Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: error printing math.Uint64 #49000

Closed
bmizerany opened this issue Oct 15, 2021 · 1 comment
Closed

fmt: error printing math.Uint64 #49000

bmizerany opened this issue Oct 15, 2021 · 1 comment

Comments

@bmizerany
Copy link
Contributor

bmizerany commented Oct 15, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bmizerany/Library/Caches/go-build"
GOENV="/Users/bmizerany/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/bmizerany/go/pkg/mod"
GONOPROXY="github.com/bmizerany"
GONOSUMDB="github.com/bmizerany"
GOOS="darwin"
GOPATH="/Users/bmizerany/go"
GOPRIVATE="github.com/bmizerany"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rf/6fdgwbmj2rxf1jw13q4fv7h80000gn/T/go-build613577533=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.17 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.17
uname -v: Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101
ProductName:	macOS
ProductVersion:	11.5.2
BuildVersion:	20G95
lldb --version: lldb-1205.0.28.2
Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)

What did you do?

Attempted to print math.MaxUint64 with fmt.Println

See: https://play.golang.org/p/N4Aj1AsylRp

I see the same locally on my M1:

/tmp % cat x.go 
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: x.go
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ package main
   2   │ 
   3   │ import (
   4   │     "fmt"
   5   │     "math"
   6   │ )
   7   │ 
   8   │ func main() {
   9   │     x := uint64(math.MaxUint64)
  10   │     fmt.Println(x)
  11   │ 
  12   │     fmt.Println(math.MaxUint64)
  13   │ }
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
/tmp % go run x.go 
# command-line-arguments
./x.go:12:13: constant 18446744073709551615 overflows int

What did you expect to see?

The maximum value of an uint64 without an error.

What did you see instead?

This error: ./prog.go:12:13: constant 18446744073709551615 overflows int

@bmizerany bmizerany changed the title fmt: compile error printing math.Uint64 fmt: error printing math.Uint64 Oct 15, 2021
@bmizerany
Copy link
Contributor Author

bmizerany commented Oct 15, 2021

Nevermind. I see the error in my ways: Println doesn't instinctively convert the number to a uint64. Please ignore.

@golang golang locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants