Skip to content

Commit

Permalink
deepcopy: gen: match Go 1.17 build tag format
Browse files Browse the repository at this point in the history
The Go team has started the process of replacing the old "// +build"
constraints with the new "//go:build" constraints. See the design
doc for more details here:

https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md

What is relevant is that in Go 1.17, gofmt now synchronizes the two
styles. In particular, if gofmt is run against a deepcopy generated
file, it will add a new "//go:build" constraint.

See https://golang.org/doc/go1.17#gofmt for details.

This PR intends to make it so that the generated code is compliant with
the new gofmt style.
  • Loading branch information
benpbrown committed Aug 17, 2021
1 parent 03ab6b3 commit de20394
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/deepcopy/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ type ObjectGenCtx struct {
// writeHeader writes out the build tag, package declaration, and imports
func writeHeader(pkg *loader.Package, out io.Writer, packageName string, imports *importsList, headerText string) {
// NB(directxman12): blank line after build tags to distinguish them from comments
_, err := fmt.Fprintf(out, `// +build !ignore_autogenerated
_, err := fmt.Fprintf(out, `//go:build !ignore_autogenerated
// +build !ignore_autogenerated
%[3]s
Expand Down
1 change: 1 addition & 0 deletions pkg/deepcopy/testdata/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de20394

Please sign in to comment.