You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
Resolvesgolang#26447
Change-Id: I52bc7d99be1d14a61dc012d10c18349d52ba4c51
Change https://golang.org/cl/124775 mentions this issue: doc.Example should not worry about unresolved blank identifiers
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
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.
The text was updated successfully, but these errors were encountered: