Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,21 @@ Generated go files should have "Code generated" comments as the first line, with
a standard in the community, with editors giving warnings not to modify. An example

```gotemplate
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

```

Example output:
```go
// Code generated by foji 0.3, template: foji/openapi/model.go.tpl; DO NOT EDIT.
// Code generated by foji, template: foji/openapi/model.go.tpl; DO NOT EDIT.
```

`version` (string version of the foji tool) and `templateFile` (the currently executing template file) are part of the
`templateFile` (the currently executing template file) is part of the
standard template func set (available to all templates).

`version` (string version of the foji cli) is also available. Note that we no longer recommend injecting the version
into the generated code. Instead, commit the generated code and manage changes with git.

An exception to the above naming and comment rules are when you generate a file as a "starting point". For example
openAPI generates a project `main.go` as an example service. Once this file is generated, it should never be replaced
Prefix the file name with `!` to disable generation on existing files.
Expand Down
2 changes: 1 addition & 1 deletion foji/enum.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ .PackageName }}

Expand Down
2 changes: 1 addition & 1 deletion foji/fields.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ .PackageName }}

Expand Down
2 changes: 1 addition & 1 deletion foji/openapi/docs.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ .PackageName }}

Expand Down
2 changes: 1 addition & 1 deletion foji/openapi/handler.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{{- end -}}
{{- $package := $.PackageName }}

// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ $package }}

Expand Down
2 changes: 1 addition & 1 deletion foji/openapi/model.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func (p {{ pascal $key }}) Validate() error {
{{- end -}}
{{- end -}}

// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ .PackageName }}

Expand Down
9 changes: 8 additions & 1 deletion foji/openapi/service.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ import (
{{- end }}
)

// GenService holds all Unsupported mock endpoints {{ .PackageName }}.
// GenService holds all Unsupported mock endpoints. You can embed the mock service in real code.
// Simple example:
//
// type Service struct {
// GenService
// }
//
// This allows you to mock the service for a quick start and eventually delete this stub.
type GenService struct {
}

Expand Down
2 changes: 1 addition & 1 deletion foji/pgx/db.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package pg

Expand Down
2 changes: 1 addition & 1 deletion foji/pgx/model.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ .PackageName }}

Expand Down
2 changes: 1 addition & 1 deletion foji/pgx/table.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.
{{- $pkgName := "pg" }}
{{- $table := .Table.Name}}
{{- $schema := .Table.Schema.Name}}
Expand Down
2 changes: 1 addition & 1 deletion foji/sqlRepo.go.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by foji {{ version }}, template: {{ templateFile }}; DO NOT EDIT.
// Code generated by foji, template: {{ templateFile }}; DO NOT EDIT.

package {{ $.PackageName }}

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ github.com/gobuffalo/plush/v5 v5.0.10/go.mod h1:C08u/VEqzzPBXFF/yqs40P/5Cvc/zlZs
github.com/gobuffalo/tags/v3 v3.1.4 h1:X/ydLLPhgXV4h04Hp2xlbI2oc5MDaa7eub6zw8oHjsM=
github.com/gobuffalo/tags/v3 v3.1.4/go.mod h1:ArRNo3ErlHO8BtdA0REaZxijuWnWzF6PUXngmMXd2I0=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofoji/plates v0.3.2 h1:JSkN4Fwvy196tAsWau1W8wetAbCMkaEsxXooJGqEtL4=
github.com/gofoji/plates v0.3.2/go.mod h1:dMu4ksz2zTMiXjTPjKQ5KVbqPc7mAHucGGmLsMmlaeE=
github.com/gofoji/plates v0.3.3 h1:MfBu5TtWHxxEBKoGngi1FA2MhcRfjm0odl6ouis9rhs=
github.com/gofoji/plates v0.3.3/go.mod h1:KOsI6hw+5gWEc/9Igg7bAbauc3IhKQwdOAMgv+FYeMo=
github.com/gofoji/plates/plush v0.3.4 h1:bIfDe7lyeiorGT0dfKtADTAyl78qFT8wvxqf+bQfsr0=
Expand Down
2 changes: 1 addition & 1 deletion tests/auth/http_handler_gen.go

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

2 changes: 1 addition & 1 deletion tests/auth/model_gen.go

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

9 changes: 8 additions & 1 deletion tests/auth/service_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import (
"tests/example"
)

// GenService holds all Unsupported mock endpoints auth.
// GenService holds all Unsupported mock endpoints. You can embed the mock service in real code.
// Simple example:
//
// type Service struct {
// GenService
// }
//
// This allows you to mock the service for a quick start and eventually delete this stub.
type GenService struct{}

// ListAdminUsers
Expand Down
2 changes: 1 addition & 1 deletion tests/csvresponse/http_handler_gen.go

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

2 changes: 1 addition & 1 deletion tests/csvresponse/model_gen.go

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

3 changes: 2 additions & 1 deletion tests/example/http_handler_gen.go

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

2 changes: 1 addition & 1 deletion tests/example/model_gen.go

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