v0.11.0
A directive is now exactly Go's directive form, //declscope:name, read by go/ast.ParseDirective. Every other spelling that is addressed to declscope is reported instead of being read.
Important
This release changes which comments are directives. A directive written with a space after //, a space after the colon, or as a block comment used to work. It is now reported and has no effect. See Migrating.
Only //declscope:name is a directive
A directive is a line comment with no space after //, no space after the colon, and a lowercase name. An argument follows after a space, and a trailing // reason is still allowed:
//declscope:package // shared with the reporting codeAny other comment whose text, after // or /*, starts with declscope: once any space is skipped is malformed. It is reported with one message, and it has no effect:
user.go:7:1: malformed declscope directive: write it as //declscope:name
| Form | Example | 0.10.1 | 0.11.0 |
|---|---|---|---|
Space or tab after // |
// declscope:package |
Read as a directive | Malformed |
| Space after the colon | //declscope: package |
Read as a directive | Malformed |
| Block comment | /*declscope:package*/ |
Read as a directive | Malformed |
| Uppercase name | //declscope:Package |
unknown directive |
Malformed |
| No name | //declscope: |
Ignored | Malformed |
This covers every keyword, at the declaration level, at the file level, and for a directive that binds to nothing. Prose that mentions a directive partway through a comment is not reported. An unknown lowercase name, such as //declscope:packagex, is still reported as unknown directive.
A malformed directive is reported rather than ignored. A directive that silently does nothing would widen or narrow a scope without anyone noticing.
Migrating
Run declscope 0.11.0 over the repository. Every comment to change is reported at its position.
| 0.10.1 | 0.11.0 |
|---|---|
// declscope:package |
//declscope:package |
//declscope: package |
//declscope:package |
/*declscope:package*/, /* declscope:package */ |
//declscope:package |
//declscope:Package |
//declscope:package |
//declscope: |
Remove it |
A file-level directive written as a block comment moves to a line comment above the package clause, as the other file-level directives are written.
Other changes
//go:linknameis now read throughgo/ast.ParseDirectivetoo, so a tab between it and its names is recognized. A declaration it names still gets no rename fix and nosurplusreport. cgo's//exportis read as before.- The README links the documentation site, which has a logo and a social preview (#107, #108).
Full changelog: v0.10.1...v0.11.0