abs filepath
This commit is contained in:
		
							
								
								
									
										16
									
								
								parsers.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								parsers.go
									
									
									
									
									
								
							@@ -2,7 +2,7 @@ package envconf
 | 
			
		||||
import ("strconv"
 | 
			
		||||
        "fmt"
 | 
			
		||||
        "errors"
 | 
			
		||||
        "strings"
 | 
			
		||||
        "path/filepath"
 | 
			
		||||
        "time")
 | 
			
		||||
 | 
			
		||||
func parseInt(key string, str string)(ret cValue) {
 | 
			
		||||
@@ -35,12 +35,18 @@ func parseBool(key string, str string)(ret cValue) {
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseDirectory(key string, str string)(ret cValue) {
 | 
			
		||||
    val, err := filepath.Abs(str)
 | 
			
		||||
    if err == nil {
 | 
			
		||||
        ret.strval = val
 | 
			
		||||
    } else {
 | 
			
		||||
        ret.err = errors.New(fmt.Sprintf(`Environment variable "%s" is not of type directory.`, key))
 | 
			
		||||
    }
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseString(_ string, str string)(ret cValue) {
 | 
			
		||||
    ret.strval = str
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseDirectory(_ string, str string)(ret cValue) {
 | 
			
		||||
    ret.strval = strings.TrimRight(str, "/")
 | 
			
		||||
    return
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user