29 lines
682 B
Go
29 lines
682 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 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
|
|
}
|