What version of Go are you using (go version)?
$ go version
go version go1.14rc1 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="on"
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/manlio/sdk/go1.14rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/manlio/sdk/go1.14rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build423783759=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.14rc1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.14rc1
uname -sr: Linux 5.5.2-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.31.
gdb --version: GNU gdb (GDB) 8.3.1
What did you do?
https://play.golang.org/p/SZZ4gDss0DK
What did you expect to see?
The program to be compiled.
What did you see instead?
/prog.go:13:1: missing return at end of function
The Go compiler does not know that runtime.Goexit causes the function to exit, so the return statement is unreachable and not required.
Of course there are similar functions like os.Exit, but Goexit is part of the runtime, so it should probably be recognized by the compiler.
On the other hand, vet should know about runtime.Goexit and should report that the statements after Goexit() are not reachable.
The compile or vet commands should also report an error if a function used in the go statement has a non empty result in the signature, but this is a different issue and probably there is a reason why it does not report an error.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
https://play.golang.org/p/SZZ4gDss0DK
What did you expect to see?
The program to be compiled.
What did you see instead?
The Go compiler does not know that
runtime.Goexitcauses the function to exit, so thereturnstatement is unreachable and not required.Of course there are similar functions like
os.Exit, butGoexitis part of the runtime, so it should probably be recognized by the compiler.On the other hand,
vetshould know aboutruntime.Goexitand should report that the statements afterGoexit()are not reachable.The
compileorvetcommands should also report an error if a function used in thegostatement has a non empty result in the signature, but this is a different issue and probably there is a reason why it does not report an error.