mirror of
https://github.com/restic/restic.git
synced 2025-12-10 22:31:47 +00:00
get rid of fmt.Print* usages
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/feature"
|
||||
"github.com/restic/restic/internal/ui/table"
|
||||
@@ -39,7 +37,7 @@ Exit status is 1 if there was any error.
|
||||
return errors.Fatal("the feature command expects no arguments")
|
||||
}
|
||||
|
||||
fmt.Printf("All Feature Flags:\n")
|
||||
globalOptions.term.Print("All Feature Flags:\n")
|
||||
flags := feature.Flag.List()
|
||||
|
||||
tab := table.New()
|
||||
|
||||
@@ -24,7 +24,7 @@ Exit status is 1 if there was any error.
|
||||
GroupID: cmdGroupAdvanced,
|
||||
DisableAutoGenTag: true,
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Printf("All Extended Options:\n")
|
||||
globalOptions.term.Print("All Extended Options:")
|
||||
var maxLen int
|
||||
for _, opt := range options.List() {
|
||||
if l := len(opt.Namespace + "." + opt.Name); l > maxLen {
|
||||
@@ -32,7 +32,7 @@ Exit status is 1 if there was any error.
|
||||
}
|
||||
}
|
||||
for _, opt := range options.List() {
|
||||
fmt.Printf(" %*s %s\n", -maxLen, opt.Namespace+"."+opt.Name, opt.Text)
|
||||
globalOptions.term.Print(fmt.Sprintf(" %*s %s", -maxLen, opt.Namespace+"."+opt.Name, opt.Text))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -299,9 +299,7 @@ func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error {
|
||||
}
|
||||
|
||||
// Info
|
||||
if _, err := fmt.Fprintf(stdout, "snapshots"); err != nil {
|
||||
return err
|
||||
}
|
||||
header := "snapshots"
|
||||
var infoStrings []string
|
||||
if key.Hostname != "" {
|
||||
infoStrings = append(infoStrings, "host ["+key.Hostname+"]")
|
||||
@@ -313,12 +311,10 @@ func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error {
|
||||
infoStrings = append(infoStrings, "paths ["+strings.Join(key.Paths, ", ")+"]")
|
||||
}
|
||||
if infoStrings != nil {
|
||||
if _, err := fmt.Fprintf(stdout, " for (%s)", strings.Join(infoStrings, ", ")); err != nil {
|
||||
return err
|
||||
}
|
||||
header += " for (" + strings.Join(infoStrings, ", ") + ")"
|
||||
}
|
||||
_, err = fmt.Fprintf(stdout, ":\n")
|
||||
|
||||
header += ":\n"
|
||||
_, err = stdout.Write([]byte(header))
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ func TestFilterPatternsFile(t *testing.T) {
|
||||
|
||||
if match {
|
||||
c++
|
||||
// fmt.Printf("pattern %q, line %q\n", test.pattern, line)
|
||||
// t.Logf("pattern %q, line %q\n", test.pattern, line)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package restic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -73,7 +72,7 @@ func TestSymlinkSerialization(t *testing.T) {
|
||||
var n2 Node
|
||||
err = json.Unmarshal(ser, &n2)
|
||||
test.OK(t, err)
|
||||
fmt.Println(string(ser))
|
||||
t.Logf("serialized %q\n", string(ser))
|
||||
|
||||
test.Equals(t, n.LinkTarget, n2.LinkTarget)
|
||||
}
|
||||
|
||||
@@ -174,8 +174,7 @@ CwGc
|
||||
func GPGVerify(data, sig []byte) (ok bool, err error) {
|
||||
keyring, err := openpgp.ReadArmoredKeyRing(bytes.NewReader(key))
|
||||
if err != nil {
|
||||
fmt.Printf("reading keyring failed")
|
||||
return false, err
|
||||
return false, fmt.Errorf("reading keyring failed: %w", err)
|
||||
}
|
||||
|
||||
_, err = openpgp.CheckArmoredDetachedSignature(keyring, bytes.NewReader(data), bytes.NewReader(sig))
|
||||
|
||||
@@ -2,7 +2,6 @@ package walker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -32,9 +31,9 @@ func (t WritableTreeMap) SaveBlob(_ context.Context, tpe restic.BlobType, buf []
|
||||
return id, true, len(buf), nil
|
||||
}
|
||||
|
||||
func (t WritableTreeMap) Dump() {
|
||||
func (t WritableTreeMap) Dump(test testing.TB) {
|
||||
for k, v := range t.TreeMap {
|
||||
fmt.Printf("%v: %v", k, string(v))
|
||||
test.Logf("%v: %v", k, string(v))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,10 +293,10 @@ func TestRewriter(t *testing.T) {
|
||||
// verifying against the expected tree root also implicitly checks the structural integrity
|
||||
if newRoot != expRoot {
|
||||
t.Error("hash mismatch")
|
||||
fmt.Println("Got")
|
||||
modrepo.Dump()
|
||||
fmt.Println("Expected")
|
||||
WritableTreeMap{expRepo}.Dump()
|
||||
t.Log("Got")
|
||||
modrepo.Dump(t)
|
||||
t.Log("Expected")
|
||||
WritableTreeMap{expRepo}.Dump(t)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -348,10 +347,10 @@ func TestSnapshotSizeQuery(t *testing.T) {
|
||||
// verifying against the expected tree root also implicitly checks the structural integrity
|
||||
if newRoot != expRoot {
|
||||
t.Error("hash mismatch")
|
||||
fmt.Println("Got")
|
||||
modrepo.Dump()
|
||||
fmt.Println("Expected")
|
||||
WritableTreeMap{expRepo}.Dump()
|
||||
t.Log("Got")
|
||||
modrepo.Dump(t)
|
||||
t.Log("Expected")
|
||||
WritableTreeMap{expRepo}.Dump(t)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user