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