-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: method Seek() should have signature Seek(int64, int) #36970
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
Comments
Do Read and Write have the correct signatures? Please include a full example, not a snippet. The error as shown here is correct: the standard Seek method takes two arguments. |
no, Read and Write are different, I only get an error for seek https://play.golang.org/p/zbCVv7Y8TlE I just tried it without any reference to io and got the same error: |
Seek is one of the canonical methods that go vet checks, while Read and Write are not: https://github.com/golang/tools/blob/master/go/analysis/passes/stdmethods/stdmethods.go#L74 If you add a "whence int" parameter to your Seek method and change the type of the first return value from io.Reader to int64 vet will be silent: https://play.golang.org/p/7Pbq67pGGl- |
Or just change the name of the function. |
I agree that this seems like a correct vet diagnostic. The io.Seeker interface is defined by itself, so it doesn't matter what other methods your named type has defined. |
Facing similar issue at my end while testing prometheus as shown below. github.com/prometheus/prometheus/storage./buffer.go:80:34: method Seek(t int64) bool should have signature Seek(int64, int) (int64, error) |
@sachinkakatkar Does renaming the method or changing the signature to conform to io.Seeker work for you? |
I don't think they are necessarily wrong enough for it to be a vet check. https://github.com/search?q=language%3AGo%20%2Ffunc%20%5C(.*%5C)%20Seek%5C(%5C)%20%5C%7B%24%2F&type=code |
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 env
OutputWhat did you do?
go vet
What did you expect to see?
no error
I do have the package "io" included, but I do also have a Read and Write method which go vet does not complain about
What did you see instead?
./file.go:286:19: method Seek(offset int64) (io.Reader, error) should have signature Seek(int64, int) (int64, error)
The text was updated successfully, but these errors were encountered: