envconf/typeinfo.go

37 lines
947 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
2021-03-25 11:06:08 +00:00
var metricInfo dataTypeInfo
2021-03-24 10:51:09 +00:00
var durInfo dataTypeInfo
var strInfo dataTypeInfo
2021-03-24 14:15:37 +00:00
var dirInfo dataTypeInfo
2021-03-24 10:51:09 +00:00
var boolInfo dataTypeInfo
intInfo.name = "int"
2021-03-25 11:06:08 +00:00
metricInfo.name = "metric"
2021-03-24 10:51:09 +00:00
durInfo.name = "duration"
2021-03-24 14:15:37 +00:00
dirInfo.name = "directory"
2021-03-24 10:51:09 +00:00
strInfo.name = "string"
boolInfo.name = "bool"
intInfo.parser = parseInt
2021-03-25 11:06:08 +00:00
metricInfo.parser = parseMetric
2021-03-24 10:51:09 +00:00
durInfo.parser = parseDuration
2021-03-24 14:15:37 +00:00
dirInfo.parser = parseDirectory
2021-03-24 10:51:09 +00:00
strInfo.parser = parseString
boolInfo.parser = parseBool
tInfo[TypeInt] = intInfo
2021-03-25 11:06:08 +00:00
tInfo[TypeMetric] = metricInfo
2021-03-24 10:51:09 +00:00
tInfo[TypeDuration] = durInfo
tInfo[TypeString] = strInfo
2021-03-24 14:15:37 +00:00
tInfo[TypeDirectory] = dirInfo
2021-03-24 10:51:09 +00:00
tInfo[TypeBool] = boolInfo
}