gcfg.v1: gopkg.in/gcfg.v1/types Index | Files

package types

import "gopkg.in/gcfg.v1/types"

Package types defines helpers for type conversions.

The API for this package is not finalized yet.

Index

Package Files

bool.go doc.go enum.go int.go scan.go

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.

func ParseBool Uses

func ParseBool(s string) (bool, error)

ParseBool parses bool values according to the definitions in BoolValues. Parsing is case-insensitive.

func ParseInt Uses

func ParseInt(intptr interface{}, val string, mode IntMode) error

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 Uses

func ScanFully(ptr interface{}, val string, verb byte) error

ScanFully uses fmt.Sscanf with verb to fully scan val into ptr.

type EnumParser Uses

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 Uses

func (ep *EnumParser) AddVals(vals map[string]interface{})

AddVals adds strings and values to an EnumParser.

func (EnumParser) Parse Uses

func (ep EnumParser) Parse(s string) (interface{}, error)

Parse parses the string and returns the value or an error.

type IntMode Uses

type IntMode uint8

An IntMode is a mode for parsing integer values, representing a set of accepted bases.

const (
    Dec IntMode = 1 << iota
    Hex
    Oct
)

IntMode values for ParseInt; can be combined using binary or.

func (IntMode) String Uses

func (m IntMode) String() string

String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`.

Package types imports 4 packages (graph) and is imported by 1 packages. Updated 2018-05-28. Refresh now. Tools for package owners.