mirror of https://github.com/spf13/viper.git
Add GetInt32
This commit is contained in:
parent
8dc2790b02
commit
15738813a0
6
viper.go
6
viper.go
|
@ -682,6 +682,12 @@ func (v *Viper) GetInt(key string) int {
|
|||
return cast.ToInt(v.Get(key))
|
||||
}
|
||||
|
||||
// GetInt32 returns the value associated with the key as an integer.
|
||||
func GetInt32(key string) int32 { return v.GetInt32(key) }
|
||||
func (v *Viper) GetInt32(key string) int32 {
|
||||
return cast.ToInt32(v.Get(key))
|
||||
}
|
||||
|
||||
// GetInt64 returns the value associated with the key as an integer.
|
||||
func GetInt64(key string) int64 { return v.GetInt64(key) }
|
||||
func (v *Viper) GetInt64(key string) int64 {
|
||||
|
|
|
@ -1068,6 +1068,10 @@ func TestMergeConfig(t *testing.T) {
|
|||
t.Fatalf("lagrenum != 765432101234567, = %d", pop)
|
||||
}
|
||||
|
||||
if pop := v.GetInt32("hello.pop"); pop != int32(37890) {
|
||||
t.Fatalf("pop != 37890, = %d", pop)
|
||||
}
|
||||
|
||||
if pop := v.GetInt64("hello.lagrenum"); pop != int64(765432101234567) {
|
||||
t.Fatalf("int64 lagrenum != 765432101234567, = %d", pop)
|
||||
}
|
||||
|
@ -1092,6 +1096,10 @@ func TestMergeConfig(t *testing.T) {
|
|||
t.Fatalf("lagrenum != 7654321001234567, = %d", pop)
|
||||
}
|
||||
|
||||
if pop := v.GetInt32("hello.pop"); pop != int32(45000) {
|
||||
t.Fatalf("pop != 45000, = %d", pop)
|
||||
}
|
||||
|
||||
if pop := v.GetInt64("hello.lagrenum"); pop != int64(7654321001234567) {
|
||||
t.Fatalf("int64 lagrenum != 7654321001234567, = %d", pop)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue