What version of Go are you using (go version)?
$ go version
go version go1.18.1 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/fishy/.cache/go-build"
GOENV="/home/fishy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fishy/.gopath/pkg/mod"
GONOPROXY="redacted"
GONOSUMDB="redacted"
GOOS="linux"
GOPATH="/home/fishy/.gopath"
GOPRIVATE="redacted"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/fishy/work/thrift/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2627081732=/tmp/go-build -gno-record-gcc-switches"
What did you do?
In Apache Thrift go library, the interface TProtocol has
ReadByte and WriteByte that's different from the expectation of stdmethods:
type TProtocol interface {
...
WriteByte(ctx context.Context, value int8) error
...
ReadByte(ctx context.Context) (value int8, err error)
...
}
This causes go vet to complain about the implementations, and we have to do extra work to disable stdmethods check for packages containing the implementation, for example: https://github.com/reddit/baseplate.go/blob/205ac6852ad82ad5508106a6cb7156e2e73d3b3a/scripts/linters.sh#L19-L31
IMHO the stdmethods check should auto skip "violations" that explicitly implement a different interface (e.g. this line of var _ thrift.TProtocol = (*tDuplicateToProtocol)(nil) should be enough to silent stdmethods on (*tDuplicateToProtocol).ReadByte and (*tDuplicateToProtocol).WriteByte), as an explicit interface with different function signature should be enough signal that the difference is intentional, otherwise the interface should embed io.ByteReader/io.ByteWriter instead.
What did you expect to see?
What did you see instead?
$ go vet .
# github.com/apache/thrift/lib/go/thrift
./binary_protocol.go:215:27: method WriteByte(ctx context.Context, value int8) error should have signature WriteByte(byte) error
./binary_protocol.go:423:27: method ReadByte(ctx context.Context) (int8, error) should have signature ReadByte() (byte, 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?
In Apache Thrift go library, the interface
TProtocolhasReadByteandWriteBytethat's different from the expectation ofstdmethods:This causes
go vetto complain about the implementations, and we have to do extra work to disablestdmethodscheck for packages containing the implementation, for example: https://github.com/reddit/baseplate.go/blob/205ac6852ad82ad5508106a6cb7156e2e73d3b3a/scripts/linters.sh#L19-L31IMHO the
stdmethodscheck should auto skip "violations" that explicitly implement a different interface (e.g. this line ofvar _ thrift.TProtocol = (*tDuplicateToProtocol)(nil)should be enough to silentstdmethodson(*tDuplicateToProtocol).ReadByteand(*tDuplicateToProtocol).WriteByte), as an explicit interface with different function signature should be enough signal that the difference is intentional, otherwise the interface should embedio.ByteReader/io.ByteWriterinstead.What did you expect to see?
What did you see instead?