Skip to content

Commit

Permalink
all: fix printf(var) mistakes detected by latest printf checker
Browse files Browse the repository at this point in the history
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 <taking@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
dmitshur authored and gopherbot committed Sep 4, 2024
1 parent 1e3e9fd commit 20097e4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion collate/build/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func newBuilder(t *testing.T, ducet []ducetElem) *Builder {
ces = append(ces, ce.w)
}
if err := b.Add([]rune(e.str), ces, nil); err != nil {
t.Errorf(err.Error())
t.Error(err)
}
}
b.t = &table{}
Expand Down
2 changes: 1 addition & 1 deletion collate/build/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func makeTestTrie(t *testing.T) trie {
idx.addTrie(n)
tr, err := idx.generate()
if err != nil {
t.Errorf(err.Error())
t.Error(err)
}
return *tr
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cldrtree/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func generate(b *Builder, t *Tree, w *gen.CodeWriter) error {

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

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

// Generate enum types.
Expand Down
3 changes: 1 addition & 2 deletions internal/gen/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ func (w *CodeWriter) writeSlice(x interface{}, isArray bool) {
if !reflect.DeepEqual(zero, x) {
line := fmt.Sprintf("%#v,\n", x)
line = line[strings.IndexByte(line, '{'):]
w.printf("%d: ", i)
w.printf(line)
w.printf("%d: %s", i, line)
}
}
case reflect.Array:
Expand Down

0 comments on commit 20097e4

Please # to comment.