Skip to content

Commit caaee72

Browse files
authored
fix(golangci-lint): fix errors in internal/sidekick (#1575)
Fix these errors detected by TestGolangCILint: ``` --- FAIL: TestGolangCILint (1.53s) all_test.go:156: /Users/julieqiu/bin/homebrew/Cellar/go/1.24.4/libexec/bin/go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest run: exit status 1 internal/sidekick/internal/api/model.go:27:2: Comment should end in a period (godot) // descriptorpb.FieldDescriptorProto_Type ^ internal/sidekick/internal/api/model.go:290:1: Comment should end in a period (godot) // ``` ^ internal/sidekick/internal/api/model.go:368:1: Comment should end in a period (godot) // OperationInfo contains normalized long running operation info ^ internal/sidekick/internal/api/documentation.go:116:9: QF1004: could use strings.ReplaceAll instead (staticcheck) new := strings.Replace(*documentation, override.Match, override.Replace, -1) ^ internal/sidekick/internal/dart/annotate.go:593:3: QF1002: could use tagged switch on field.Typez (staticcheck) switch { ^ internal/sidekick/internal/dart/annotate.go:613:3: QF1002: could use tagged switch on valueField.Typez (staticcheck) switch { ^ internal/sidekick/internal/dart/annotate.go:669:3: QF1002: could use tagged switch on field.Typez (staticcheck) switch { ^ internal/sidekick/internal/dart/annotate.go:681:3: QF1002: could use tagged switch on valueField.Typez (staticcheck) switch { ^ internal/sidekick/internal/dart/annotate.go:730:3: QF1002: could use tagged switch on field.Typez (staticcheck) switch { ^ internal/sidekick/internal/parser/pagination.go:63:6: QF1001: could apply De Morgan's law (staticcheck) if !(hasPageSize && hasPageToken != nil) { ^ internal/sidekick/internal/parser/pagination.go:87:6: QF1001: could apply De Morgan's law (staticcheck) if !(hasNextPageToken && hasRepeatedItem) { ^ internal/sidekick/internal/rust/annotate.go:775:3: QF1002: could use tagged switch on segment (staticcheck) switch { ^ internal/sidekick/internal/rust/codec.go:492:2: QF1003: could use tagged switch on f.Typez (staticcheck) if f.Typez == api.MESSAGE_TYPE { ^ internal/sidekick/sidekick_test.go:148:30: QF1004: could use strings.ReplaceAll instead (staticcheck) "package-name-override": strings.Replace(config.Name, "/", "-", -1) + "-golden-protobuf", ^ internal/sidekick/downloads_cache_test.go:209:49: makeTestContents - result 1 (error) is always nil (unparam) func makeTestContents(t *testing.T) (*contents, error) { ^ internal/sidekick/internal/dart/annotate.go:202:74: (*annotateModel).annotateModel - result 0 (*github.com/googleapis/librarian/internal/sidekick/internal/dart.modelAnnotations) is never used (unparam) func (annotate *annotateModel) annotateModel(options map[string]string) (*modelAnnotations, error) { ^ internal/sidekick/internal/golang/gotemplate.go:106:64: annotateModel - result 0 (*github.com/googleapis/librarian/internal/sidekick/internal/golang.modelAnnotations) is never used (unparam) func annotateModel(model *api.API, options map[string]string) (*modelAnnotations, error) { ^ internal/sidekick/downloads_cache_test.go:33:14: os.MkdirTemp() could be replaced by t.TempDir() in TestExistingDirectory (usetesting) tmp, err := os.MkdirTemp(t.TempDir(), "sidekick-test-") ^ internal/sidekick/downloads_cache_test.go:65:18: os.MkdirTemp() could be replaced by t.TempDir() in TestWithDownload (usetesting) testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-") ^ internal/sidekick/downloads_cache_test.go:112:18: os.MkdirTemp() could be replaced by t.TempDir() in TestTargetExists (usetesting) testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-") ^ internal/sidekick/downloads_cache_test.go:147:18: os.MkdirTemp() could be replaced by t.TempDir() in TestDownloadGoogleapisRootTgzExists (usetesting) testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-") ^ internal/sidekick/downloads_cache_test.go:170:18: os.MkdirTemp() could be replaced by t.TempDir() in TestDownloadGoogleapisRootNeedsDownload (usetesting) testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-") ^ internal/sidekick/sidekick_dart_test.go:26:17: os.MkdirTemp() could be replaced by t.TempDir() in TestDartFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_rust_prost_convert_test.go:25:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustProstConvert (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_rust_prost_test.go:25:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustProstFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_sample_test.go:25:17: os.MkdirTemp() could be replaced by t.TempDir() in TestSampleFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:43:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustFromOpenAPI (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:84:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:176:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustModuleFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:244:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustBootstrapWkt (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:311:17: os.MkdirTemp() could be replaced by t.TempDir() in TestRustOverrideTitleAndDescription (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/sidekick_test.go:363:17: os.MkdirTemp() could be replaced by t.TempDir() in TestGoFromProtobuf (usetesting) outDir, err := os.MkdirTemp(t.TempDir(), "golden") ^ internal/sidekick/update_test.go:39:8: os.Chdir() could be replaced by t.Chdir() in TestUpdateRootConfig (usetesting) defer os.Chdir(cwd) ^ internal/sidekick/update_test.go:40:12: os.Chdir() could be replaced by t.Chdir() in TestUpdateRootConfig (usetesting) if err := os.Chdir(tempDir); err != nil { ^ ``` Fixes #1541
1 parent 906e2e0 commit caaee72

22 files changed

+83
-167
lines changed

.golangci.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,3 @@ linters:
2929
- unparam
3030
- unused
3131
- usetesting
32-
# TODO(https://github.com/googleapis/librarian/issues/1510): fix tests and
33-
# remove
34-
exclusions:
35-
paths:
36-
- internal/sidekick

internal/sidekick/downloads_cache_test.go

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ import (
3030
)
3131

3232
func TestExistingDirectory(t *testing.T) {
33-
tmp, err := os.MkdirTemp(t.TempDir(), "sidekick-test-")
34-
if err != nil {
35-
t.Fatal(err)
36-
}
37-
defer os.RemoveAll(tmp)
33+
tmp := t.TempDir()
3834
rootConfig := config.Config{
3935
Source: map[string]string{
4036
"googleapis-root": tmp,
@@ -62,11 +58,7 @@ func TestValidateConfig(t *testing.T) {
6258
}
6359

6460
func TestWithDownload(t *testing.T) {
65-
testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-")
66-
if err != nil {
67-
t.Fatal(err)
68-
}
69-
defer os.RemoveAll(testDir)
61+
testDir := t.TempDir()
7062

7163
simulatedSha := "2d08f07eab9bbe8300cd20b871d0811bbb693fab"
7264
simulatedSubdir := fmt.Sprintf("googleapis-%s", simulatedSha)
@@ -109,11 +101,7 @@ func TestWithDownload(t *testing.T) {
109101
}
110102

111103
func TestTargetExists(t *testing.T) {
112-
testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-")
113-
if err != nil {
114-
t.Fatal(err)
115-
}
116-
defer os.RemoveAll(testDir)
104+
testDir := t.TempDir()
117105

118106
sha256 := "eb853d49313f20a096607fea87dfc10bd6a1b917ad17ad5db8a205b457a940e1"
119107
rootConfig := &config.Config{
@@ -144,16 +132,9 @@ func TestTargetExists(t *testing.T) {
144132
}
145133

146134
func TestDownloadGoogleapisRootTgzExists(t *testing.T) {
147-
testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-")
148-
if err != nil {
149-
t.Fatal(err)
150-
}
151-
defer os.RemoveAll(testDir)
135+
testDir := t.TempDir()
152136

153-
tarball, err := makeTestContents(t)
154-
if err != nil {
155-
t.Fatal(err)
156-
}
137+
tarball := makeTestContents(t)
157138

158139
// In this test we will create the download file with the right contents.
159140
target := path.Join(testDir, "existing-file")
@@ -167,16 +148,9 @@ func TestDownloadGoogleapisRootTgzExists(t *testing.T) {
167148
}
168149

169150
func TestDownloadGoogleapisRootNeedsDownload(t *testing.T) {
170-
testDir, err := os.MkdirTemp(t.TempDir(), "sidekick-test-")
171-
if err != nil {
172-
t.Fatal(err)
173-
}
174-
defer os.RemoveAll(testDir)
151+
testDir := t.TempDir()
175152

176-
tarball, err := makeTestContents(t)
177-
if err != nil {
178-
t.Fatal(err)
179-
}
153+
tarball := makeTestContents(t)
180154

181155
// In this test we expect that a download is needed.
182156
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -206,7 +180,7 @@ type contents struct {
206180
Contents []byte
207181
}
208182

209-
func makeTestContents(t *testing.T) (*contents, error) {
183+
func makeTestContents(t *testing.T) *contents {
210184
t.Helper()
211185

212186
hasher := sha256.New()
@@ -220,7 +194,7 @@ func makeTestContents(t *testing.T) (*contents, error) {
220194
return &contents{
221195
Sha256: fmt.Sprintf("%x", hasher.Sum(nil)),
222196
Contents: data,
223-
}, nil
197+
}
224198
}
225199

226200
func makeTestTarball(t *testing.T, tempDir, subdir string) (*contents, error) {

internal/sidekick/internal/api/dependencies_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ func TestFindDependenciesService(t *testing.T) {
583583
}
584584
}
585585

586-
// Simplify the test expectations
586+
// Simplify the test expectations.
587587
func flatten(m map[string]bool) []string {
588588
var arr []string
589589
for k, v := range m {

internal/sidekick/internal/api/documentation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func patchMethodDocs(svc *Service, name string, override *config.DocumentationOv
113113
}
114114

115115
func patchElementDocs(documentation *string, override *config.DocumentationOverride) error {
116-
new := strings.Replace(*documentation, override.Match, override.Replace, -1)
116+
new := strings.ReplaceAll(*documentation, override.Match, override.Replace)
117117
if *documentation == new {
118118
slog.Error("comment override mismatch", "id", override.ID, "want", override.Match, "text", *documentation)
119119
return fmt.Errorf("comment override for %s did not match", override.ID)

internal/sidekick/internal/api/model.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Typez int
2424

2525
const (
2626
// These are the different field types as defined in
27-
// descriptorpb.FieldDescriptorProto_Type
27+
// descriptorpb.FieldDescriptorProto_Type.
2828

2929
UNDEFINED_TYPE Typez = iota // 0
3030
DOUBLE_TYPE // 1
@@ -287,7 +287,7 @@ type Method struct {
287287
// [(a, va3), (b, vb2), (c, vc1)],
288288
//
289289
// ]
290-
// ```
290+
// ```.
291291
func (m *Method) RoutingCombos() []*RoutingInfoCombo {
292292
combos := []*RoutingInfoCombo{
293293
{},
@@ -365,7 +365,7 @@ type PathBinding struct {
365365
Codec any
366366
}
367367

368-
// OperationInfo contains normalized long running operation info
368+
// OperationInfo contains normalized long running operation info.
369369
type OperationInfo struct {
370370
// The metadata type. If there is no metadata, this is set to
371371
// `.google.protobuf.Empty`.
@@ -451,11 +451,11 @@ type RoutingPathSpec struct {
451451

452452
const (
453453
// SingleSegmentWildcard is a special routing path segment which indicates
454-
// "match anything that does not include a `/`"
454+
// "match anything that does not include a `/`".
455455
SingleSegmentWildcard = "*"
456456

457457
// MultiSegmentWildcard is a special routing path segment which indicates
458-
// "match anything including `/`"
458+
// "match anything including `/`".
459459
MultiSegmentWildcard = "**"
460460
)
461461

internal/sidekick/internal/dart/annotate.go

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func newAnnotateModel(model *api.API) *annotateModel {
199199
// Fields and methods defined in this struct directly correspond to Mustache
200200
// tags. For example, the Mustache tag {{#Services}} uses the
201201
// [Template.Services] field.
202-
func (annotate *annotateModel) annotateModel(options map[string]string) (*modelAnnotations, error) {
202+
func (annotate *annotateModel) annotateModel(options map[string]string) error {
203203
var (
204204
packageNameOverride string
205205
generationYear string
@@ -224,7 +224,7 @@ func (annotate *annotateModel) annotateModel(options map[string]string) (*modelA
224224
case key == "not-for-publication":
225225
value, err := strconv.ParseBool(definition)
226226
if err != nil {
227-
return nil, fmt.Errorf(
227+
return fmt.Errorf(
228228
"cannot convert `not-for-publication` value %q to boolean: %w",
229229
definition,
230230
err,
@@ -235,15 +235,15 @@ func (annotate *annotateModel) annotateModel(options map[string]string) (*modelA
235235
// "proto:google.protobuf" = "package:google_cloud_protobuf/protobuf.dart"
236236
keys := strings.Split(key, ":")
237237
if len(keys) != 2 {
238-
return nil, fmt.Errorf("key should be in the format proto:<proto-package>, got=%q", key)
238+
return fmt.Errorf("key should be in the format proto:<proto-package>, got=%q", key)
239239
}
240240
protoPackage := keys[1]
241241
annotate.packageMapping[protoPackage] = definition
242242
case strings.HasPrefix(key, "prefix:"):
243243
// 'prefix:google.protobuf' = 'protobuf'
244244
keys := strings.Split(key, ":")
245245
if len(keys) != 2 {
246-
return nil, fmt.Errorf("key should be in the format prefix:<proto-package>, got=%q", key)
246+
return fmt.Errorf("key should be in the format prefix:<proto-package>, got=%q", key)
247247
}
248248
protoPackage := keys[1]
249249
annotate.packagePrefixes[protoPackage] = definition
@@ -307,7 +307,7 @@ func (annotate *annotateModel) annotateModel(options map[string]string) (*modelA
307307
}
308308

309309
model.Codec = ann
310-
return ann, nil
310+
return nil
311311
}
312312

313313
func calculateRequiredFields(model *api.API) map[string]*api.Field {
@@ -590,13 +590,13 @@ func (annotate *annotateModel) createFromJsonLine(field *api.Field, state *api.A
590590

591591
switch {
592592
case isList:
593-
switch {
594-
case field.Typez == api.BYTES_TYPE:
593+
switch field.Typez {
594+
case api.BYTES_TYPE:
595595
return fmt.Sprintf("decodeListBytes(%s)%s", data, bang)
596-
case field.Typez == api.ENUM_TYPE:
596+
case api.ENUM_TYPE:
597597
typeName := enumName(state.EnumByID[field.TypezID])
598598
return fmt.Sprintf("decodeListEnum(%s, %s.fromJson)%s", data, typeName, bang)
599-
case field.Typez == api.MESSAGE_TYPE:
599+
case api.MESSAGE_TYPE:
600600
_, hasCustomEncoding := usesCustomEncoding[field.TypezID]
601601
typeName := annotate.resolveTypeName(state.MessageByID[field.TypezID], true)
602602
if hasCustomEncoding {
@@ -610,13 +610,13 @@ func (annotate *annotateModel) createFromJsonLine(field *api.Field, state *api.A
610610
case isMap:
611611
valueField := message.Fields[1]
612612

613-
switch {
614-
case valueField.Typez == api.BYTES_TYPE:
613+
switch valueField.Typez {
614+
case api.BYTES_TYPE:
615615
return fmt.Sprintf("decodeMapBytes(%s)%s", data, bang)
616-
case valueField.Typez == api.ENUM_TYPE:
616+
case api.ENUM_TYPE:
617617
typeName := enumName(state.EnumByID[valueField.TypezID])
618618
return fmt.Sprintf("decodeMapEnum(%s, %s.fromJson)%s", data, typeName, bang)
619-
case valueField.Typez == api.MESSAGE_TYPE:
619+
case api.MESSAGE_TYPE:
620620
_, hasCustomEncoding := usesCustomEncoding[valueField.TypezID]
621621
typeName := annotate.resolveTypeName(state.MessageByID[valueField.TypezID], true)
622622
if hasCustomEncoding {
@@ -666,10 +666,10 @@ func createToJsonLine(field *api.Field, state *api.APIState, required bool) stri
666666

667667
switch {
668668
case isList:
669-
switch {
670-
case field.Typez == api.BYTES_TYPE:
669+
switch field.Typez {
670+
case api.BYTES_TYPE:
671671
return fmt.Sprintf("encodeListBytes(%s)", name)
672-
case field.Typez == api.MESSAGE_TYPE || field.Typez == api.ENUM_TYPE:
672+
case api.MESSAGE_TYPE, api.ENUM_TYPE:
673673
return fmt.Sprintf("encodeList(%s)", name)
674674
default:
675675
// identity
@@ -678,10 +678,10 @@ func createToJsonLine(field *api.Field, state *api.APIState, required bool) stri
678678
case isMap:
679679
valueField := message.Fields[1]
680680

681-
switch {
682-
case valueField.Typez == api.BYTES_TYPE:
681+
switch valueField.Typez {
682+
case api.BYTES_TYPE:
683683
return fmt.Sprintf("encodeMapBytes(%s)", name)
684-
case valueField.Typez == api.MESSAGE_TYPE || valueField.Typez == api.ENUM_TYPE:
684+
case api.MESSAGE_TYPE, api.ENUM_TYPE:
685685
return fmt.Sprintf("encodeMap(%s)", name)
686686
default:
687687
// identity
@@ -727,21 +727,17 @@ func buildQueryLines(
727727
switch {
728728
case field.Repeated:
729729
// Handle lists; these should be lists of strings or other primitives.
730-
switch {
731-
case field.Typez == api.STRING_TYPE:
730+
switch field.Typez {
731+
case api.STRING_TYPE:
732732
return append(result, fmt.Sprintf("%s: %s!", preable, ref))
733-
case field.Typez == api.ENUM_TYPE:
733+
case api.ENUM_TYPE:
734734
return append(result, fmt.Sprintf("%s: %s!.map((e) => e.value)", preable, ref))
735-
case field.Typez == api.BOOL_TYPE ||
736-
field.Typez == api.INT32_TYPE ||
737-
field.Typez == api.UINT32_TYPE || field.Typez == api.SINT32_TYPE ||
738-
field.Typez == api.FIXED32_TYPE || field.Typez == api.SFIXED32_TYPE ||
739-
field.Typez == api.INT64_TYPE ||
740-
field.Typez == api.UINT64_TYPE || field.Typez == api.SINT64_TYPE ||
741-
field.Typez == api.FIXED64_TYPE || field.Typez == api.SFIXED64_TYPE ||
742-
field.Typez == api.FLOAT_TYPE || field.Typez == api.DOUBLE_TYPE:
735+
case api.BOOL_TYPE, api.INT32_TYPE, api.UINT32_TYPE, api.SINT32_TYPE,
736+
api.FIXED32_TYPE, api.SFIXED32_TYPE, api.INT64_TYPE,
737+
api.UINT64_TYPE, api.SINT64_TYPE, api.FIXED64_TYPE, api.SFIXED64_TYPE,
738+
api.FLOAT_TYPE, api.DOUBLE_TYPE:
743739
return append(result, fmt.Sprintf("%s: %s!.map((e) => '$e')", preable, ref))
744-
case field.Typez == api.BYTES_TYPE:
740+
case api.BYTES_TYPE:
745741
return append(result, fmt.Sprintf("%s: %s!.map((e) => encodeBytes(e)!)", preable, ref))
746742
default:
747743
slog.Error("unhandled list query param", "type", field.Typez)

internal/sidekick/internal/dart/annotate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestAnnotateModel(t *testing.T) {
2626
model := api.NewTestAPI([]*api.Message{}, []*api.Enum{}, []*api.Service{})
2727
model.PackageName = "test"
2828
annotate := newAnnotateModel(model)
29-
_, err := annotate.annotateModel(map[string]string{})
29+
err := annotate.annotateModel(map[string]string{})
3030
if err != nil {
3131
t.Fatal(err)
3232
}
@@ -44,7 +44,7 @@ func TestAnnotateModel(t *testing.T) {
4444
func TestAnnotateModel_Options(t *testing.T) {
4545
model := api.NewTestAPI([]*api.Message{}, []*api.Enum{}, []*api.Service{})
4646
annotate := newAnnotateModel(model)
47-
_, err := annotate.annotateModel(map[string]string{
47+
err := annotate.annotateModel(map[string]string{
4848
"version": "1.0.0",
4949
"part-file": "src/test.p.dart",
5050
})
@@ -80,7 +80,7 @@ func TestAnnotateMethod(t *testing.T) {
8080
)
8181
api.Validate(model)
8282
annotate := newAnnotateModel(model)
83-
_, err := annotate.annotateModel(map[string]string{})
83+
err := annotate.annotateModel(map[string]string{})
8484
if err != nil {
8585
t.Fatal(err)
8686
}

internal/sidekick/internal/dart/dart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func httpPathFmt(pathInfo *api.PathInfo) string {
184184
// both regular references as well as implit references.
185185
//
186186
// - `[Code][google.rpc.Code]`
187-
// - `[google.rpc.Code][]`
187+
// - `[google.rpc.Code][]`.
188188
var commentRefsRegex = regexp.MustCompile(`\[([\w\d\._]+)\]\[([\d\w\._]*)\]`)
189189

190190
func formatDocComments(documentation string, _ *api.APIState) []string {

internal/sidekick/internal/dart/generate.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ var dartTemplates embed.FS
2929
// Generate generates Dart code from the model.
3030
func Generate(model *api.API, outdir string, config *config.Config) error {
3131
annotate := newAnnotateModel(model)
32-
_, err := annotate.annotateModel(config.Codec)
33-
if err != nil {
32+
if err := annotate.annotateModel(config.Codec); err != nil {
3433
return err
3534
}
3635

3736
provider := templatesProvider()
38-
err = language.GenerateFromModel(outdir, model, provider, generatedFiles(model))
37+
err := language.GenerateFromModel(outdir, model, provider, generatedFiles(model))
3938
if err == nil {
4039
// Check if we're configured to skip formatting.
4140
skipFormat := config.Codec["skip-format"]
4241
if skipFormat != "true" {
4342
err = formatDirectory(outdir)
4443
}
4544
}
46-
4745
return err
4846
}
4947

internal/sidekick/internal/golang/golang.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ type goImport struct {
3737

3838
// Generate generates Go code from the model.
3939
func Generate(model *api.API, outdir string, cfg *config.Config) error {
40-
_, err := annotateModel(model, cfg.Codec)
41-
if err != nil {
40+
if err := annotateModel(model, cfg.Codec); err != nil {
4241
return err
4342
}
4443
provider := templatesProvider()

0 commit comments

Comments
 (0)