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

x/tools/cmd/godoc: option to show "exported" declarations of main packages #5727

Open
lukescott opened this issue Jun 17, 2013 · 15 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@lukescott
Copy link

What steps will reproduce the problem?
1. Run godoc -http=:8080
2. Go to http://localhost:8080/pkg/
3. Click on a package that is main

What is the expected output?

Documentation for exported components.

What do you see instead?

A blank page.

Which operating system are you using?

Mac OS X, Linux

Which version are you using?  (run 'go version')

Go1.1 (it worked in Go1.0)

Please provide any additional information below.

Our company uses Go as our primary language, and we have been successfully for a year
now. All we really want is a command-line option in godoc to export main like it used to
do in Go1.

This is for internal reasons. We use it to distinguish finalized verses experimental
functionality in our binaries, much like you would export something in a package to make
it available for use. This was extremely helpful in our company Hackathon - we would
communicate RPC calls to our iPhone developer without verbal communication. We got a lot
done. We've used this day to day, and it has helped a lot. Now we can't do this in Go
1.1.
@robpike
Copy link
Contributor

robpike commented Jun 17, 2013

Comment 1:

Labels changed: added priority-soon, godoc, removed priority-triage.

Owner changed to @griesemer.

@robpike
Copy link
Contributor

robpike commented Jun 17, 2013

Comment 2:

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 3:

A future version of godoc may be significantly refactored/rewritten and simplified,
which is why I'd rather not add an extra flag to godoc which then must be maintained.
But here's a very simple CL that does just that and illustrates how you can customize
godoc for your purposes. Let me know if this is what you are looking for; and if you can
live with your own custom version of godoc.
https://golang.org/cl/10409043

Status changed to WaitingForReply.

@lukescott
Copy link
Author

Comment 4:

Will this future version have this option in some form? Because if that's the case, the
CL will hold us over until then. Otherwise I'd rather not have to maintain a custom
version of godoc forever.
As an idea for the future version: Instead of a flag could be show a hyperlink on the
cmd page that would allow you to view exported things anyway. There is an option to add
m=all to the URL manually to show private things in a package. Would be nice if both
things were linked on the page cmd/package pages.

@adg
Copy link
Contributor

adg commented Jun 19, 2013

Comment 5:

I agree it would be a nice part of the UI. It would also be nice to have the option  to
see unexported declarations, too.

Labels changed: added priority-later, feature, removed priority-soon.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 6:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 7:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 8:

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

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 9:

Labels changed: added repo-tools.

@griesemer
Copy link
Contributor

Comment 10:

Owner changed to bgarcia@golang.org.

@gopherbot
Copy link
Contributor

Comment 11 by bt@brandonthomson.com:

Just had to rebuild my godoc for Go 1.3 and it's a bit more tricky to apply this change
now. First you need to get the go.tools repo because godoc has been moved into there.
Then, search for "info.IsMain = " in go.tools/godoc/server.go. Change that line to:
info.IsMain = false && pkgname == "main"
to change it permanently (or add a flag like the CL above if you really need it). Now to
build the binary you can cd into go.tools/cmd/godoc and do 'go install' or 'go build -o
godoc' or something like that.
Haven't tested it extensively yet but it seems to be working.

@davecheney
Copy link
Contributor

Comment 12:

> to change it permanently (or add a flag like the CL above if you really need it). Now
to build the binary you can cd into go.tools/cmd/godoc and do 'go install' or 'go build
-o godoc' or something like that.
go install code.google.com/p/go.tools/cmd/godoc
will work from any location

@drewwells
Copy link

Instructions for the new location:

edit $GOPATH/src/golang.org/x/tools/godoc/server.go

- info.IsMain = pkgname == "main"
+ info.IsMain = false && pkgname == "main"

go install golang.org/x/tools/cmd/godoc
which -a godoc #make sure godoc built in $GOPATH/bin is the first one

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/godoc: option to show "exported" declarations of main packages x/tools/cmd/godoc: option to show "exported" declarations of main packages Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
@mainali123
Copy link

Is there any 3rd party library to generate godoc for main package? I really need it.

@drewwells
Copy link

drewwells commented Jan 27, 2024

rename the package from main to somethingelse. Rename method main to Main. Create a main package that calls somethingelse.Main

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

10 participants