envconf/typeinfo.go

62 lines
1.3 KiB
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 {
2021-03-26 16:17:52 +00:00
parser func(string, string) cValue
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
var hexInfo16 dataTypeInfo
var hexInfo32 dataTypeInfo
var hexInfo64 dataTypeInfo
var hexInfo128 dataTypeInfo
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
2022-01-16 20:48:29 +00:00
hexInfo16.parser = parseHex16
hexInfo32.parser = parseHex32
hexInfo64.parser = parseHex64
hexInfo128.parser = parseHex128
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
2022-01-16 20:48:29 +00:00
tInfo[TypeHex16] = hexInfo16
tInfo[TypeHex32] = hexInfo32
tInfo[TypeHex64] = hexInfo64
tInfo[TypeHex128] = hexInfo128
2021-03-26 16:17:52 +00:00
tInfo[TypeBool] = boolInfo
2021-03-24 10:51:09 +00:00
}