Comments for humans always have a single space after the slashes #7

Opendmitshur opened this issue 7 years ago
dmitshur commented 7 years ago · edited

Do this:

// This is a comment
// for humans.

Don't do this:

//This is a comment
//for humans.

For consistency, and because the no space style is reserved for comment pragmas, for example:

//go:generate go run gen.go

Temporarily commented out code should also have no spaces, but it's not meant to be committed.


Write Preview Markdown
tongohiti commented 6 years ago

because the no space style is reserved for comment pragmas

Obviously this isn't quite true. Counter-example is // +build ... stuff where there is a space between '//' and '+'.

Write Preview Markdown
dmitshur commented 6 years ago · edited

Yes, // +build is an exception that comes from pre-1.0 times. It doesn't invalidate the point made here. The main reason for this entry is consistency with existing code.

There was a proposal to rename // +build to //go:build, which is likely what it would've been if it were created after the //go: compiler directive convention was established. The proposal was rejected because the change would incur too much churn without enough benefits to justify it.

Write Preview Markdown
to comment.