From 18a9253a5fd13205b04beed8e8ca009547b12c1f Mon Sep 17 00:00:00 2001 From: Kenny Grant Date: Thu, 19 Oct 2017 22:34:42 +0100 Subject: blog: Fix Decoding arbitrary data example The example on the blog post json-and-go describes decoding arbitrary data, but instead of switching on the default concrete type for numbers - float64, it looks for int, making it print: is of a type I don't know how to handle. This change looks for float64 instead of int. Change-Id: I86825003893216dd52212d7f75239ec57770a83b Reviewed-on: https://go-review.googlesource.com/71930 Reviewed-by: Ian Lance Taylor --- content/json-and-go.article | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'content/json-and-go.article') diff --git a/content/json-and-go.article b/content/json-and-go.article index 4a1ae36..4a9f55a 100644 --- a/content/json-and-go.article +++ b/content/json-and-go.article @@ -163,8 +163,8 @@ We can then iterate through the map with a range statement and use a type switch switch vv := v.(type) { case string: fmt.Println(k, "is string", vv) - case int: - fmt.Println(k, "is int", vv) + case float64: + fmt.Println(k, "is float64", vv) case []interface{}: fmt.Println(k, "is an array:") for i, u := range vv { -- cgit v1.2.3