package types
import "github.com/scalingdata/gcfg/types"
Package types defines helpers for type conversions.
The API for this package is not finalized yet.
Index ¶
- Variables
- func ParseBool(s string) (bool, error)
- func ParseInt(intptr interface{}, val string, mode IntMode) error
- func ScanFully(ptr interface{}, val string, verb byte) error
- type EnumParser
- func (ep *EnumParser) AddVals(vals map[string]interface{})
- func (ep EnumParser) Parse(s string) (interface{}, error)
- type IntMode
Variables ¶
var BoolValues = map[string]interface{}{ "true": true, "yes": true, "on": true, "1": true, "false": false, "no": false, "off": false, "0": false, }
BoolValues defines the name and value mappings for ParseBool.
Functions ¶
func ParseBool ¶
ParseBool parses bool values according to the definitions in BoolValues. Parsing is case-insensitive.
func ParseInt ¶
ParseInt parses val using mode into intptr, which must be a pointer to an integer kind type. Non-decimal value require prefix `0` or `0x` in the cases when mode permits ambiguity of base; otherwise the prefix can be omitted.
func ScanFully ¶
ScanFully uses fmt.Sscanf with verb to fully scan val into ptr.
Types ¶
type EnumParser ¶
type EnumParser struct { Type string // type name; if not set, use type of first value added CaseMatch bool // if true, matching of strings is case-sensitive // contains filtered or unexported fields }
EnumParser parses "enum" values; i.e. a predefined set of strings to predefined values.
func (*EnumParser) AddVals ¶
func (ep *EnumParser) AddVals(vals map[string]interface{})
AddVals adds strings and values to an EnumParser.
func (EnumParser) Parse ¶
func (ep EnumParser) Parse(s string) (interface{}, error)
Parse parses the string and returns the value or an error.
type IntMode ¶
type IntMode uint8
An IntMode is a mode for parsing integer values, representing a set of accepted bases.
IntMode values for ParseInt; can be combined using binary or.
func (IntMode) String ¶
String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`.
Source Files ¶
bool.go doc.go enum.go int.go scan.go
- Version
- v0.0.0-20140729183856-37aabad69cfd (latest)
- Published
- Jul 29, 2014
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 3 days ago –
Tools for package owners.