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/doc: doc.Examples can mark examples as un-playable due to unresolved _ identifiers #26447

Closed
mostynb opened this issue Jul 18, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mostynb
Copy link
Contributor

mostynb commented Jul 18, 2018

What version of Go are you using (go version)?

Tip of master (or thereabouts): 311ec41

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mostyn/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mostyn/go"
GOPROXY=""
GORACE=""
GOROOT="/home/mostyn/code/go"
GOTMPDIR=""
GOTOOLDIR="/home/mostyn/code/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build568816912=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This example is not runnable in the playground, but if I copy+paste the code into https://play.golang.org/ then it runs just fine:
https://golang.org/pkg/bufio/#example_Scanner_custom

I tracked this down to the "_, err = strconv.ParseInt(string(token), 10, 32)" line in the if block inside the split function, if I change = to := in that line and then return the values explicitly, then the example becomes runnable in godoc.

Digging a little deeper, doc.playExample considers the example unrunnable because the blank identifier on that line is unresolved. But that's the whole point of blank identifiers- they're not supposed to be resolved. So I think blank identifiers should not be added to the unresolved map.

What did you expect to see?

The example should be runnable in the playground box in godoc.

What did you see instead?

The example was not runnable.

mostynb added a commit to mostynb/go that referenced this issue Jul 18, 2018
https://golang.org/pkg/bufio/#example_Scanner_custom is not directly
runnable in the playground via godoc, but if I copy+paste the code into
https://play.golang.org/ then it runs just fine.

This seems to be due to the blank identifier in the following line in
the example:

"_, err = strconv.ParseInt(string(token), 10, 32)"

But that's the whole point of blank identifiers- they're not supposed
to be resolved.  So let's skip adding the blank identifier to
doc.playExample's unresolved map.

Resolves golang#26447

Change-Id: I52bc7d99be1d14a61dc012d10c18349d52ba4c51
@gopherbot
Copy link

Change https://golang.org/cl/124775 mentions this issue: doc.Example should not worry about unresolved blank identifiers

@FiloSottile FiloSottile changed the title doc.Examples can mark examples as un-playable due to unresolved _ identifiers go/doc: doc.Examples can mark examples as un-playable due to unresolved _ identifiers Jul 19, 2018
@FiloSottile FiloSottile added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 19, 2018
@FiloSottile FiloSottile added this to the Go1.11 milestone Jul 19, 2018
@golang golang locked and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants