Skip to content

Commit

Permalink
all: fix printf(var) mistake detected by latest printf checker
Browse files Browse the repository at this point in the history
For golang/go#69267.

Change-Id: I050c167e2e3ce36541e0d71469fb3f5778f5a882
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/610517
Reviewed-by: Ian Lance Taylor <[email protected]>
kokoro-CI: kokoro <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
timothy-king committed Sep 5, 2024
1 parent 0709f9d commit 6b577b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions cmd/pkgsite/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ func main() {
if *useProxy {
url := os.Getenv("GOPROXY")
if url == "" {
die("GOPROXY environment variable is not set")
dief("GOPROXY environment variable is not set")
}
var err error
serverCfg.Proxy, err = proxy.New(url, nil)
if err != nil {
die("connecting to proxy: %s", err)
dief("connecting to proxy: %s", err)
}
}

Expand All @@ -122,7 +122,7 @@ func main() {
ctx := context.Background()
server, err := pkgsite.BuildServer(ctx, serverCfg)
if err != nil {
die(err.Error())
dief("%s", err)
}

addr := *httpAddr
Expand All @@ -132,7 +132,7 @@ func main() {

ln, err := net.Listen("tcp", addr)
if err != nil {
die(err.Error())
dief("%s", err)
}

url := "http://" + addr
Expand All @@ -150,10 +150,10 @@ func main() {
server.Install(router.Handle, nil, nil)
mw := timeout.Timeout(54 * time.Second)
srv := &http.Server{Addr: addr, Handler: mw(router)}
die("%v", srv.Serve(ln))
dief("%v", srv.Serve(ln))
}

func die(format string, args ...any) {
func dief(format string, args ...any) {
fmt.Fprintf(os.Stderr, format, args...)
fmt.Fprintln(os.Stderr)
os.Exit(1)
Expand Down
3 changes: 2 additions & 1 deletion internal/frontend/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package client

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (c *Client) fetchJSONPage(url string) (_ []byte, err error) {
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
return nil, fmt.Errorf(r.Status)
return nil, errors.New(r.Status)
}
body, err := io.ReadAll(r.Body)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/symbol/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (w *Walker) loadImports(pkgPath string) {
// except we also check if a field is Embedded. If so, we ignore that field.
func (w *Walker) emitStructType(name string, typ *types.Struct) {
typeStruct := fmt.Sprintf("type %s struct", name)
w.emitf(typeStruct)
w.emitf("%s", typeStruct)
defer w.pushScope(typeStruct)()
for i := 0; i < typ.NumFields(); i++ {
f := typ.Field(i)
Expand All @@ -312,8 +312,8 @@ func (w *Walker) emitStructType(name string, typ *types.Struct) {
// https://go.googlesource.com/go/+/refs/tags/go1.16.6/src/cmd/api/goapi.go#931,
// except we don't check for unexported methods.
func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
typeInterface := fmt.Sprintf("type " + name + " interface")
w.emitf(typeInterface)
typeInterface := fmt.Sprintf("type %s interface", name)
w.emitf("%s", typeInterface)
pop := w.pushScope(typeInterface)

var methodNames []string
Expand Down

0 comments on commit 6b577b4

Please sign in to comment.