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

package-comments flags main as of 1.2.2 #740

Open
twmb opened this issue Aug 25, 2022 · 6 comments
Open

package-comments flags main as of 1.2.2 #740

twmb opened this issue Aug 25, 2022 · 6 comments

Comments

@twmb
Copy link

twmb commented Aug 25, 2022

This might not be a bug, but I'd like to clarify if this is intentional. It's not common to document main packages, I personally plan to disable the rule if it continues to lint documenting main.

@chavacava
Copy link
Collaborator

Hi @twmb, thanks for filling the issue.

Well, even if documenting main packages might be not so common, the official guideline for documenting GO code says they should be documented:

Every package should have a package comment introducing the package.

and it also provides an example for a main package:

/*
Gofmt formats Go programs.
It uses tabs for indentation and blanks for alignment.
Alignment assumes that an editor is using a fixed-width font.
[...]
When gofmt reads from standard input, [...]
formatted by piping them through gofmt.
*/
package main

As a reference, standard GO tools have documented main packages.

Must revive lint main package documentation? I think it must but I'm open to discuss about.

@hawkingrei
Copy link

We have meet this problem, too. but we are not main package.

pingcap/tidb#37413

https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_build/detail/tidb_ghpr_build/78196/pipeline

util/texttree/texttree.go:15:1: package-comments: should have a package comment (revive)

https://github.com/pingcap/tidb/blob/a80078538d366d55acfc34dd772b1977a720a9bc/util/texttree/texttree.go#L14-L16

@twmb
Copy link
Author

twmb commented Sep 2, 2022

Must revive lint main package documentation?

I'm open to it, but I think it's worth a quick survey of the packages that already use revive to see if they currently document main. I never have -- I document my main packages elsewhere. As well, main packages do not follow the common Package main ..., as seen in the linked post above.

@chavacava
Copy link
Collaborator

We have meet this problem, too. but we are not main package.

util/texttree/texttree.go:15:1: package-comments: should have a package comment (revive)

https://github.com/pingcap/tidb/blob/a80078538d366d55acfc34dd772b1977a720a9bc/util/texttree/texttree.go#L14-L16

Hi @hawkingrei , I've checked the code you point in your comment and I've seen there is no documentation for the texttree package. Thus revive pointing that lack of documentation seems OK to me. Do you agree or I'm missing something?

@chavacava
Copy link
Collaborator

As well, main packages do not follow the common Package main ..., as seen in the linked post above.

Yes, revive takes that into account

@mcandre
Copy link

mcandre commented Oct 4, 2024

A package level API doc for a main package may seem like overkill.

However, projects that provide multiple applications can use the separate docs to explain the purpose of each application.

For example:

// Package main implements a GIF editor application.
package main

Even a Go project with only one application, can still use this API doc to encourage the author to say a few words about the purpose of their application. There are tons of projects, FOSS and enterprise, with zero explanation for their tools are intended to accomplish.

The developer describing a project in the package main API doc, and the README, and the repository slug, enjoys multiple opportunities to attempt to communicate, using different descriptions for each of these snippets. The coder is often so deeply immersed in their project that they forget: The wider world has no idea how to install their widget, how to run it, or what their widget is supposed to do. But each individual attempt at communication raises the odds of successfully gaining an audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants