Skip to content

Commit 1efe5c4

Browse files
egonelbrerahul2393
andauthored
fix(spanner): unnecessary string formatting fixes (#10736)
* fix(spanner): incorrect use of sprintf method * fix(spanner): unnecessary use of fmt.Sprintf --------- Co-authored-by: rahul2393 <[email protected]>
1 parent d1b5587 commit 1efe5c4

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

spanner/errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (e *TransactionOutcomeUnknownError) Unwrap() error { return e.err }
8282
// Error implements error.Error.
8383
func (e *Error) Error() string {
8484
if e == nil {
85-
return fmt.Sprintf("spanner: OK")
85+
return "spanner: OK"
8686
}
8787
code := ErrCode(e)
8888
if e.additionalInformation == "" {

spanner/integration_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -6280,29 +6280,29 @@ func blackholeOrAllowDirectPath(t *testing.T, blackholeDP bool) {
62806280
if blackholeDP {
62816281
cmdRes := exec.Command("bash", "-c", blackholeDpv4Cmd)
62826282
out, _ := cmdRes.CombinedOutput()
6283-
t.Logf(string(out))
6283+
t.Log(string(out))
62846284
} else {
62856285
cmdRes := exec.Command("bash", "-c", allowDpv4Cmd)
62866286
out, _ := cmdRes.CombinedOutput()
6287-
t.Logf(string(out))
6287+
t.Log(string(out))
62886288
}
62896289
return
62906290
}
62916291
// DirectPath supports both ipv4 and ipv6
62926292
if blackholeDP {
62936293
cmdRes := exec.Command("bash", "-c", blackholeDpv4Cmd)
62946294
out, _ := cmdRes.CombinedOutput()
6295-
t.Logf(string(out))
6295+
t.Log(string(out))
62966296
cmdRes = exec.Command("bash", "-c", blackholeDpv6Cmd)
62976297
out, _ = cmdRes.CombinedOutput()
6298-
t.Logf(string(out))
6298+
t.Log(string(out))
62996299
} else {
63006300
cmdRes := exec.Command("bash", "-c", allowDpv4Cmd)
63016301
out, _ := cmdRes.CombinedOutput()
6302-
t.Logf(string(out))
6302+
t.Log(string(out))
63036303
cmdRes = exec.Command("bash", "-c", allowDpv6Cmd)
63046304
out, _ = cmdRes.CombinedOutput()
6305-
t.Logf(string(out))
6305+
t.Log(string(out))
63066306
}
63076307
}
63086308

spanner/session_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func TestSessionLeak(t *testing.T) {
371371
if single.sh.stack == nil && !isMultiplexEnabled {
372372
t.Fatalf("Missing stacktrace from session handle")
373373
}
374-
stack := fmt.Sprintf("%s", single.sh.stack)
374+
stack := string(single.sh.stack)
375375
testMethod := "TestSessionLeak"
376376
if !strings.Contains(stack, testMethod) && !isMultiplexEnabled {
377377
t.Fatalf("Stacktrace does not contain '%s'\nGot: %s", testMethod, stack)

spanner/spannertest/integration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func makeClient(t *testing.T) (*spanner.Client, *dbadmin.DatabaseAdminClient, *v
107107
// Don't use SPANNER_EMULATOR_HOST because we need the raw connection for
108108
// the database admin client anyway.
109109

110-
t.Logf("Using in-memory fake Spanner DB")
110+
t.Log("Using in-memory fake Spanner DB")
111111
srv, err := NewServer("localhost:0")
112112
if err != nil {
113113
t.Fatalf("Starting in-memory fake: %v", err)

spanner/timestampbound.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func ReadTimestamp(t time.Time) TimestampBound {
174174
func (tb TimestampBound) String() string {
175175
switch tb.mode {
176176
case strong:
177-
return fmt.Sprintf("(strong)")
177+
return "(strong)"
178178
case exactStaleness:
179179
return fmt.Sprintf("(exactStaleness: %s)", tb.d)
180180
case maxStaleness:

0 commit comments

Comments
 (0)