You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
json.Number supports both the Int64 () and Float64 () interfaces, and I think I should support other types, such as Int () and Int32, though the user himself can use the Int64 interface through conversions.
The text was updated successfully, but these errors were encountered:
bradfitz
changed the title
encoding/json: Add Int() and Int32() interfaces of json.Number
proposal: encoding/json: add Int() and Int32() methods on json.Number
Jan 26, 2018
As you say, you can just write a conversion. It doesn't even take an extra line of code, just a few more characters. Why should we add more methods? And if we add more, why shouldn't we add methods for all the numeric types?
I think we should add methods for all the numeric types. We have it as a number type, so the interface itself should support direct access to its corresponding type value instead of letting the user cast it to the type he needs.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wangguoliang/Documents/mos"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zd/20dl0mb523v4tjk_pf_hdscr0000gn/T/go-build194310903=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
json.Number supports both the Int64 () and Float64 () interfaces, and I think I should support other types, such as Int () and Int32, though the user himself can use the Int64 interface through conversions.
Related PR
cc @bradfitz
What did you expect to see?
encoding/json package.
I want support Built-in interface:
What did you see instead?
The text was updated successfully, but these errors were encountered: