What version of Go are you using (go version)?
$ go version
go version go1.18 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/vearutop/Library/Caches/go-build"
GOENV="/Users/vearutop/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/vearutop/go/pkg/mod"
GONOPROXY="github.com/adjust,github.com/vearutop,github.com/Unbotify"
GONOSUMDB="github.com/adjust,github.com/vearutop,github.com/Unbotify"
GOOS="darwin"
GOPATH="/Users/vearutop/go"
GOPRIVATE="github.com/adjust,github.com/vearutop,github.com/Unbotify"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/vearutop/sdk/go1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/vearutop/sdk/go1.18/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/vearutop/gohack/github.com/cucumber/godog/go.mod"
GOWORK=""
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/n7/jv2b0zv57jzc8y6zhmfzbn7c0000gn/T/go-build1890007164=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I was getting file and line of struct method.
https://go.dev/play/p/VFs8FKAkTLf
package main
import (
"reflect"
"runtime"
)
type s struct{}
func (tc *s) f() {}
func main() {
tc := &s{}
v := reflect.ValueOf(tc.f)
ptr := v.Pointer()
f := runtime.FuncForPC(ptr)
file, line := f.FileLine(f.Entry())
name := f.Name()
println(file, line, name)
}
What did you expect to see?
.../main.go 10 main.(*s).f-fm
What did you see instead?
<autogenerated> 1 main.(*s).f-fm
The issue is reproducible with go1.18 and gotip, however go1.18rc1 and below (go1.17) works as expected.
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?
I was getting file and line of struct method.
https://go.dev/play/p/VFs8FKAkTLf
What did you expect to see?
What did you see instead?
The issue is reproducible with
go1.18andgotip, howevergo1.18rc1and below (go1.17) works as expected.