Skip to content
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

cmd/vet: remove Peek from methods check #19719

Closed
josharian opened this issue Mar 26, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@josharian
Copy link
Contributor

commented Mar 26, 2017

vet's methods check ensures that methods with a canonical name have the right signature. This includes:

	"Peek":          {[]string{"=int"}, []string{"[]byte", "error"}},                   // image.reader (matching bufio.Reader)

But it's not clear to me why the unexported image.reader interface is important enough to set the canonical interpretation of Peek.

I see three Peeks in the standard library:

// bufio
func (b *Reader) Peek(n int) ([]byte, error)

// cmd/internal/obj
func (a *AsmBuf) Peek(i int) byte

// text/scanner
func (s *Scanner) Peek() rune

Of these, only bufio.Reader matches. Another Peek that comes to mind is from Russ's article Off to the Races:

// Peek reads and returns the word at address addr.
func (m *Mem) Peek(addr uintptr) uintptr

I think we should remove Peek from the list of canonical method names.

The CL is trivial; this issue is to ask for approval.

@robpike

@bradfitz bradfitz added this to the Go1.9Maybe milestone Mar 26, 2017

@robpike

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2017

Fine with me.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 27, 2017

CL https://golang.org/cl/38722 mentions this issue.

@gopherbot gopherbot closed this in 73912a1 Mar 27, 2017

lparth added a commit to lparth/go that referenced this issue Apr 13, 2017

cmd/vet: remove Peek from list of canonical methods
It is insufficiently canonical;
see the discussion at issue 19719.

Fixes golang#19719

Change-Id: I0559ff3b1b39d7bc4b446d104f36fdf8ce3da50e
Reviewed-on: https://go-review.googlesource.com/38722
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>

@golang golang locked and limited conversation to collaborators Mar 27, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.