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

doc: doc/articles/wiki clarification #25188

Open
wfc-sfmjp opened this issue Apr 30, 2018 · 5 comments · May be fixed by #28726

Comments

@wfc-sfmjp
Copy link

commented Apr 30, 2018

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

go version go1.10.1 windows/amd64

Does this issue reproduce with the latest release?

N/A

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

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\sfmjp.WFC\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\sfmjp.WFC\go
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\sfmjp.WFC\AppData\Local\Temp\go-build919863594=/tmp/go-build -gno-record-gcc-switches

What did you do?

Following the wiki docs, I ran into an issue when getting to the following section: Using net/http to serve wiki pages.

The code sample explicitly says to add "net/http" to the import statement. It doesn't state to add "log", though it's also necessary. So when following along, a user will get a compilation error saying that log doesn't exist. It isn't until the user navigates to the "code so far" link does it show the need to add the import statement for log.

What did you expect to see?

I would expect the documentation to reflect the need to import both net/http and log at this point. If you're experienced in Go, then it may be obvious that you need to add an import statement for log. As a newer Gopher, this caused a situation where it's not entirely obvious that it was necessary to add until I looked at the code so far link.

@FiloSottile FiloSottile changed the title doc/articles/wiki clarification doc: doc/articles/wiki clarification Apr 30, 2018

@FiloSottile FiloSottile added this to the Unplanned milestone Apr 30, 2018

@FiloSottile

This comment has been minimized.

Copy link
Member

commented Apr 30, 2018

Thanks for reporting this.

Would adding

We need to also import the log package to use log.Fatal.

at the end of this paragraph

To use this handler, we rewrite our main function to initialize http using the viewHandler to handle any requests under the path /view/.

be a good fix in your opinion?

@wfc-sfmjp

This comment has been minimized.

Copy link
Author

commented Apr 30, 2018

That would be super helpful! As I went further through the article(I've completed it now!), I would also update the remaining snippets that include the import statement to reflect the addition of the log like so:

import (
	"html/template"
	"io/ioutil"
	"log"
	"net/http"
)

In the future, are pull requests accepted for documentation changes?

@FiloSottile

This comment has been minimized.

Copy link
Member

commented Apr 30, 2018

We do gladly accept PRs! If you are looking for a new task now that you completed the article, please feel free to submit a PR applying the changes you and I suggested here.

https://github.com/golang/go/tree/master/doc/articles/wiki

You might want to read http://golang.org/wiki/CommitMessage first.

@agnivade agnivade added the help wanted label May 1, 2018

@dupoxy

This comment has been minimized.

Copy link
Contributor

commented May 2, 2018

Maybe PR #24584 is related.

0leynikov added a commit to 0leynikov/go that referenced this issue Nov 11, 2018
go/doc: add missing log package imports
The second part of the tutorial did not contain an import of the "log"
package:
https://golang.org/doc/articles/wiki/#tmp_4
Anyone following this part step by step would get an error.

Fixes golang#25188
@0leynikov 0leynikov referenced a pull request that will close this issue Nov 11, 2018
@gopherbot

This comment has been minimized.

Copy link

commented Nov 11, 2018

Change https://golang.org/cl/148830 mentions this issue: go/doc: add missing log package imports

0leynikov added a commit to 0leynikov/go that referenced this issue Sep 15, 2019
doc: add missing import of the log package
https://golang.org/doc/articles/wiki/#tmp_4
Anyone following this part step by step would get an "undefined: log"
error.

Fixes golang#25188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.