envconf/typeinfo.go

29 lines
682 B
Go
Raw Normal View History

2021-03-24 10:51:09 +00:00
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 boolInfo dataTypeInfo
intInfo.name = "int"
durInfo.name = "duration"
strInfo.name = "string"
boolInfo.name = "bool"
intInfo.parser = parseInt
durInfo.parser = parseDuration
strInfo.parser = parseString
boolInfo.parser = parseBool
tInfo[TypeInt] = intInfo
tInfo[TypeDuration] = durInfo
tInfo[TypeString] = strInfo
tInfo[TypeBool] = boolInfo
}