37 lines
947 B
Go
37 lines
947 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 metricInfo dataTypeInfo
|
|
var durInfo dataTypeInfo
|
|
var strInfo dataTypeInfo
|
|
var dirInfo dataTypeInfo
|
|
var boolInfo dataTypeInfo
|
|
|
|
intInfo.name = "int"
|
|
metricInfo.name = "metric"
|
|
durInfo.name = "duration"
|
|
dirInfo.name = "directory"
|
|
strInfo.name = "string"
|
|
boolInfo.name = "bool"
|
|
|
|
intInfo.parser = parseInt
|
|
metricInfo.parser = parseMetric
|
|
durInfo.parser = parseDuration
|
|
dirInfo.parser = parseDirectory
|
|
strInfo.parser = parseString
|
|
boolInfo.parser = parseBool
|
|
|
|
tInfo[TypeInt] = intInfo
|
|
tInfo[TypeMetric] = metricInfo
|
|
tInfo[TypeDuration] = durInfo
|
|
tInfo[TypeString] = strInfo
|
|
tInfo[TypeDirectory] = dirInfo
|
|
tInfo[TypeBool] = boolInfo
|
|
}
|