envconf/typeinfo.go

46 lines
980 B
Go

package envconf
type dataTypeInfo struct {
parser func(string, string, uint) cValue
name string
}
var tInfo map[DataType]dataTypeInfo
func init() {
tInfo = make(map[DataType]dataTypeInfo)
var intInfo dataTypeInfo
var metricInfo dataTypeInfo
var durInfo dataTypeInfo
var strInfo dataTypeInfo
var dirInfo dataTypeInfo
var hexInfo dataTypeInfo
var boolInfo dataTypeInfo
intInfo.name = "int"
metricInfo.name = "metric"
durInfo.name = "duration"
dirInfo.name = "directory"
strInfo.name = "string"
hexInfo.name = "hex"
boolInfo.name = "bool"
intInfo.parser = parseInt
metricInfo.parser = parseMetric
durInfo.parser = parseDuration
dirInfo.parser = parseDirectory
strInfo.parser = parseString
hexInfo.parser = parseHex
boolInfo.parser = parseBool
tInfo[TypeInt] = intInfo
tInfo[TypeMetric] = metricInfo
tInfo[TypeDuration] = durInfo
tInfo[TypeString] = strInfo
tInfo[TypeDirectory] = dirInfo
tInfo[TypeHex] = hexInfo
tInfo[TypeBool] = boolInfo
}