Enforce Go style rules across codebase

Apply five style rules: convert iota string enums to typed
string constants, replace errors.As with errors.AsType,
merge three-group imports into two groups, fix multiline
parameter/argument formatting, and replace fmt.Sprintf URL
construction with net/url.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-20 11:46:39 +04:00
parent 34c25c2727
commit f5703d390b
105 changed files with 1180 additions and 940 deletions

View File

@@ -20,26 +20,24 @@ import (
)
type (
EvidenceState uint8
EvidenceState string
)
const (
EvidenceStateRequested EvidenceState = iota
EvidenceStateFulfilled
EvidenceStateRequested EvidenceState = "REQUESTED"
EvidenceStateFulfilled EvidenceState = "FULFILLED"
)
func (es EvidenceState) MarshalText() ([]byte, error) {
return []byte(es.String()), nil
return []byte(es), nil
}
func (es *EvidenceState) UnmarshalText(data []byte) error {
val := string(data)
val := EvidenceState(data)
switch val {
case EvidenceStateRequested.String():
*es = EvidenceStateRequested
case EvidenceStateFulfilled.String():
*es = EvidenceStateFulfilled
case EvidenceStateRequested, EvidenceStateFulfilled:
*es = val
default:
return fmt.Errorf("invalid EvidenceState value: %q", val)
}
@@ -48,16 +46,7 @@ func (es *EvidenceState) UnmarshalText(data []byte) error {
}
func (es EvidenceState) String() string {
var val string
switch es {
case EvidenceStateRequested:
val = "REQUESTED"
case EvidenceStateFulfilled:
val = "FULFILLED"
}
return val
return string(es)
}
func (es *EvidenceState) Scan(value any) error {
@@ -70,5 +59,5 @@ func (es *EvidenceState) Scan(value any) error {
}
func (es EvidenceState) Value() (driver.Value, error) {
return es.String(), nil
return string(es), nil
}