envconf/typeinfo.go

33 lines
813 B
Go

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