Skip to content

Commit

Permalink
buildtags: Format only go:build lines for go 1.18+ (#211)
Browse files Browse the repository at this point in the history
```
$ ./tmp/testgo161718.sh ./buildtags/ ./printer/
+ go1.16.8 test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
+ go1.17.2 test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
+ gotip test ./buildtags/ ./printer/
ok  	github.com/mmcloughlin/avo/buildtags	0.001s
ok  	github.com/mmcloughlin/avo/printer	0.002s
```

Updates #183
  • Loading branch information
mmcloughlin authored Oct 30, 2021
1 parent c48d61f commit 1d235fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion buildtags/syntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func Format(t ConstraintsConvertable) (string, error) {
output := ""
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "//") {
if (PlusBuildSyntaxSupported() && strings.HasPrefix(line, "// +build")) ||
(GoBuildSyntaxSupported() && strings.HasPrefix(line, "//go:build")) {
output += line + "\n"
}
}
Expand Down

0 comments on commit 1d235fb

Please sign in to comment.