Loading dynamictypes/dynamictypes.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package dynamictypes dynamictypes/dynamictypes_test.go 0 → 100644 +25 −0 Original line number Diff line number Diff line package dynamictypes import "testing" func TestDynamicTypes(t *testing.T) { for _, v := range []interface{}{ 42, 3.1415926, "Hello, World!", '€', 3 + 2i, } { //t.Logf("%v", v) switch v.(type) { case int: t.Logf("int: %d", v) case float64: t.Logf("float64: %f", v) case string: t.Logf("string: %q", v) default: t.Logf("%t: %f", v, v) } } } Loading
dynamictypes/dynamictypes.go 0 → 100644 +1 −0 Original line number Diff line number Diff line package dynamictypes
dynamictypes/dynamictypes_test.go 0 → 100644 +25 −0 Original line number Diff line number Diff line package dynamictypes import "testing" func TestDynamicTypes(t *testing.T) { for _, v := range []interface{}{ 42, 3.1415926, "Hello, World!", '€', 3 + 2i, } { //t.Logf("%v", v) switch v.(type) { case int: t.Logf("int: %d", v) case float64: t.Logf("float64: %f", v) case string: t.Logf("string: %q", v) default: t.Logf("%t: %f", v, v) } } }