Skip to content

Commit

Permalink
fix: place code gen comment at top
Browse files Browse the repository at this point in the history
The code is generated comment must, acording to the go docs, be placed before any code. This ensures gofumpt and other tools excludes linting the spanner aip generated files.

Go docs: *'This line must appear before the first non-comment, non-blank text in the file.'* https://pkg.go.dev/cmd/go#section-directories
  • Loading branch information
loodde committed Aug 30, 2024
1 parent 556d550 commit edf2c6a
Show file tree
Hide file tree
Showing 21 changed files with 24 additions and 44 deletions.
3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/1.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/2.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/3.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/4.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/5.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/6.sql.database.go

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

3 changes: 1 addition & 2 deletions internal/codegen/databasecodegen/testdata/7.sql.database.go

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

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

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

3 changes: 1 addition & 2 deletions internal/codegen/descriptorcodegen/testdata/1.sql.table.go

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

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

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

3 changes: 1 addition & 2 deletions internal/codegen/descriptorcodegen/testdata/2.sql.table.go

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

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

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

3 changes: 1 addition & 2 deletions internal/codegen/descriptorcodegen/testdata/3.sql.table.go

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

8 changes: 4 additions & 4 deletions internal/codegen/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func NewFile(cfg FileConfig) *File {
imports: NewImports(),
}
f.buf.Grow(102400) // 100kiB
if cfg.GeneratedBy != "" {
f.P()
f.P("// Code generated by ", cfg.GeneratedBy, ". DO NOT EDIT.")
}
if cfg.BuildTag != "" {
f.P("// +build ", cfg.BuildTag)
f.P()
}
f.P("package ", cfg.Package)
if cfg.GeneratedBy != "" {
f.P()
f.P("// Code generated by ", cfg.GeneratedBy, ". DO NOT EDIT.")
}
f.P()
f.P("import ()")
return f
Expand Down
3 changes: 1 addition & 2 deletions internal/examples/freightdb/database_gen.go

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

3 changes: 1 addition & 2 deletions internal/examples/freightdb/descriptor_gen.go

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

3 changes: 1 addition & 2 deletions internal/examples/musicdb/database_gen.go

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

3 changes: 1 addition & 2 deletions internal/examples/musicdb/descriptor_gen.go

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

0 comments on commit edf2c6a

Please sign in to comment.