1

I'm trying to generate the documentation for my packages in Golang. Ultimately I want to generate the documentation as part of CI/CD and host it inside our network. I know about godoc and using the instructions here I tried exactly as it states, in my package directory, however all I get is the full documentation for go itself, but not custom packages.

If I go to :6060/src, I can see a list of the contents of the src directory, and within that, I can see enter image description here However when I click on it, I get the response enter image description here

I don't know if that's why I cant see my packages in the documentation, it would seem odd as $GOPATH is set to Users/me/go.

But if that's not related, how can I generate the static html files for specific packages such as my own? It seems much harder to google an answer for this that I expected. I know other tools use doxygen, but godoc doesn't seem equivalent in any way

amlwwalker
  • 3,161
  • 4
  • 26
  • 47
  • "godoc doesn't seem equivalent in any way" true. It is a live documentation server. It is how documentation is served for Go libraries. Is there a particular reason you want to produce static HTML instead of using the language's standard mechanism? – Adrian Mar 25 '20 at 14:26
  • I don't want someone to have to have access to the source code, I want them to be able to get access to the documentation. For instance host it as a static site somewhere. What is the standard mechanism, i.e what is the private equivalent of godoc.org etc? How can I host my packages documentation privately? – amlwwalker Mar 25 '20 at 15:20
  • Using `godoc` *is* the standard method, it hosts your documentation privately. What would be the value of the documentation for someone who does not have access to the source code? Why would anyone need documentation for a library they can't use? – Adrian Mar 25 '20 at 16:34
  • ok, so the scenario is the tech lead wants everyone to be able to see docs for our projects. Maybe I can rephrase - how do I host the documentation for a private (gitlab) repository so that anyone on the team can see it without cloning the code - they can see the code in gitlab. For ease I want to be able to give a link in the readme to the docs. Where/how do I host it? I guess the obvious answer is to clone the code to a docker container, run godoc and people can connect, but I would much prefer just a static site that is generated as part of CICD. godoc is just showing me Go itselfs docs – amlwwalker Mar 25 '20 at 17:34
  • "godoc is just showing me Go itselfs docs" - are you using it according to what `godoc --help` says, i.e., passing it the package name you want it to serve docs for? – Adrian Mar 25 '20 at 18:09
  • yes i can do that, but thats all very manual - i cant seem to get any help on hosting the docs for my own packages myself. Can you help with this? – amlwwalker Mar 25 '20 at 22:08
  • `godoc` will serve docs for your packages. That is the official solution. – Adrian Mar 26 '20 at 13:34

0 Answers0