Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.13.10 linux/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="/home/karl/.cache/go-build" GOENV="/home/karl/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/karl/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/karl/tmp/floattest/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build659173498=/tmp/go-build -gno-record-gcc-switches"
What did you do?
go.mod:
module floattest
go 1.11
main.go:
package floattest
func returnFloat(v float64) float64 {
return v
}
main_1_13_test.go:
// +build go1.13
package floattest
import (
"testing"
)
func TestStuff(t *testing.T) {
expected := 0x1.5fp20
actual := returnFloat(expected)
if actual != expected {
t.Errorf("Expected %v but got %v\n", expected, actual)
}
}
command: go test
What did you expect to see?
PASS
ok floattest 0.002s
What did you see instead?
# floattest [floattest.test]
./main_1_13_test.go:10:14: hexadecimal floating-point literals requires go1.13 or later (-lang was set to go1.11; check go.mod)
FAIL floattest [build failed]
Since the build settings will not compile this file on go < 1.13, this shouldn't be an error.