Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: support no fmt for better codegen speed #182

Merged
merged 1 commit into from
Apr 3, 2024
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
3 changes: 3 additions & 0 deletions generator/golang/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ func (g *GoBackend) buildResponse() *plugin.Response {
// PostProcess implements the backend.PostProcessor interface to do
// source formatting before writing files out.
func (g *GoBackend) PostProcess(path string, content []byte) ([]byte, error) {
if g.utils.Features().NoFmt {
return content, nil
}
switch filepath.Ext(path) {
case ".go":
if formated, err := format.Source(content); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion generator/golang/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ type Features struct {
NoDefaultSerdes bool `no_default_serdes:"Do not generate default thrift serdes code."`
NoAliasTypeReflectionMethod bool `no_alias_type_reflection_method:"Do not generate type related methods in <idl>_reflection.go when 'thrift.is_alias=\"true\"' annotation is set to types."`
EnableRefInterface bool `enable_ref_interface:"Generate Interface field without pointer type when 'thrift.is_interface=\"true\"' annotation is set to types in referred thrift."`
UseOption bool `use_option:"Parse specific Thrift annotations into struct-style option fields. If key not match, thriftgo will just ignore it."`
UseOption bool `use_option:"Parse specific Thrift annotations into struct-style option fields. If key not match, thriftgo will just ignore it."`
// ForceUseOption bool `use_option:"Forcefully parse all Thrift annotations into struct-style option fields. If parsing is not possible, an error will be thrown."`
NoFmt bool `no_fmt:"To achieve faster generation speed, skipping the formatting of Golang code can improve performance by approximately 50%."`
}

var defaultFeatures = Features{
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package version

const ThriftgoVersion = "0.3.8"
const ThriftgoVersion = "0.3.9"
Loading