blob: 50832ac635be85bb4c2518b19bbfec91454b095f [file] [log] [blame]
package gcfg
import (
"fmt"
"strings"
)
type gbool bool
var gboolValues = map[string]gbool{
"true": true, "yes": true, "on": true, "1": true,
"false": false, "no": false, "off": false, "0": false}
func (b *gbool) UnmarshalText(text []byte) error {
s := strings.ToLower(string(text))
v, ok := gboolValues[s]
if !ok {
return fmt.Errorf("failed to parse %#q as bool", s)
}
*b = gbool(v)
return nil
}
var _ textUnmarshaler = new(gbool)