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

x/tools/cmd/godoc: add -tags like go build #3398

Open
ugorji opened this Issue Mar 26, 2012 · 16 comments

Comments

Projects
None yet
7 participants
@ugorji
Contributor

ugorji commented Mar 26, 2012

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull", "hg update default", rebuild, and
retry
what you did to reproduce the problem.  Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Run godoc on a package having some files with build constraints e.g. // +build ignore
2. The files are skipped by godoc and their contents are not reflected in godoc output.
I don't see the files listed either.
3.

What is the expected output?

I expected to see the information in godoc.

What do you see instead?
Nothing.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux

Which version are you using?  (run 'go version')
Running at tip, but go version gives:
go version weekly.2012-03-22 +de7e784537ac

Please provide any additional information below.
@rsc

This comment has been minimized.

Contributor

rsc commented Mar 26, 2012

Comment 1:

godoc ignores files that say "// +build ignore".
It uses the files that would be built by go build.
That seems like it is working as intended.
Maybe after Go 1 we could give godoc a flag to
allow the specification of additional build tags,
like go build's -tags.
Russ

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@ugorji

This comment has been minimized.

Contributor

ugorji commented Mar 27, 2012

Comment 2:

That would be nice.
I stumbled upon this because I tagged some of my code which should only run on an
appengine instance with // +build appengine. After that, I couldn't see them anymore
using godoc. My only solution seemed to be to remove the build constraints.
@rsc

This comment has been minimized.

Contributor

rsc commented Sep 12, 2012

Comment 3:

Labels changed: added go1.1maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 10, 2012

Comment 4:

Labels changed: added size-m.

@rsc

This comment has been minimized.

Contributor

rsc commented Mar 12, 2013

Comment 5:

[The time for maybe has passed.]

Labels changed: removed go1.1maybe.

@adg

This comment has been minimized.

Contributor

adg commented Mar 18, 2013

Comment 6:

Labels changed: added godoc.

@rsc

This comment has been minimized.

Contributor

rsc commented Jul 30, 2013

Comment 7:

Labels changed: added go1.2.

@rsc

This comment has been minimized.

Contributor

rsc commented Jul 30, 2013

Comment 8:

Labels changed: added feature.

@robpike

This comment has been minimized.

Contributor

robpike commented Aug 21, 2013

Comment 9:

This would be nice, but it won't happen for Go 1.2.

Labels changed: removed go1.2.

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2013

Comment 10:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2013

Comment 11:

Labels changed: removed feature.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 12:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 13:

Labels changed: added repo-tools.

@ugorji ugorji added accepted labels Dec 4, 2013

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc changed the title from cmd/godoc: add -tags like go build to x/tools/cmd/godoc: add -tags like go build Apr 14, 2015

@rsc rsc removed the repo-tools label Apr 14, 2015

@jeffallen

This comment has been minimized.

Contributor

jeffallen commented Dec 11, 2017

If you are someone like me who just stumbled across this old bug and are looking for a quick hack to solve your problem right now, use "go get golang.org/x/tools" to get the godoc source code then hack it like this:

diff --git a/godoc/server.go b/godoc/server.go
index 3b452e5e..d231425e 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -64,6 +64,7 @@ func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode,
 	// Note: If goos/goarch aren't set, the current binary's GOOS/GOARCH
 	// are used.
 	ctxt := build.Default
+	ctxt.BuildTags = []string{"vartime"}
 	ctxt.IsAbsPath = pathpkg.IsAbs
 	ctxt.IsDir = func(path string) bool {
 		fi, err := h.c.fs.Stat(filepath.ToSlash(path))

Then use "go build" to build a local copy of godoc that is using the build tags you need.

@gopherbot

This comment has been minimized.

gopherbot commented Aug 12, 2018

Change https://golang.org/cl/129099 mentions this issue: x/tools/cmd/godoc: add -tags like go build

@SchumacherFM

This comment has been minimized.

Contributor

SchumacherFM commented Aug 12, 2018

Good evening,

as I currently need this feature in godoc to display documentation for specific build tags, I've added it to godoc. It took me a couple of days and I think it is ready for review 😊.
See the CL https://golang.org/cl/129099

Below I've added some printscreens how the design looks like for HTML and CLI.
If there are better ideas to display the build tag information, let me know.

It would be great if some one from the Go Team, etc can review the code.

screen shot 2018-08-12 at 7 43 40 pm

screen shot 2018-08-12 at 7 45 09 pm

screen shot 2018-08-12 at 7 45 41 pm

screen shot 2018-08-12 at 7 46 01 pm

screen shot 2018-08-12 at 7 47 45 pm

screen shot 2018-08-12 at 7 48 29 pm

screen shot 2018-08-12 at 7 50 54 pm

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Aug 12, 2018

godoc, cmd/godoc: add -tags flag like go build
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Aug 27, 2018

godoc, cmd/godoc: add -tags flag like go build
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Sep 6, 2018

godoc, cmd/godoc: add -tags flag like go build
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Oct 14, 2018

godoc, cmd/godoc: add -tags flag like go build
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2

SchumacherFM added a commit to SchumacherFM/tools that referenced this issue Nov 6, 2018

godoc, cmd/godoc: add -tags flag like go build
The specified build tags in the -tags flag for the godoc command
parses additional Go source files. All identifiers are getting listed
alongside with the information from which build tag they originate.

Fixes golang/go#3398

Change-Id: Ifcb716303d7c77ff5348156115197ea9b06c9dc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment