From 0ac2068de99fd349edc4954d0e9b4a600d75da44 Mon Sep 17 00:00:00 2001
From: "Dr. Tobias Quathamer" <toddy15@users.noreply.github.com>
Date: Sat, 1 Sep 2018 22:59:01 +0200
Subject: [PATCH] Fix overflow error on 32 bit architectures (#340)

* Handle int64 separately for 32 bit architectures

* Remove tests which result in an overflow error on 32 bit architectures
---
 viper.go      | 4 +++-
 viper_test.go | 8 --------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/viper.go b/viper.go
index cfa1241..051a3ef 100644
--- a/viper.go
+++ b/viper.go
@@ -648,8 +648,10 @@ func (v *Viper) Get(key string) interface{} {
 			return cast.ToBool(val)
 		case string:
 			return cast.ToString(val)
-		case int64, int32, int16, int8, int:
+		case int32, int16, int8, int:
 			return cast.ToInt(val)
+		case int64:
+			return cast.ToInt64(val)
 		case float64, float32:
 			return cast.ToFloat64(val)
 		case time.Time:
diff --git a/viper_test.go b/viper_test.go
index be11f3e..15966e4 100644
--- a/viper_test.go
+++ b/viper_test.go
@@ -1102,10 +1102,6 @@ func TestMergeConfig(t *testing.T) {
 		t.Fatalf("pop != 37890, = %d", pop)
 	}
 
-	if pop := v.GetInt("hello.lagrenum"); pop != 765432101234567 {
-		t.Fatalf("lagrenum != 765432101234567, = %d", pop)
-	}
-
 	if pop := v.GetInt32("hello.pop"); pop != int32(37890) {
 		t.Fatalf("pop != 37890, = %d", pop)
 	}
@@ -1130,10 +1126,6 @@ func TestMergeConfig(t *testing.T) {
 		t.Fatalf("pop != 45000, = %d", pop)
 	}
 
-	if pop := v.GetInt("hello.lagrenum"); pop != 7654321001234567 {
-		t.Fatalf("lagrenum != 7654321001234567, = %d", pop)
-	}
-
 	if pop := v.GetInt32("hello.pop"); pop != int32(45000) {
 		t.Fatalf("pop != 45000, = %d", pop)
 	}