From c9ec821a3fdf0fd22fd3d2e0c5a3fa804c8a87e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Tue, 1 Aug 2023 13:12:50 +0200 Subject: [PATCH] Rename GenGoFile.ErrIfAdd to IgnoreDiscoveredImports --- encoding/gocode/gen.go | 16 ++++++++-------- encoding/gocode/postprocessing.go | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/encoding/gocode/gen.go b/encoding/gocode/gen.go index 823a91e..2a68774 100644 --- a/encoding/gocode/gen.go +++ b/encoding/gocode/gen.go @@ -123,10 +123,10 @@ func GenerateTypesOpenAPI(sch thema.Schema, cfg *TypeConfigOpenAPI) ([]byte, err } return PostprocessGoFile(GenGoFile{ - Path: fmt.Sprintf("%s_type_gen.go", sch.Lineage().Name()), - Appliers: applyFuncs, - In: []byte(gostr), - ErrIfAdd: !cfg.IgnoreDiscoveredImports, + Path: fmt.Sprintf("%s_type_gen.go", sch.Lineage().Name()), + Appliers: applyFuncs, + In: []byte(gostr), + IgnoreDiscoveredImports: !cfg.IgnoreDiscoveredImports, }) } @@ -343,10 +343,10 @@ func GenerateLineageBinding(lin thema.Lineage, cfg *BindingConfig) ([]byte, erro } return PostprocessGoFile(GenGoFile{ - Path: fmt.Sprintf("%s_binding_gen.go", strings.ToLower(lin.Name())), - Appliers: cfg.ApplyFuncs, - In: buf.Bytes(), - ErrIfAdd: !cfg.IgnoreDiscoveredImports, + Path: fmt.Sprintf("%s_binding_gen.go", strings.ToLower(lin.Name())), + Appliers: cfg.ApplyFuncs, + In: buf.Bytes(), + IgnoreDiscoveredImports: !cfg.IgnoreDiscoveredImports, }) } diff --git a/encoding/gocode/postprocessing.go b/encoding/gocode/postprocessing.go index 49fc6a2..acfa365 100644 --- a/encoding/gocode/postprocessing.go +++ b/encoding/gocode/postprocessing.go @@ -16,10 +16,10 @@ import ( ) type GenGoFile struct { - ErrIfAdd bool - Path string - Appliers []dstutil.ApplyFunc - In []byte + Path string + Appliers []dstutil.ApplyFunc + In []byte + IgnoreDiscoveredImports bool } func PostprocessGoFile(cfg GenGoFile) ([]byte, error) { @@ -45,7 +45,7 @@ func PostprocessGoFile(cfg GenGoFile) ([]byte, error) { return nil, fmt.Errorf("goimports processing of generated file failed: %w", err) } - if cfg.ErrIfAdd { + if !cfg.IgnoreDiscoveredImports { // Compare imports before and after; warn about performance if some were added gfa, _ := parser.ParseFile(fset, fname, string(byt), parser.ParseComments) imap := make(map[string]bool)