What steps are needed to document `package main` in Godoc?

后端 未结 2 1194
悲&欢浪女
悲&欢浪女 2021-02-02 17:59

Godoc is a great tool for documenting packages, however it seems to be less useful when it\'s used against package main. I\'ll see an output that only displays the

2条回答
  •  渐次进展
    2021-02-02 18:03

    AFAIK, you already have the answer to your question. I can think of two alternative solutions:

    1. Maintain a fork of godoc that shows functions for main packages. (And you'd then have to run an instance of it yourself on a web server. The downside is that people going straight to godoc.org for your package documentation will miss out.)
    2. Separate your main packages into sub-packages such that the main package is small or minimal. Documentation could then be read in those sub-packages. But as far as I know, this is not in widespread practice.

    I think in general, godoc is for package documentation. Documentation for main packages is really only useful to people editing the source code of that package---so the documentation conceivably doesn't need to be publicized. On the other hand, this lacks the nice presentation/organization of godoc.

    As a compromise, if you really want to publicize the documentation, I'd recommend an overview of the architecture of your program rather than a play-by-play of each function.

提交回复
热议问题