Skip to content

Commit de20394

Browse files
committed
deepcopy: gen: match Go 1.17 build tag format
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.
1 parent 03ab6b3 commit de20394

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pkg/deepcopy/gen.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ type ObjectGenCtx struct {
175175
// writeHeader writes out the build tag, package declaration, and imports
176176
func writeHeader(pkg *loader.Package, out io.Writer, packageName string, imports *importsList, headerText string) {
177177
// NB(directxman12): blank line after build tags to distinguish them from comments
178-
_, err := fmt.Fprintf(out, `// +build !ignore_autogenerated
178+
_, err := fmt.Fprintf(out, `//go:build !ignore_autogenerated
179+
// +build !ignore_autogenerated
179180
180181
%[3]s
181182

pkg/deepcopy/testdata/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)