Compare commits

..

No commits in common. "master" and "v0.1.51" have entirely different histories.

10 changed files with 236 additions and 1243 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
tests/buildenv/*
tests/bin/*

View File

@ -1,6 +1,3 @@
#!/usr/bin/env bash #!/usr/bin/env bash
go fmt *.go go fmt *.go
go fmt tests/*.go git add *.go
git add *.go tests/*.go
git add tests/*.go

View File

@ -1,916 +0,0 @@
package envconf
import "time"
type mapEnvType [5]*keyLookupType
func (c *Config) GetMapInt(key string) (empty map[string]int64) {
empty = make(map[string]int64)
retval := make(map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeInt.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.intval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapMetric(key string) (empty map[string]int64) {
empty = make(map[string]int64)
retval := make(map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeMetric.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.intval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapDuration(key string) (empty map[string]time.Duration) {
empty = make(map[string]time.Duration)
retval := make(map[string]time.Duration)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeDuration.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.durval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapString(key string) (empty map[string]string) {
empty = make(map[string]string)
retval := make(map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeString.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.strval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapDirectory(key string) (empty map[string]string) {
empty = make(map[string]string)
retval := make(map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeDirectory.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.strval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapBool(key string) (empty map[string]bool) {
empty = make(map[string]bool)
retval := make(map[string]bool)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeBool.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.boolval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapHex(key string) (empty map[string][]byte) {
empty = make(map[string][]byte)
retval := make(map[string][]byte)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[0].next[key]
if ok {
for k11, v11 := range v10.next {
entry := c.env[v11.key]
if (entry.dtype.baseType() == TypeHex.baseType()) && (entry.parsed.err == nil) {
retval[k11] = entry.parsed.binval
} else {
return
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapInt(key string) (empty map[string]map[string]int64) {
empty = make(map[string]map[string]int64)
retval := make(map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]int64)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeInt.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.intval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMetric(key string) (empty map[string]map[string]int64) {
empty = make(map[string]map[string]int64)
retval := make(map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]int64)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeMetric.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.intval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapDuration(key string) (empty map[string]map[string]time.Duration) {
empty = make(map[string]map[string]time.Duration)
retval := make(map[string]map[string]time.Duration)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]time.Duration)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeDuration.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.durval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapString(key string) (empty map[string]map[string]string) {
empty = make(map[string]map[string]string)
retval := make(map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]string)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeString.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.strval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapDirectory(key string) (empty map[string]map[string]string) {
empty = make(map[string]map[string]string)
retval := make(map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]string)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeDirectory.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.strval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapBool(key string) (empty map[string]map[string]bool) {
empty = make(map[string]map[string]bool)
retval := make(map[string]map[string]bool)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]bool)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeBool.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.boolval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapHex(key string) (empty map[string]map[string][]byte) {
empty = make(map[string]map[string][]byte)
retval := make(map[string]map[string][]byte)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[1].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string][]byte)
for k12, v12 := range v11.next {
entry := c.env[v12.key]
if (entry.dtype.baseType() == TypeHex.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12] = entry.parsed.binval
} else {
return
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapInt(key string) (empty map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]int64)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeInt.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.intval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMetric(key string) (empty map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]int64)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeMetric.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.intval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapDuration(key string) (empty map[string]map[string]map[string]time.Duration) {
empty = make(map[string]map[string]map[string]time.Duration)
retval := make(map[string]map[string]map[string]time.Duration)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]time.Duration)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]time.Duration)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeDuration.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.durval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapString(key string) (empty map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]string)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeString.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.strval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapDirectory(key string) (empty map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]string)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeDirectory.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.strval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapBool(key string) (empty map[string]map[string]map[string]bool) {
empty = make(map[string]map[string]map[string]bool)
retval := make(map[string]map[string]map[string]bool)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]bool)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]bool)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeBool.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.boolval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapHex(key string) (empty map[string]map[string]map[string][]byte) {
empty = make(map[string]map[string]map[string][]byte)
retval := make(map[string]map[string]map[string][]byte)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[2].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string][]byte)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string][]byte)
for k13, v13 := range v12.next {
entry := c.env[v13.key]
if (entry.dtype.baseType() == TypeHex.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13] = entry.parsed.binval
} else {
return
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapInt(key string) (empty map[string]map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]int64)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]int64)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeInt.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.intval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMetric(key string) (empty map[string]map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]int64)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]int64)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeMetric.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.intval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapDuration(key string) (empty map[string]map[string]map[string]map[string]time.Duration) {
empty = make(map[string]map[string]map[string]map[string]time.Duration)
retval := make(map[string]map[string]map[string]map[string]time.Duration)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]time.Duration)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]time.Duration)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]time.Duration)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeDuration.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.durval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapString(key string) (empty map[string]map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]string)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]string)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeString.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.strval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapDirectory(key string) (empty map[string]map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]string)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]string)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeDirectory.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.strval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapBool(key string) (empty map[string]map[string]map[string]map[string]bool) {
empty = make(map[string]map[string]map[string]map[string]bool)
retval := make(map[string]map[string]map[string]map[string]bool)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]bool)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]bool)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]bool)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeBool.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.boolval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapHex(key string) (empty map[string]map[string]map[string]map[string][]byte) {
empty = make(map[string]map[string]map[string]map[string][]byte)
retval := make(map[string]map[string]map[string]map[string][]byte)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[3].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string][]byte)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string][]byte)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string][]byte)
for k14, v14 := range v13.next {
entry := c.env[v14.key]
if (entry.dtype.baseType() == TypeHex.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14] = entry.parsed.binval
} else {
return
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapInt(key string) (empty map[string]map[string]map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]int64)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]int64)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]int64)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeInt.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.intval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapMetric(key string) (empty map[string]map[string]map[string]map[string]map[string]int64) {
empty = make(map[string]map[string]map[string]map[string]map[string]int64)
retval := make(map[string]map[string]map[string]map[string]map[string]int64)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]int64)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]int64)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]int64)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]int64)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeMetric.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.intval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapDuration(key string) (empty map[string]map[string]map[string]map[string]map[string]time.Duration) {
empty = make(map[string]map[string]map[string]map[string]map[string]time.Duration)
retval := make(map[string]map[string]map[string]map[string]map[string]time.Duration)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]time.Duration)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]time.Duration)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]time.Duration)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]time.Duration)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeDuration.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.durval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapString(key string) (empty map[string]map[string]map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]string)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]string)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]string)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeString.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.strval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapDirectory(key string) (empty map[string]map[string]map[string]map[string]map[string]string) {
empty = make(map[string]map[string]map[string]map[string]map[string]string)
retval := make(map[string]map[string]map[string]map[string]map[string]string)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]string)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]string)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]string)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]string)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeDirectory.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.strval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapBool(key string) (empty map[string]map[string]map[string]map[string]map[string]bool) {
empty = make(map[string]map[string]map[string]map[string]map[string]bool)
retval := make(map[string]map[string]map[string]map[string]map[string]bool)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string]bool)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string]bool)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string]bool)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string]bool)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeBool.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.boolval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}
func (c *Config) GetMapMapMapMapMapHex(key string) (empty map[string]map[string]map[string]map[string]map[string][]byte) {
empty = make(map[string]map[string]map[string]map[string]map[string][]byte)
retval := make(map[string]map[string]map[string]map[string]map[string][]byte)
if c.parsed {
key = cleanKey(key)
v10, ok := c.mapEnv[4].next[key]
if ok {
for k11, v11 := range v10.next {
retval[k11] = make(map[string]map[string]map[string]map[string][]byte)
for k12, v12 := range v11.next {
retval[k11][k12] = make(map[string]map[string]map[string][]byte)
for k13, v13 := range v12.next {
retval[k11][k12][k13] = make(map[string]map[string][]byte)
for k14, v14 := range v13.next {
retval[k11][k12][k13][k14] = make(map[string][]byte)
for k15, v15 := range v14.next {
entry := c.env[v15.key]
if (entry.dtype.baseType() == TypeHex.baseType()) && (entry.parsed.err == nil) {
retval[k11][k12][k13][k14][k15] = entry.parsed.binval
} else {
return
}
}
}
}
}
}
return retval
}
}
return
}

View File

@ -1,40 +1,26 @@
package envconf package envconf
import ( import (
"fmt"
"time" "time"
) )
type DataType uint32 type DataType int
const ( const (
sizeBitmask DataType = 0xffff TypeNone DataType = iota
typeBitmask DataType = sizeBitmask << 16 TypeInt DataType = iota
TypeMetric DataType = iota
TypeDuration DataType = iota
TypeString DataType = iota
TypeDirectory DataType = iota
TypeBool DataType = iota
TypeHex DataType = iota
TypeHex16 DataType = iota
TypeHex32 DataType = iota
TypeHex64 DataType = iota
TypeHex128 DataType = iota
) )
const (
TypeNone DataType = iota << 16
TypeInt DataType = iota << 16
TypeMetric DataType = iota << 16
TypeDuration DataType = iota << 16
TypeString DataType = iota << 16
TypeDirectory DataType = iota << 16
TypeBool DataType = iota << 16
TypeHex DataType = iota << 16
)
func FixedHex(size uint16) DataType {
return TypeHex | DataType(size)
}
func (dtype DataType) baseType() DataType {
return dtype & typeBitmask
}
func (dtype DataType) typeAndSize() (DataType, int) {
return (dtype & typeBitmask), int(dtype & sizeBitmask)
}
type cValue struct { type cValue struct {
dtype DataType dtype DataType
intval int64 intval int64
@ -46,24 +32,18 @@ type cValue struct {
} }
func (dtype DataType) parse(key string, str string) (ret cValue) { func (dtype DataType) parse(key string, str string) (ret cValue) {
rdtype, size := dtype.typeAndSize() info, ok := tInfo[dtype]
info, ok := tInfo[rdtype]
if ok { if ok {
ret = info.parser(key, str, size) ret = info.parser(key, str)
if len(ret.binval) == 0 { if len(ret.binval) == 0 {
ret.binval = make([]byte, 0, 0) ret.binval = make([]byte, 0, 0)
} }
} }
return return
} }
func (dtype DataType) String() string { func (dtype DataType) String() string {
rdtype, size := dtype.typeAndSize() info, ok := tInfo[dtype]
info, ok := tInfo[rdtype]
if ok { if ok {
if size > 0 {
return fmt.Sprintf("%s%d", info.name, size)
}
return info.name return info.name
} }
return "invalid" return "invalid"

View File

@ -20,48 +20,10 @@ type cEntry struct {
hasdef bool // Default value is defined hasdef bool // Default value is defined
} }
type keyLookupType struct {
key string
end bool
next map[string]*keyLookupType
}
func (kl *keyLookupType) setKey(parts []string, key string) {
if len(kl.next) == 0 {
kl.next = make(map[string]*keyLookupType)
}
if len(parts) > 0 {
firstPart := parts[0]
nextLookup, ok := kl.next[firstPart]
if ok {
nextLookup.setKey(parts[1:], key)
} else {
nextLookup := new(keyLookupType)
nextLookup.setKey(parts[1:], key)
kl.next[firstPart] = nextLookup
}
} else {
kl.key = key
kl.end = true
}
}
func (kl *keyLookupType) print() {
if kl.end {
fmt.Println(kl.key)
fmt.Println("-----------------")
return
}
for key, val := range kl.next {
fmt.Println(key)
val.print()
}
}
type Config struct { type Config struct {
parsed bool parsed bool
env map[string]cEntry env map[string]cEntry
mapEnv *mapEnvType mapEnv map[string]map[string]cEntry
} }
// NewConfig returns an envconf.Config that is used to read configuration from environment variables. // NewConfig returns an envconf.Config that is used to read configuration from environment variables.
@ -71,42 +33,27 @@ func NewConfig() *Config {
config := new(Config) config := new(Config)
config.parsed = false config.parsed = false
config.env = make(map[string]cEntry) config.env = make(map[string]cEntry)
config.mapEnv = make(map[string]map[string]cEntry)
config.mapEnv = new(mapEnvType)
for level, _ := range config.mapEnv {
config.mapEnv[level] = new(keyLookupType)
}
for _, v := range os.Environ() { for _, v := range os.Environ() {
splitted := strings.SplitN(v, "=", 2) splitted := strings.SplitN(v, "=", 2)
if len(splitted) == 2 { if len(splitted) == 2 {
key := cleanKey(splitted[0]) key := cleanKey(splitted[0])
val := splitted[1] left, right, mappable := keySplit(key)
splitted = strings.Split(key, "_")
maxParts := len(splitted)
splitted = append(splitted, make([]string, len(config.mapEnv), len(config.mapEnv))...)
if unicode.IsLetter(getFirstRune(key)) { if unicode.IsLetter(getFirstRune(key)) {
var entry cEntry var entry cEntry
entry.value = val entry.value = splitted[1]
entry.dtype = TypeNone entry.dtype = TypeNone
entry.unset = false entry.unset = false
entry.empty = false entry.empty = false
config.env[key] = entry config.env[key] = entry
if len(splitted) > 1 { if mappable {
for level := 0; level < len(config.mapEnv); level++ { if len(config.mapEnv[left]) == 0 {
for count := 0; count < maxParts-1-level; count++ { config.mapEnv[left] = make(map[string]cEntry)
parts := make([]string, level+2, level+2)
lastSplit := len(parts) - 1 + count
for partPos, _ := range parts {
parts[partPos] = splitted[partPos+count]
}
parts[0] = strings.Trim(strings.Join(splitted[:count+1], "_"), "_")
parts[len(parts)-1] = strings.Trim(strings.Join(splitted[lastSplit:], "_"), "_")
config.mapEnv[level].setKey(parts, key)
}
} }
config.mapEnv[left][right] = entry
} }
} }
} }
@ -135,12 +82,11 @@ func (c *Config) Define(key string, dtype DataType) {
// Variables without a defined type will be ignored by Parse. // Variables without a defined type will be ignored by Parse.
func (c *Config) DefineMap(key string, dtype DataType) { func (c *Config) DefineMap(key string, dtype DataType) {
key = cleanKey(key) key = cleanKey(key)
entries, ok := c.mapEnv[0].next[key] entries, ok := c.mapEnv[key]
if ok { if ok {
for _, entry := range entries.next { for mapKey, entry := range entries {
defEntry := c.env[entry.key] entry.dtype = dtype
defEntry.dtype = dtype c.mapEnv[key][mapKey] = entry
c.env[entry.key] = defEntry
} }
} }
} }
@ -190,6 +136,13 @@ func (c *Config) Parse() {
} }
} }
for k, v := range c.mapEnv {
for mk, mv := range v {
mv.parsed = mv.dtype.parse(k+"_"+mk, mv.value)
c.mapEnv[k][mk] = mv
}
}
if failed { if failed {
for k, v := range c.env { for k, v := range c.env {
if (v.parsed.err == nil) && v.unset { if (v.parsed.err == nil) && v.unset {
@ -281,7 +234,17 @@ func (c *Config) Status() (ok bool) {
} }
} }
} }
for _, v := range c.mapEnv {
for _, mv := range v {
err := mv.parsed.err
if err != nil {
ok = false
if !mv.empty {
fmt.Fprintln(os.Stderr, err)
}
}
}
}
if !ok { if !ok {
fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, "")
for _, v := range c.env { for _, v := range c.env {
@ -324,13 +287,34 @@ func (c *Config) getRaw(key string, dtype DataType) (val cValue) {
if c.parsed { if c.parsed {
key = cleanKey(key) key = cleanKey(key)
entry, ok := c.env[key] entry, ok := c.env[key]
if ok && (entry.dtype.baseType() == dtype.baseType()) { if ok && (entry.dtype == dtype) {
return entry.parsed return entry.parsed
} }
} }
return return
} }
func (c *Config) getRawMap(key string, dtype DataType) (empty map[string]cValue) {
empty = make(map[string]cValue)
retval := make(map[string]cValue)
if c.parsed {
key = cleanKey(key)
entries, ok := c.mapEnv[key]
if ok {
for k, v := range entries {
if (v.dtype == dtype) && (v.parsed.err == nil) {
retval[k] = v.parsed
} else {
return
}
}
return retval
}
}
return
}
// Returns the value of an environment variable. // Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeInt the function will return 0. // If the variable is not defined as envconf.TypeInt the function will return 0.
func (c *Config) GetInt(key string) int64 { func (c *Config) GetInt(key string) int64 {
@ -345,6 +329,34 @@ func (c *Config) GetHex(key string) []byte {
return val.binval return val.binval
} }
// Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeHex16 the function will return []byte{}.
func (c *Config) GetHex16(key string) []byte {
val := c.getRaw(key, TypeHex16)
return val.binval
}
// Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeHex32 the function will return []byte{}.
func (c *Config) GetHex32(key string) []byte {
val := c.getRaw(key, TypeHex32)
return val.binval
}
// Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeHex64 the function will return []byte{}.
func (c *Config) GetHex64(key string) []byte {
val := c.getRaw(key, TypeHex64)
return val.binval
}
// Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeHex128 the function will return []byte{}.
func (c *Config) GetHex128(key string) []byte {
val := c.getRaw(key, TypeHex128)
return val.binval
}
// Returns the value of an environment variable. // Returns the value of an environment variable.
// If the variable is not defined as envconf.TypeMetric the function will return 0. // If the variable is not defined as envconf.TypeMetric the function will return 0.
func (c *Config) GetMetric(key string) int64 { func (c *Config) GetMetric(key string) int64 {
@ -384,6 +396,78 @@ func (c *Config) GetBool(key string) bool {
return val.boolval return val.boolval
} }
func (c *Config) GetMapInt(key string) (retval map[string]int64) {
retval = make(map[string]int64)
for k, v := range c.getRawMap(key, TypeInt) {
retval[k] = v.intval
}
return
}
func (c *Config) GetMapDuration(key string) (retval map[string]time.Duration) {
retval = make(map[string]time.Duration)
for k, v := range c.getRawMap(key, TypeDuration) {
retval[k] = v.durval
}
return
}
func (c *Config) GetMapString(key string) (retval map[string]string) {
retval = make(map[string]string)
for k, v := range c.getRawMap(key, TypeString) {
retval[k] = v.strval
}
return
}
func (c *Config) GetMapBool(key string) (retval map[string]bool) {
retval = make(map[string]bool)
for k, v := range c.getRawMap(key, TypeBool) {
retval[k] = v.boolval
}
return
}
func (c *Config) GetMapHex(key string) (retval map[string][]byte) {
retval = make(map[string][]byte)
for k, v := range c.getRawMap(key, TypeHex) {
retval[k] = v.binval
}
return
}
func (c *Config) GetMapHex16(key string) (retval map[string][]byte) {
retval = make(map[string][]byte)
for k, v := range c.getRawMap(key, TypeHex16) {
retval[k] = v.binval
}
return
}
func (c *Config) GetMapHex32(key string) (retval map[string][]byte) {
retval = make(map[string][]byte)
for k, v := range c.getRawMap(key, TypeHex32) {
retval[k] = v.binval
}
return
}
func (c *Config) GetMapHex64(key string) (retval map[string][]byte) {
retval = make(map[string][]byte)
for k, v := range c.getRawMap(key, TypeHex64) {
retval[k] = v.binval
}
return
}
func (c *Config) GetMapHex128(key string) (retval map[string][]byte) {
retval = make(map[string][]byte)
for k, v := range c.getRawMap(key, TypeHex128) {
retval[k] = v.binval
}
return
}
func getFirstRune(str string) rune { func getFirstRune(str string) rune {
for _, v := range str { for _, v := range str {
return v return v

View File

@ -1,155 +0,0 @@
#!/usr/bin/env python3
import typing
import tempfile
import os.path
import os
import shutil
import subprocess
from dataclasses import dataclass
@dataclass
class DataType:
const_type: str
go_type: str
sig_type: str
value_type: str
def get_return_type(levels: int, dtype: str) -> str:
return ("map[string]" * levels) + dtype
def get_signature(levels: int, data_type: DataType) -> str:
return (
"func (c *Config) Get"
+ ("Map" * levels)
+ data_type.sig_type
+ "(key string) (empty "
+ get_return_type(levels, data_type.go_type)
+ ") {"
)
def get_empty_def(levels: int, data_type: DataType) -> str:
return "empty = make(" + get_return_type(levels, data_type.go_type) + ")"
def get_nested_keys(levels: int) -> str:
txt = ""
for count in range(levels):
txt += "[k" + str(count + 11) + "]"
return txt
def get_retval_def(levels: int, current_level: int, data_type: DataType) -> str:
base = "retval := make("
if current_level > 0:
base = "retval" + get_nested_keys(current_level) + " = make("
return base + get_return_type(levels - current_level, data_type.go_type) + ")"
def get_entries(levels: int) -> str:
return f"v10, ok := c.mapEnv[{levels-1}].next[key]"
def get_entry(levels: int) -> str:
return f"entry := c.env[v{levels + 11}.key]"
def set_value(levels: int, data_type: DataType) -> str:
return f"retval{get_nested_keys(levels + 1)} = entry.parsed.{data_type.value_type}"
def get_loop(levels: int) -> str:
return f"for k{levels + 11}, v{levels + 11} := range v{levels + 10}.next {{"
def get_function(file: typing.TextIO, levels: int, data_type: DataType):
print(get_signature(levels, data_type), file=file)
print(get_empty_def(levels, data_type), file=file)
print(get_retval_def(levels, 0, data_type), file=file)
print("if c.parsed {", file=file)
print("key = cleanKey(key)", file=file)
print(get_entries(levels), file=file)
print("if ok {", file=file)
for level in range(levels - 1):
print(get_loop(level), file=file)
print(get_retval_def(levels, level + 1, data_type), file=file)
print(get_loop(levels - 1), file=file)
print(get_entry(levels - 1), file=file)
print(
f"if (entry.dtype.baseType() == {data_type.const_type}.baseType()) && (entry.parsed.err == nil) {{",
file=file,
)
print(set_value(levels - 1, data_type), file=file)
print("} else {", file=file)
print("return", file=file)
print("};" * (levels + 1), file=file)
print("return retval", file=file)
print("}", file=file)
print("}", file=file)
print("return", file=file)
print("}", file=file)
def main():
data_types = [
DataType(
const_type="TypeInt", go_type="int64", sig_type="Int", value_type="intval"
),
DataType(
const_type="TypeMetric",
go_type="int64",
sig_type="Metric",
value_type="intval",
),
DataType(
const_type="TypeDuration",
go_type="time.Duration",
sig_type="Duration",
value_type="durval",
),
DataType(
const_type="TypeString",
go_type="string",
sig_type="String",
value_type="strval",
),
DataType(
const_type="TypeDirectory",
go_type="string",
sig_type="Directory",
value_type="strval",
),
DataType(
const_type="TypeBool", go_type="bool", sig_type="Bool", value_type="boolval"
),
DataType(
const_type="TypeHex", go_type="[]byte", sig_type="Hex", value_type="binval"
),
]
levels = 5
with tempfile.TemporaryDirectory() as pathname:
code_file = os.path.join(pathname, "code.go")
with open(code_file, mode="w", encoding="utf-8") as f:
print("package envconf", file=f)
print('import "time"', file=f)
print(f"type mapEnvType [{levels}]*keyLookupType", file=f)
for level in range(levels):
for data_type in data_types:
get_function(f, level + 1, data_type)
if subprocess.run(["go", "fmt", code_file], check=True).returncode == 0:
shutil.copyfile(
code_file,
os.path.join(
os.path.dirname(os.path.realpath(__file__)), "auto_generated.go"
),
follow_symlinks=False,
)
if __name__ == "__main__":
main()

View File

@ -11,7 +11,7 @@ import (
"time" "time"
) )
func parseInt(key string, str string, _ int) (ret cValue) { func parseInt(key string, str string) (ret cValue) {
val, err := strconv.ParseInt(str, 10, 64) val, err := strconv.ParseInt(str, 10, 64)
if err == nil { if err == nil {
ret.intval = val ret.intval = val
@ -21,7 +21,7 @@ func parseInt(key string, str string, _ int) (ret cValue) {
return return
} }
func parseMetric(key string, str string, _ int) (ret cValue) { func parseMetric(key string, str string) (ret cValue) {
mod := int64(1) mod := int64(1)
str = strings.ToUpper(str) str = strings.ToUpper(str)
if strings.HasSuffix(str, "K") { if strings.HasSuffix(str, "K") {
@ -46,7 +46,7 @@ func parseMetric(key string, str string, _ int) (ret cValue) {
return return
} }
func parseDuration(key string, str string, _ int) (ret cValue) { func parseDuration(key string, str string) (ret cValue) {
val, err := time.ParseDuration(str) val, err := time.ParseDuration(str)
if err == nil { if err == nil {
ret.durval = val ret.durval = val
@ -56,7 +56,7 @@ func parseDuration(key string, str string, _ int) (ret cValue) {
return return
} }
func parseBool(key string, str string, _ int) (ret cValue) { func parseBool(key string, str string) (ret cValue) {
val, err := strconv.ParseBool(str) val, err := strconv.ParseBool(str)
if err == nil { if err == nil {
ret.boolval = val ret.boolval = val
@ -66,21 +66,57 @@ func parseBool(key string, str string, _ int) (ret cValue) {
return return
} }
func parseHex(key string, str string, size int) (ret cValue) { func parseHex(key string, str string) (ret cValue) {
val, err := hex.DecodeString(str) val, err := hex.DecodeString(str)
if err == nil && (size == 0 || size == len(val)) { if err == nil {
ret.binval = val ret.binval = val
} else { } else {
if size == 0 { ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex.`, key))
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex.`, key))
} else {
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex%d.`, key, size))
}
} }
return return
} }
func parseDirectory(_ string, str string, _ int) (ret cValue) { func parseHex16(key string, str string) (ret cValue) {
val, err := hex.DecodeString(str)
if err == nil && len(val) == 16 {
ret.binval = val
} else {
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex16.`, key))
}
return
}
func parseHex32(key string, str string) (ret cValue) {
val, err := hex.DecodeString(str)
if err == nil && len(val) == 32 {
ret.binval = val
} else {
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex32.`, key))
}
return
}
func parseHex64(key string, str string) (ret cValue) {
val, err := hex.DecodeString(str)
if err == nil && len(val) == 64 {
ret.binval = val
} else {
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex64.`, key))
}
return
}
func parseHex128(key string, str string) (ret cValue) {
val, err := hex.DecodeString(str)
if err == nil && len(val) == 128 {
ret.binval = val
} else {
ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type hex128.`, key))
}
return
}
func parseDirectory(_ string, str string) (ret cValue) {
wd, err := os.Getwd() wd, err := os.Getwd()
if err == nil { if err == nil {
if path.IsAbs(str) { if path.IsAbs(str) {
@ -94,7 +130,7 @@ func parseDirectory(_ string, str string, _ int) (ret cValue) {
return return
} }
func parseString(_ string, str string, _ int) (ret cValue) { func parseString(_ string, str string) (ret cValue) {
ret.strval = str ret.strval = str
return return
} }

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
dir=$(dirname $(realpath $0))
export GO111MODULE=on
export GOPROXY=direct
export GOPATH=${dir}/buildenv/deps
mkdir -p ${dir}/buildenv
chmod -R 755 ${dir}/buildenv
rm -rf ${dir}/buildenv
mkdir -p "${dir}/buildenv/src"
mkdir -p ${GOPATH}/src
mkdir -p ${dir}/bin
cp -r "${dir}/main.go" "${dir}/buildenv/src/main.go"
cd ${dir}/buildenv
go mod init src
go mod tidy
package_name=$(ls ${dir}/buildenv/deps/pkg/mod/git.purser.it/roypur | tr -d "\n")
package_dir="${dir}/buildenv/deps/pkg/mod/git.purser.it/roypur/${package_name}"
chmod -R 777 "${dir}/buildenv/deps"
rm -R "${package_dir}"
mkdir -p "${package_dir}"
cp $(dirname ${dir})/*.go ${package_dir}
cd "${dir}"
go build -o "${dir}/bin/test"

View File

@ -1,16 +0,0 @@
package main
import (
"fmt"
"git.purser.it/roypur/envconf"
)
func main() {
conf := envconf.NewConfig()
conf.Define("this_is_a_map", envconf.TypeInt)
conf.DefineMap("test_map", envconf.TypeInt)
conf.Parse()
conf.Status()
fmt.Println(conf.GetMapMapMapMapMapInt("test_map"))
fmt.Println(conf.GetInt("this_is_a_map"))
}

View File

@ -1,7 +1,7 @@
package envconf package envconf
type dataTypeInfo struct { type dataTypeInfo struct {
parser func(string, string, int) cValue parser func(string, string) cValue
name string name string
} }
@ -16,6 +16,11 @@ func init() {
var dirInfo dataTypeInfo var dirInfo dataTypeInfo
var hexInfo dataTypeInfo var hexInfo dataTypeInfo
var hexInfo16 dataTypeInfo
var hexInfo32 dataTypeInfo
var hexInfo64 dataTypeInfo
var hexInfo128 dataTypeInfo
var boolInfo dataTypeInfo var boolInfo dataTypeInfo
intInfo.name = "int" intInfo.name = "int"
@ -33,6 +38,11 @@ func init() {
strInfo.parser = parseString strInfo.parser = parseString
hexInfo.parser = parseHex hexInfo.parser = parseHex
hexInfo16.parser = parseHex16
hexInfo32.parser = parseHex32
hexInfo64.parser = parseHex64
hexInfo128.parser = parseHex128
boolInfo.parser = parseBool boolInfo.parser = parseBool
tInfo[TypeInt] = intInfo tInfo[TypeInt] = intInfo
@ -41,5 +51,11 @@ func init() {
tInfo[TypeString] = strInfo tInfo[TypeString] = strInfo
tInfo[TypeDirectory] = dirInfo tInfo[TypeDirectory] = dirInfo
tInfo[TypeHex] = hexInfo tInfo[TypeHex] = hexInfo
tInfo[TypeHex16] = hexInfo16
tInfo[TypeHex32] = hexInfo32
tInfo[TypeHex64] = hexInfo64
tInfo[TypeHex128] = hexInfo128
tInfo[TypeBool] = boolInfo tInfo[TypeBool] = boolInfo
} }