Open lukescott opened 11 years ago
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.
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.
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.
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
Is there any 3rd party library to generate godoc for main package? I really need it.
rename the package from main
to somethingelse
. Rename method main
to Main
. Create a main package that calls somethingelse.Main