Skip to content

Commit 20097e4

Browse files
dmitshurgopherbot
authored andcommitted
all: fix printf(var) mistakes detected by latest printf checker
The CodeWriter.WriteComment method is odd. It calls fmt.Sprintf on its arguments so the caller doesn't need to, but isn't named something like WriteCommentf as I'd expect. I tried renaming it, but it became a bigger change than I wanted. Leaving that for a future CL - this one just fixes clear mistakes to fix the build. For golang/go#69267. Change-Id: Ifba42d4512696194fbf21d6c8d3da76440b1ce9e Reviewed-on: https://go-review.googlesource.com/c/text/+/610676 Reviewed-by: Tim King <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1e3e9fd commit 20097e4

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

collate/build/builder_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func newBuilder(t *testing.T, ducet []ducetElem) *Builder {
6565
ces = append(ces, ce.w)
6666
}
6767
if err := b.Add([]rune(e.str), ces, nil); err != nil {
68-
t.Errorf(err.Error())
68+
t.Error(err)
6969
}
7070
}
7171
b.t = &table{}

collate/build/trie_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func makeTestTrie(t *testing.T) trie {
2929
idx.addTrie(n)
3030
tr, err := idx.generate()
3131
if err != nil {
32-
t.Errorf(err.Error())
32+
t.Error(err)
3333
}
3434
return *tr
3535
}

internal/cldrtree/generate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func generate(b *Builder, t *Tree, w *gen.CodeWriter) error {
2121

2222
fmt.Fprintf(w, "var tree = &cldrtree.Tree{locales, indices, buckets}\n\n")
2323

24-
w.WriteComment("Path values:\n" + b.stats())
24+
w.WriteComment("Path values:\n%s", b.stats())
2525
fmt.Fprintln(w)
2626

2727
// Generate enum types.

internal/gen/code.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ func (w *CodeWriter) writeSlice(x interface{}, isArray bool) {
342342
if !reflect.DeepEqual(zero, x) {
343343
line := fmt.Sprintf("%#v,\n", x)
344344
line = line[strings.IndexByte(line, '{'):]
345-
w.printf("%d: ", i)
346-
w.printf(line)
345+
w.printf("%d: %s", i, line)
347346
}
348347
}
349348
case reflect.Array:

0 commit comments

Comments
 (0)