Skip to content

Commit 028095d

Browse files
authored
refactor: convert var to const where appropriate (#2872)
Convert several `var` declarations to `const` to improve code clarity and enforce immutability for these values. Fixes #2871
1 parent 05e5099 commit 028095d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

internal/sidekick/dart/dart.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/iancoleman/strcase"
2727
)
2828

29-
var (
29+
const (
3030
typedDataImport = "dart:typed_data"
3131
httpImport = "package:http/http.dart as http"
3232
serviceClientImport = "package:google_cloud_rpc/service_client.dart"
@@ -59,7 +59,7 @@ var usesCustomEncoding = map[string]string{
5959
".google.protobuf.Value": "",
6060
}
6161

62-
var (
62+
const (
6363
// nestedMessageChar is used to concatenate a message and a child message.
6464
nestedMessageChar = "_"
6565

internal/sidekick/parser/parser_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ import (
2323
"github.com/googleapis/librarian/internal/sidekick/config"
2424
)
2525

26+
const (
27+
discoSourceFileRelative = "disco/compute.v1.json"
28+
secretManagerYamlRelative = "google/cloud/secretmanager/v1/secretmanager_v1.yaml"
29+
)
30+
2631
var (
2732
testdataDir, _ = filepath.Abs("../testdata")
28-
discoSourceFileRelative = "disco/compute.v1.json"
2933
discoSourceFile = path.Join(testdataDir, discoSourceFileRelative)
30-
secretManagerYamlRelative = "google/cloud/secretmanager/v1/secretmanager_v1.yaml"
3134
secretManagerYamlFullPath = path.Join(testdataDir, "googleapis", secretManagerYamlRelative)
3235
openAPIFile = path.Join(testdataDir, "openapi", "secretmanager_openapi_v1.json")
3336
protobufFile = path.Join("testdata", "scalar.proto")

internal/sidekick/sidekick/sidekick_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ import (
2121
"testing"
2222
)
2323

24-
var (
25-
testdataDir, _ = filepath.Abs("../testdata")
26-
googleapisRoot = fmt.Sprintf("%s/googleapis", testdataDir)
27-
outputDir = fmt.Sprintf("%s/test-only", testdataDir)
24+
const (
2825
secretManagerServiceConfig = "googleapis/google/cloud/secretmanager/v1/secretmanager_v1.yaml"
29-
specificationSource = fmt.Sprintf("%s/openapi/secretmanager_openapi_v1.json", testdataDir)
26+
)
27+
28+
var (
29+
testdataDir, _ = filepath.Abs("../testdata")
30+
googleapisRoot = fmt.Sprintf("%s/googleapis", testdataDir)
31+
outputDir = fmt.Sprintf("%s/test-only", testdataDir)
32+
specificationSource = fmt.Sprintf("%s/openapi/secretmanager_openapi_v1.json", testdataDir)
3033
)
3134

3235
func requireCommand(t *testing.T, command string) {

0 commit comments

Comments
 (0)