84 lines
2.1 KiB
Go
84 lines
2.1 KiB
Go
package envvars
|
|
|
|
import "time"
|
|
|
|
func String(key, defaultValue string) string {
|
|
return Object(key, defaultValue, ConvertString)
|
|
}
|
|
|
|
func Byte(key string, defaultValue byte) byte {
|
|
return Uint8(key, defaultValue)
|
|
}
|
|
|
|
func Rune(key string, defaultValue rune) rune {
|
|
return Object(key, defaultValue, ConvertRune)
|
|
}
|
|
|
|
func Int64(key string, defaultValue int64) int64 {
|
|
return Object(key, defaultValue, ConvertInt64)
|
|
}
|
|
|
|
func Int32(key string, defaultValue int32) int32 {
|
|
return Object(key, defaultValue, ConvertInt32)
|
|
}
|
|
|
|
func Int16(key string, defaultValue int16) int16 {
|
|
return Object(key, defaultValue, ConvertInt16)
|
|
}
|
|
|
|
func Int8(key string, defaultValue int8) int8 {
|
|
return Object(key, defaultValue, ConvertInt8)
|
|
}
|
|
|
|
func Int(key string, defaultValue int) int {
|
|
return Object(key, defaultValue, ConvertInt)
|
|
}
|
|
|
|
func Uint64(key string, defaultValue uint64) uint64 {
|
|
return Object(key, defaultValue, ConvertUint64)
|
|
}
|
|
|
|
func Uint32(key string, defaultValue uint32) uint32 {
|
|
return Object(key, defaultValue, ConvertUint32)
|
|
}
|
|
|
|
func Uint16(key string, defaultValue uint16) uint16 {
|
|
return Object(key, defaultValue, ConvertUint16)
|
|
}
|
|
|
|
func Uint8(key string, defaultValue uint8) uint8 {
|
|
return Object(key, defaultValue, ConvertUint8)
|
|
}
|
|
|
|
func Uint(key string, defaultValue uint) uint {
|
|
return Object(key, defaultValue, ConvertUint)
|
|
}
|
|
|
|
func Float64(key string, defaultValue float64) float64 {
|
|
return Object(key, defaultValue, ConvertFloat64)
|
|
}
|
|
|
|
func Float32(key string, defaultValue float32) float32 {
|
|
return Object(key, defaultValue, ConvertFloat32)
|
|
}
|
|
|
|
func Complex128(key string, defaultValue complex128) complex128 {
|
|
return Object(key, defaultValue, ConvertComplex128)
|
|
}
|
|
|
|
func Complex64(key string, defaultValue complex64) complex64 {
|
|
return Object(key, defaultValue, ConvertComplex64)
|
|
}
|
|
|
|
func Bool(key string, defaultValue bool) bool {
|
|
return Object(key, defaultValue, ConvertBool)
|
|
}
|
|
|
|
func Time(key string, defaultValue time.Time, layout string) time.Time {
|
|
return Object(key, defaultValue, func(s string) (time.Time, error) { return time.Parse(layout, s) })
|
|
}
|
|
|
|
func Duration(key string, defaultValue time.Duration) time.Duration {
|
|
return Object(key, defaultValue, time.ParseDuration)
|
|
}
|