envconf/typeinfo.go

46 lines
980 B
Go
Raw Normal View History

2021-03-24 10:51:09 +00:00
package envconf
2021-03-26 16:17:52 +00:00
2021-03-24 10:51:09 +00:00
type dataTypeInfo struct {
2022-01-28 18:38:27 +00:00
parser func(string, string, uint) cValue
2021-03-26 16:17:52 +00:00
name string
2021-03-24 10:51:09 +00:00
}
2021-03-26 16:17:52 +00:00
2021-03-24 10:51:09 +00:00
var tInfo map[DataType]dataTypeInfo
2021-03-26 16:17:52 +00:00
2021-03-24 10:51:09 +00:00
func init() {
2021-03-26 16:17:52 +00:00
tInfo = make(map[DataType]dataTypeInfo)
var intInfo dataTypeInfo
var metricInfo dataTypeInfo
var durInfo dataTypeInfo
var strInfo dataTypeInfo
var dirInfo dataTypeInfo
2022-01-16 17:24:24 +00:00
var hexInfo dataTypeInfo
2022-01-16 20:48:29 +00:00
2021-03-26 16:17:52 +00:00
var boolInfo dataTypeInfo
2021-03-24 10:51:09 +00:00
2021-03-26 16:17:52 +00:00
intInfo.name = "int"
metricInfo.name = "metric"
durInfo.name = "duration"
dirInfo.name = "directory"
strInfo.name = "string"
2022-01-16 17:24:24 +00:00
hexInfo.name = "hex"
2021-03-26 16:17:52 +00:00
boolInfo.name = "bool"
2021-03-24 10:51:09 +00:00
2021-03-26 16:17:52 +00:00
intInfo.parser = parseInt
metricInfo.parser = parseMetric
durInfo.parser = parseDuration
dirInfo.parser = parseDirectory
strInfo.parser = parseString
2022-01-16 20:48:29 +00:00
2022-01-16 17:24:24 +00:00
hexInfo.parser = parseHex
2021-03-26 16:17:52 +00:00
boolInfo.parser = parseBool
2021-03-24 10:51:09 +00:00
2021-03-26 16:17:52 +00:00
tInfo[TypeInt] = intInfo
tInfo[TypeMetric] = metricInfo
tInfo[TypeDuration] = durInfo
tInfo[TypeString] = strInfo
tInfo[TypeDirectory] = dirInfo
2022-01-16 17:24:24 +00:00
tInfo[TypeHex] = hexInfo
2021-03-26 16:17:52 +00:00
tInfo[TypeBool] = boolInfo
2021-03-24 10:51:09 +00:00
}