chore: minor

This commit is contained in:
andig 2026-08-11 09:54:34 +02:00
parent dc143a6dc7
commit 6fdb83fc14
10 changed files with 24 additions and 29 deletions

View file

@ -202,7 +202,7 @@ func NewStatusMap(a, b, c string) (StatusMap, error) {
{api.StatusB, b},
{api.StatusC, c},
} {
for _, s := range strings.Split(e.states, ",") {
for s := range strings.SplitSeq(e.states, ",") {
if s = strings.ToLower(strings.TrimSpace(s)); s != "" {
if status, ok := res[s]; ok {
return nil, fmt.Errorf("status %s: duplicate state '%s', already mapped to %s", e.status, s, status)

View file

@ -45,7 +45,7 @@ func TestTraceBudget(t *testing.T) {
log.Write([]byte(s2))
for i := range 100 {
log.Write([]byte(fmt.Sprintf("[mqtt ] TRACE send %d", i)))
log.Write(fmt.Appendf(nil, "[mqtt ] TRACE send %d", i))
}
assert.Equal(t, []string{s2}, log.All(nil, jww.LevelDebug, 0))

View file

@ -137,7 +137,7 @@ func redactToken(token string) string {
type Status struct {
Name string `json:"name"`
ExpiresAt time.Time `json:"expiresAt,omitempty"`
ExpiresAt time.Time `json:"expiresAt"`
ExpiresSoon bool `json:"expiresSoon,omitempty"`
Token string `json:"token,omitempty"`
}

View file

@ -38,7 +38,7 @@ func checkPulsares() (string, error) {
_ = f.Close()
})
var token string
var token strings.Builder
b := make([]byte, 512)
for {
@ -47,9 +47,9 @@ func checkPulsares() (string, error) {
return "", nil
}
token += string(b[:n])
token.WriteString(string(b[:n]))
if token, ok := strings.CutSuffix(token, "\x04"); ok {
if token, ok := strings.CutSuffix(token.String(), "\x04"); ok {
return token, nil
}
}

View file

@ -327,7 +327,7 @@ func (p Param) MarshalJSON() ([]byte, error) {
// Product contains naming information about a product a template supports
type Product struct {
Brand string // product brand
Description TextLanguage `json:",omitempty"` // product name
Description TextLanguage // product name
Capabilities []Capability `json:",omitempty"` // appended to template-level capabilities
}