Skip to content

Commit

Permalink
chore: skip fmt.Fprint error
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Feb 24, 2025
1 parent 3424508 commit a5b9b57
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ var infoCmd = &cmds.Command{
}
tw := tabwriter.NewWriter(writer.w, 6, 6, 2, ' ', 0)
writer.Printf("Bandwidth:\n")
fmt.Fprintf(tw, "\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
fmt.Fprintf(tw, "\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
_, _ = fmt.Fprintf(tw, "\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
_, _ = fmt.Fprintf(tw, "\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
if err := tw.Flush(); err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/paych.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ var voucherListCmd = &cmds.Command{
if err != nil {
return err
}
fmt.Fprintf(buff, "Lane %d, Nonce %d: %s, voucher: %s\n", v.Lane, v.Nonce, v.Amount.String(), str)
_, _ = fmt.Fprintf(buff, "Lane %d, Nonce %d: %s, voucher: %s\n", v.Lane, v.Nonce, v.Amount.String(), str)
}

return re.Emit(buff)
Expand Down Expand Up @@ -362,7 +362,7 @@ var voucherBestSpendableCmd = &cmds.Command{
if err != nil {
return err
}
fmt.Fprintf(buff, "Lane %d, Nonce %d: %s, voucher: %s\n", v.Lane, v.Nonce, v.Amount.String(), str)
_, _ = fmt.Fprintf(buff, "Lane %d, Nonce %d: %s, voucher: %s\n", v.Lane, v.Nonce, v.Amount.String(), str)
}
return re.Emit(buff)
},
Expand Down Expand Up @@ -422,15 +422,15 @@ func paychStatus(writer io.Writer, avail *types.ChannelAvailableFunds) {
if avail.Channel == nil {
if avail.PendingWaitSentinel != nil {
fmt.Fprint(writer, "Creating channel\n")
fmt.Fprintf(writer, " From: %s\n", avail.From)
fmt.Fprintf(writer, " To: %s\n", avail.To)
fmt.Fprintf(writer, " Pending Amt: %s\n", types.FIL(avail.PendingAmt))
fmt.Fprintf(writer, " Wait Sentinel: %s\n", avail.PendingWaitSentinel)
_, _ = fmt.Fprintf(writer, " From: %s\n", avail.From)
_, _ = fmt.Fprintf(writer, " To: %s\n", avail.To)
_, _ = fmt.Fprintf(writer, " Pending Amt: %s\n", types.FIL(avail.PendingAmt))
_, _ = fmt.Fprintf(writer, " Wait Sentinel: %s\n", avail.PendingWaitSentinel)
return
}
fmt.Fprint(writer, "Channel does not exist\n")
fmt.Fprintf(writer, " From: %s\n", avail.From)
fmt.Fprintf(writer, " To: %s\n", avail.To)
_, _ = fmt.Fprintf(writer, " From: %s\n", avail.From)
_, _ = fmt.Fprintf(writer, " To: %s\n", avail.To)
return
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ var statsBandwidthCmd = &cmds.Command{

tw := tabwriter.NewWriter(buf, 4, 4, 2, ' ', 0)

fmt.Fprintf(tw, "Segment\tTotalIn\tTotalOut\tRateIn\tRateOut\n")
_, _ = fmt.Fprintf(tw, "Segment\tTotalIn\tTotalOut\tRateIn\tRateOut\n")

if bypeer {
bw, err := netAPI.NetBandwidthStatsByPeer(ctx)
Expand All @@ -401,7 +401,7 @@ var statsBandwidthCmd = &cmds.Command{

for _, p := range peers {
s := bw[p]
fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
_, _ = fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
}
} else if byproto {
bw, err := netAPI.NetBandwidthStatsByProtocol(ctx)
Expand All @@ -423,7 +423,7 @@ var statsBandwidthCmd = &cmds.Command{
if p == "" {
p = "<unknown>"
}
fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
_, _ = fmt.Fprintf(tw, "%s\t%s\t%s\t%s/s\t%s/s\n", p, humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
}
} else {

Expand All @@ -432,7 +432,7 @@ var statsBandwidthCmd = &cmds.Command{
return err
}

fmt.Fprintf(tw, "Total\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
_, _ = fmt.Fprintf(tw, "Total\t%s\t%s\t%s/s\t%s/s\n", humanize.Bytes(uint64(s.TotalIn)), humanize.Bytes(uint64(s.TotalOut)), humanize.Bytes(uint64(s.RateIn)), humanize.Bytes(uint64(s.RateOut)))
}

if err := tw.Flush(); err != nil {
Expand Down
22 changes: 11 additions & 11 deletions venus-devtool/api-gen/doc_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,32 +186,32 @@ curl http://<ip>:<port>/rpc/v{{ .APIVersion }} -X POST -H "Content-Type: applica
return g.Methods[i].Name < g.Methods[j].Name
})

fmt.Fprintf(buf, "* [%s](#%s)\n", g.GroupName, strings.ToLower(g.GroupName))
_, _ = fmt.Fprintf(buf, "* [%s](#%s)\n", g.GroupName, strings.ToLower(g.GroupName))
for _, method := range g.Methods {
fmt.Fprintf(buf, " * [%s](#%s)\n", method.Name, strings.ToLower(method.Name))
_, _ = fmt.Fprintf(buf, " * [%s](#%s)\n", method.Name, strings.ToLower(method.Name))
}
}

fmt.Fprintf(buf, "\n")
_, _ = fmt.Fprintf(buf, "\n")
for _, g := range groups {
fmt.Fprintf(buf, "## %s\n\n", g.GroupName)
_, _ = fmt.Fprintf(buf, "## %s\n\n", g.GroupName)

for _, m := range g.Methods {
fmt.Fprintf(buf, "### %s\n", m.Name)
fmt.Fprintf(buf, "%s\n\n", m.Comment)
_, _ = fmt.Fprintf(buf, "### %s\n", m.Name)
_, _ = fmt.Fprintf(buf, "%s\n\n", m.Comment)

fmt.Fprintf(buf, "Perms: %s\n\n", m.Perm)
_, _ = fmt.Fprintf(buf, "Perms: %s\n\n", m.Perm)

if strings.Count(m.InputExample, "\n") > 0 {
fmt.Fprintf(buf, "Inputs:\n```json\n%s\n```\n\n", m.InputExample)
_, _ = fmt.Fprintf(buf, "Inputs:\n```json\n%s\n```\n\n", m.InputExample)
} else {
fmt.Fprintf(buf, "Inputs: `%s`\n\n", m.InputExample)
_, _ = fmt.Fprintf(buf, "Inputs: `%s`\n\n", m.InputExample)
}

if strings.Count(m.ResponseExample, "\n") > 0 {
fmt.Fprintf(buf, "Response:\n```json\n%s\n```\n\n", m.ResponseExample)
_, _ = fmt.Fprintf(buf, "Response:\n```json\n%s\n```\n\n", m.ResponseExample)
} else {
fmt.Fprintf(buf, "Response: `%s`\n\n", m.ResponseExample)
_, _ = fmt.Fprintf(buf, "Response: `%s`\n\n", m.ResponseExample)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion venus-devtool/api-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
app.Setup()

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
_, _ = fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
}
}

Expand Down
10 changes: 5 additions & 5 deletions venus-devtool/api-gen/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GenProxyForAPI(t util.APIMeta) error {

var fileBuffer bytes.Buffer

fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/api-gen. DO NOT EDIT.\npackage %s\n\n", api.Pkg.Name)
_, _ = fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/api-gen. DO NOT EDIT.\npackage %s\n\n", api.Pkg.Name)

err = writeImports(deps, &fileBuffer)
if err != nil {
Expand Down Expand Up @@ -147,18 +147,18 @@ type %s struct {
)

func writeStruct(dst *bytes.Buffer, ifaceMeta *util.InterfaceMeta, astMeta *util.ASTMeta) error {
fmt.Fprintf(dst, structHeadFormat, common.StructName(ifaceMeta.Name))
_, _ = fmt.Fprintf(dst, structHeadFormat, common.StructName(ifaceMeta.Name))

for _, nested := range ifaceMeta.Nested {
fmt.Fprintf(dst, "\t%s\n", common.StructName(nested))
_, _ = fmt.Fprintf(dst, "\t%s\n", common.StructName(nested))
}

tmpBuf := &bytes.Buffer{}
if len(ifaceMeta.Defined) > 0 {
fmt.Fprint(dst, structInternalHead)

for _, meth := range ifaceMeta.Defined {
fmt.Fprintf(dst, "\t\t%s ", meth.Name)
_, _ = fmt.Fprintf(dst, "\t\t%s ", meth.Name)

err := printer.Fprint(tmpBuf, astMeta.FileSet, meth.FuncType)
if err != nil {
Expand Down Expand Up @@ -325,6 +325,6 @@ func writeMethodBody(dst *bytes.Buffer, typBuf *bytes.Buffer, ifaceMeta *util.In
}

sname := common.StructName(ifaceMeta.Name)
fmt.Fprintf(dst, "func(s *%s) %s(%s) (%s) { return s.Internal.%s(%s) }\n", sname, methMeta.Name, strings.Join(params, ", "), strings.Join(results, ", "), methMeta.Name, strings.Join(callNames, ", "))
_, _ = fmt.Fprintf(dst, "func(s *%s) %s(%s) (%s) { return s.Internal.%s(%s) }\n", sname, methMeta.Name, strings.Join(params, ", "), strings.Join(results, ", "), methMeta.Name, strings.Join(callNames, ", "))
return nil
}
2 changes: 1 addition & 1 deletion venus-devtool/bundle-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
app.Setup()

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
_, _ = fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
}
}

Expand Down
2 changes: 1 addition & 1 deletion venus-devtool/compatible/actors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
app.Setup()

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
_, _ = fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
}
}

Expand Down
4 changes: 2 additions & 2 deletions venus-devtool/compatible/apis/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ var checksumCmd = &cli.Command{

for ii := 0; ii < numIn; ii++ {
inTyp := meth.Type.In(ii)
fmt.Fprintf(&buf, "\tIn: %s\n", formatType(inTyp)) // nolint
_, _ = fmt.Fprintf(&buf, "\tIn: %s\n", formatType(inTyp)) // nolint
}

for oi := 0; oi < numOut; oi++ {
outTyp := meth.Type.Out(oi)
fmt.Fprintf(&buf, "\tOut: %s\n", formatType(outTyp)) // nolint
_, _ = fmt.Fprintf(&buf, "\tOut: %s\n", formatType(outTyp)) // nolint
}

fmt.Printf("\t%s:\tIn=%d,\tOut=%d,\tCheckSum=%x\n", meth.Name, numIn, numOut, md5.Sum(buf.Bytes()))
Expand Down
2 changes: 1 addition & 1 deletion venus-devtool/compatible/apis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ func main() {
app.Setup()

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
_, _ = fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
}
}
18 changes: 9 additions & 9 deletions venus-devtool/state-type-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
app.Setup()

if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
_, _ = fmt.Fprintf(os.Stderr, "ERR: %v\n", err) // nolint: errcheck
}
}

Expand Down Expand Up @@ -312,11 +312,11 @@ func outputFile(dst string, opt outputOpt, pkgInfos []*pkgInfo, fopt option) err
for _, pi := range pkgInfos {
for _, fi := range pi.files {
var fileBuffer bytes.Buffer
fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/state-type-gen. DO NOT EDIT.\npackage %s\n\n", "types")
_, _ = fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/state-type-gen. DO NOT EDIT.\npackage %s\n\n", "types")

// write import
fmt.Fprintln(&fileBuffer, "import (")
fmt.Fprintf(&fileBuffer, "\"%v\"\n", pi.path)
_, _ = fmt.Fprintf(&fileBuffer, "\"%v\"\n", pi.path)
fmt.Fprintln(&fileBuffer, ")\n")

genFileDetail(&fileBuffer, fi, pi.name, fopt)
Expand All @@ -337,12 +337,12 @@ func outputFile(dst string, opt outputOpt, pkgInfos []*pkgInfo, fopt option) err

func writePkgInfo(dst string, pkgInfos []*pkgInfo, fopt option) error {
var fileBuffer bytes.Buffer
fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/state-type-gen. DO NOT EDIT.\npackage %s\n\n", "types")
_, _ = fmt.Fprintf(&fileBuffer, "// Code generated by github.com/filecoin-project/venus/venus-devtool/state-type-gen. DO NOT EDIT.\npackage %s\n\n", "types")

// write import
fmt.Fprintln(&fileBuffer, "import (")
for _, info := range pkgInfos {
fmt.Fprintf(&fileBuffer, "\"%v\"\n", info.path)
_, _ = fmt.Fprintf(&fileBuffer, "\"%v\"\n", info.path)
}
fmt.Fprintln(&fileBuffer, ")\n")

Expand All @@ -355,7 +355,7 @@ func writePkgInfo(dst string, pkgInfos []*pkgInfo, fopt option) error {
merge.v = append(merge.v, fi.v...)
}
merge.sort()
fmt.Fprintf(&fileBuffer, "////////// %s //////////\n\n", pi.name)
_, _ = fmt.Fprintf(&fileBuffer, "////////// %s //////////\n\n", pi.name)
genFileDetail(&fileBuffer, &merge, pi.name, fopt)
fmt.Fprintln(&fileBuffer, "\n")
}
Expand All @@ -380,16 +380,16 @@ func genDetail(buf *bytes.Buffer, list []string, typ string, pkgName string, opt
if len(list) == 0 {
return
}
fmt.Fprintf(buf, "%s (\n", typ)
_, _ = fmt.Fprintf(buf, "%s (\n", typ)
for _, one := range list {
if vals, ok := opt.aliasStructs[one]; ok {
for _, val := range vals {
if val.pkgName == pkgName {
fmt.Fprintf(buf, "\t%s = %s.%s\n", val.newName, pkgName, one)
_, _ = fmt.Fprintf(buf, "\t%s = %s.%s\n", val.newName, pkgName, one)
}
}
} else {
fmt.Fprintf(buf, "\t%s = %s.%s\n", one, pkgName, one)
_, _ = fmt.Fprintf(buf, "\t%s = %s.%s\n", one, pkgName, one)
}
}
fmt.Fprintln(buf, ")")
Expand Down
2 changes: 1 addition & 1 deletion venus-shared/actors/types/bigint_fil.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (f FIL) Nano() string {
func (f FIL) Format(s fmt.State, ch rune) {
switch ch {
case 's', 'v':
fmt.Fprint(s, f.String())
_, _ = fmt.Fprint(s, f.String())
default:
f.Int.Format(s, ch)
}
Expand Down

0 comments on commit a5b9b57

Please sign in to comment.