add directory type
This commit is contained in:
		@@ -7,6 +7,7 @@ const (
 | 
			
		||||
    TypeInt DataType = iota
 | 
			
		||||
    TypeDuration DataType = iota
 | 
			
		||||
    TypeString DataType = iota
 | 
			
		||||
    TypeDirectory DataType = iota
 | 
			
		||||
    TypeBool DataType = iota
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,9 @@ func (c *Config) GetInt(key string)(int64) {
 | 
			
		||||
    }
 | 
			
		||||
    return 0
 | 
			
		||||
}
 | 
			
		||||
func (c *Config) GetDirectory(key string)(string) {
 | 
			
		||||
    return c.GetString(key)
 | 
			
		||||
}
 | 
			
		||||
func (c *Config) GetString(key string)(string) {
 | 
			
		||||
    if c.parsed {
 | 
			
		||||
        upper := strings.ToUpper(key)
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package envconf
 | 
			
		||||
import ("strconv"
 | 
			
		||||
        "fmt"
 | 
			
		||||
        "errors"
 | 
			
		||||
        "strings"
 | 
			
		||||
        "time")
 | 
			
		||||
 | 
			
		||||
func parseInt(key string, str string)(ret cValue) {
 | 
			
		||||
@@ -41,3 +42,8 @@ func parseString(_ string, str string)(ret cValue) {
 | 
			
		||||
    ret.strval = str
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseDirectory(_ string, str string)(ret cValue) {
 | 
			
		||||
    ret.strval = strings.TrimRight(str, "/")
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,20 +9,24 @@ func init() {
 | 
			
		||||
    var intInfo dataTypeInfo
 | 
			
		||||
    var durInfo dataTypeInfo
 | 
			
		||||
    var strInfo dataTypeInfo
 | 
			
		||||
    var dirInfo dataTypeInfo
 | 
			
		||||
    var boolInfo dataTypeInfo
 | 
			
		||||
 | 
			
		||||
    intInfo.name = "int"
 | 
			
		||||
    durInfo.name = "duration"
 | 
			
		||||
    dirInfo.name = "directory"
 | 
			
		||||
    strInfo.name = "string"
 | 
			
		||||
    boolInfo.name = "bool"
 | 
			
		||||
 | 
			
		||||
    intInfo.parser = parseInt
 | 
			
		||||
    durInfo.parser = parseDuration
 | 
			
		||||
    dirInfo.parser = parseDirectory
 | 
			
		||||
    strInfo.parser = parseString
 | 
			
		||||
    boolInfo.parser = parseBool
 | 
			
		||||
 | 
			
		||||
    tInfo[TypeInt] = intInfo
 | 
			
		||||
    tInfo[TypeDuration] = durInfo
 | 
			
		||||
    tInfo[TypeString] = strInfo
 | 
			
		||||
    tInfo[TypeDirectory] = dirInfo
 | 
			
		||||
    tInfo[TypeBool] = boolInfo
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user