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

go/ast: InterfaceType.Methods comment is incomplete #22415

Closed
willfaught opened this issue Oct 24, 2017 · 2 comments
Closed

go/ast: InterfaceType.Methods comment is incomplete #22415

willfaught opened this issue Oct 24, 2017 · 2 comments

Comments

@willfaught
Copy link
Contributor

@willfaught willfaught commented Oct 24, 2017

What did you do?

$ go doc go/ast InterfaceType.Methods

What did you expect to see?

It doesn't explain what type to expect in Methods.List[x].Type, or that Methods.List[x].Names can be empty (for embedded interfaces).

What did you see instead?

type InterfaceType struct {
    Methods *FieldList  // list of methods

    // ... other fields elided ...
}

System details

go version go1.9.1 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/willfaught/Developer/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_1/ggvd2t1x7hz_185crsb36zlr0000gp/T/go-build074149053=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version go1.9.1 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.9.1
uname -v: Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29
lldb --version: lldb-900.0.50.1
  Swift-4.0
@griesemer
Copy link
Contributor

@griesemer griesemer commented Oct 24, 2017

An ast.FieldList element is of type ast.Field which explains that a type can be a method type (the obvious case here). It also explains that Names can be nil for anonymous fields (which is the equivalent of embedded types.

The go/ast documentation is deliberately sparse so that the "forest" (the overall ast package) can be seen despite all the "trees". It's not meant as a tutorial.

What do you suggest?

@willfaught
Copy link
Contributor Author

@willfaught willfaught commented Oct 25, 2017

Shoot, I missed those Field comments! You're absolutely right. It's clear enough. Thanks for pointing that out. Sorry.

@willfaught willfaught closed this Oct 25, 2017
@golang golang locked and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.