Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ var surplusModes = rule.SurplusModeSet{rule.SurplusModeOff, rule.SurplusModeLoos
// The values rules.unused accepts, from reporting least to most.
var unusedModes = rule.UnusedModeSet{rule.UnusedModeOff, rule.UnusedModeLoose, rule.UnusedModeStrict}

// boolSetting is a true/false key, with its own error naming the two values it
// takes rather than the parser's "cannot unmarshal".
type boolSetting struct {
set bool
value bool
}

func (b *boolSetting) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&b.value); err != nil {
return fmt.Errorf("want true or false")
}
b.set = true
return nil
}

// File is the on-disk configuration. Every field is optional, and no setting
// has a zero value that means anything, so a field left empty is skipped by
// Apply: omitting a key keeps the built-in default rather than silently
Expand All @@ -102,6 +87,21 @@ type File struct {
path string
}

// boolSetting is a true/false key, with its own error naming the two values it
// takes rather than the parser's "cannot unmarshal".
type boolSetting struct {
set bool
value bool
}

func (b *boolSetting) UnmarshalYAML(node *yaml.Node) error {
if err := node.Decode(&b.value); err != nil {
return fmt.Errorf("want true or false")
}
b.set = true
return nil
}

// Each section is a named type so that go-yaml's strict-decoding error can name
// the section a misspelled key sits in, rather than printing the anonymous
// struct's whole type literal.
Expand Down
Loading