From 444a268ce023284edf1adf521c01b31e2dd4537b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 21 Aug 2016 17:46:23 +0200 Subject: [PATCH] Replace stdlib errors with github.com/pkg/errors --- src/cmds/restic/cmd_backup.go | 3 ++- src/cmds/restic/cmd_cat.go | 3 ++- src/cmds/restic/cmd_check.go | 3 ++- src/cmds/restic/cmd_dump.go | 2 ++ src/cmds/restic/cmd_init.go | 2 +- src/cmds/restic/cmd_key.go | 3 ++- src/cmds/restic/cmd_list.go | 3 ++- src/cmds/restic/cmd_restore.go | 3 ++- src/cmds/restic/global.go | 3 ++- src/cmds/restic/main.go | 3 ++- src/restic/archiver.go | 3 ++- src/restic/archiver_duplication_test.go | 3 ++- src/restic/backend/generic.go | 2 +- src/restic/backend/handle.go | 3 ++- src/restic/backend/id.go | 3 ++- src/restic/backend/local/config.go | 3 ++- src/restic/backend/local/local.go | 3 ++- src/restic/backend/mem/mem_backend.go | 3 ++- src/restic/backend/mem/mem_backend_test.go | 2 +- src/restic/backend/mock_backend.go | 2 +- src/restic/backend/rest/config.go | 3 ++- src/restic/backend/rest/rest.go | 3 ++- src/restic/backend/rest/rest_test.go | 3 ++- src/restic/backend/s3/config.go | 3 ++- src/restic/backend/s3/s3.go | 3 ++- src/restic/backend/s3/s3_test.go | 3 ++- src/restic/backend/sftp/config.go | 3 ++- src/restic/backend/sftp/sftp.go | 3 ++- src/restic/backend/test/tests_test.go | 2 +- src/restic/cache.go | 3 ++- src/restic/checker/checker.go | 2 ++ src/restic/crypto/crypto.go | 3 ++- src/restic/filter/filter.go | 3 ++- src/restic/fuse/file.go | 3 ++- src/restic/fuse/file_test.go | 3 ++- src/restic/fuse/link.go | 5 +++-- src/restic/index/index.go | 3 ++- src/restic/node_windows.go | 3 ++- src/restic/pack/pack.go | 3 ++- src/restic/pipe/pipe.go | 3 ++- src/restic/repository/config.go | 3 ++- src/restic/repository/index.go | 3 ++- src/restic/repository/key.go | 3 ++- src/restic/repository/parallel_test.go | 3 ++- src/restic/repository/repository.go | 3 ++- src/restic/snapshot.go | 3 ++- src/restic/tree.go | 3 ++- src/restic/worker/pool_test.go | 3 ++- 48 files changed, 92 insertions(+), 47 deletions(-) diff --git a/src/cmds/restic/cmd_backup.go b/src/cmds/restic/cmd_backup.go index b5c567de6..9efb27203 100644 --- a/src/cmds/restic/cmd_backup.go +++ b/src/cmds/restic/cmd_backup.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "errors" "fmt" "os" "path/filepath" @@ -14,6 +13,8 @@ import ( "strings" "time" + "github.com/pkg/errors" + "golang.org/x/crypto/ssh/terminal" ) diff --git a/src/cmds/restic/cmd_cat.go b/src/cmds/restic/cmd_cat.go index 959dfabd3..f8a96772c 100644 --- a/src/cmds/restic/cmd_cat.go +++ b/src/cmds/restic/cmd_cat.go @@ -2,10 +2,11 @@ package main import ( "encoding/json" - "errors" "fmt" "os" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/debug" diff --git a/src/cmds/restic/cmd_check.go b/src/cmds/restic/cmd_check.go index 9bcd27917..cbb79f8c4 100644 --- a/src/cmds/restic/cmd_check.go +++ b/src/cmds/restic/cmd_check.go @@ -1,11 +1,12 @@ package main import ( - "errors" "fmt" "os" "time" + "github.com/pkg/errors" + "golang.org/x/crypto/ssh/terminal" "restic" diff --git a/src/cmds/restic/cmd_dump.go b/src/cmds/restic/cmd_dump.go index dc25f37bc..31ed114aa 100644 --- a/src/cmds/restic/cmd_dump.go +++ b/src/cmds/restic/cmd_dump.go @@ -8,6 +8,8 @@ import ( "io" "os" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/pack" diff --git a/src/cmds/restic/cmd_init.go b/src/cmds/restic/cmd_init.go index 887d34166..4bfc4a5c0 100644 --- a/src/cmds/restic/cmd_init.go +++ b/src/cmds/restic/cmd_init.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "github.com/pkg/errors" "restic/repository" ) diff --git a/src/cmds/restic/cmd_key.go b/src/cmds/restic/cmd_key.go index 46e5b6bfd..42f0ee6a7 100644 --- a/src/cmds/restic/cmd_key.go +++ b/src/cmds/restic/cmd_key.go @@ -1,9 +1,10 @@ package main import ( - "errors" "fmt" + "github.com/pkg/errors" + "restic/backend" "restic/repository" ) diff --git a/src/cmds/restic/cmd_list.go b/src/cmds/restic/cmd_list.go index 3bfb5af9f..57310b6f0 100644 --- a/src/cmds/restic/cmd_list.go +++ b/src/cmds/restic/cmd_list.go @@ -1,9 +1,10 @@ package main import ( - "errors" "fmt" + "github.com/pkg/errors" + "restic/backend" ) diff --git a/src/cmds/restic/cmd_restore.go b/src/cmds/restic/cmd_restore.go index 97b77ec1b..84a9a9b08 100644 --- a/src/cmds/restic/cmd_restore.go +++ b/src/cmds/restic/cmd_restore.go @@ -1,9 +1,10 @@ package main import ( - "errors" "fmt" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/debug" diff --git a/src/cmds/restic/global.go b/src/cmds/restic/global.go index 511628a45..c16263cbb 100644 --- a/src/cmds/restic/global.go +++ b/src/cmds/restic/global.go @@ -1,7 +1,6 @@ package main import ( - "errors" "fmt" "io" "os" @@ -9,6 +8,8 @@ import ( "strings" "syscall" + "github.com/pkg/errors" + "restic/backend" "restic/backend/local" "restic/backend/rest" diff --git a/src/cmds/restic/main.go b/src/cmds/restic/main.go index 19d81e774..f9a4ec808 100644 --- a/src/cmds/restic/main.go +++ b/src/cmds/restic/main.go @@ -2,11 +2,12 @@ package main import ( "fmt" - "github.com/jessevdk/go-flags" "os" "restic" "restic/debug" "runtime" + + "github.com/jessevdk/go-flags" ) func init() { diff --git a/src/restic/archiver.go b/src/restic/archiver.go index cf245d2b0..ae062a7f6 100644 --- a/src/restic/archiver.go +++ b/src/restic/archiver.go @@ -2,7 +2,6 @@ package restic import ( "encoding/json" - "errors" "fmt" "io" "os" @@ -11,6 +10,8 @@ import ( "sync" "time" + "github.com/pkg/errors" + "restic/backend" "restic/debug" "restic/fs" diff --git a/src/restic/archiver_duplication_test.go b/src/restic/archiver_duplication_test.go index 56341a997..61f7aafb9 100644 --- a/src/restic/archiver_duplication_test.go +++ b/src/restic/archiver_duplication_test.go @@ -2,13 +2,14 @@ package restic_test import ( "crypto/rand" - "errors" "io" mrand "math/rand" "sync" "testing" "time" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/pack" diff --git a/src/restic/backend/generic.go b/src/restic/backend/generic.go index c528f8998..7510ad0fe 100644 --- a/src/restic/backend/generic.go +++ b/src/restic/backend/generic.go @@ -1,6 +1,6 @@ package backend -import "errors" +import "github.com/pkg/errors" // ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix // could be found. diff --git a/src/restic/backend/handle.go b/src/restic/backend/handle.go index 6bdf6af23..62ff00b01 100644 --- a/src/restic/backend/handle.go +++ b/src/restic/backend/handle.go @@ -1,8 +1,9 @@ package backend import ( - "errors" "fmt" + + "github.com/pkg/errors" ) // Handle is used to store and access data in a backend. diff --git a/src/restic/backend/id.go b/src/restic/backend/id.go index 115792707..a37e0edea 100644 --- a/src/restic/backend/id.go +++ b/src/restic/backend/id.go @@ -5,7 +5,8 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" - "errors" + + "github.com/pkg/errors" ) // Hash returns the ID for data. diff --git a/src/restic/backend/local/config.go b/src/restic/backend/local/config.go index 456f3c428..a430f9dec 100644 --- a/src/restic/backend/local/config.go +++ b/src/restic/backend/local/config.go @@ -1,8 +1,9 @@ package local import ( - "errors" "strings" + + "github.com/pkg/errors" ) // ParseConfig parses a local backend config. diff --git a/src/restic/backend/local/local.go b/src/restic/backend/local/local.go index 9a85f7a5b..d6b02a0b5 100644 --- a/src/restic/backend/local/local.go +++ b/src/restic/backend/local/local.go @@ -1,13 +1,14 @@ package local import ( - "errors" "fmt" "io" "io/ioutil" "os" "path/filepath" + "github.com/pkg/errors" + "restic/backend" "restic/debug" "restic/fs" diff --git a/src/restic/backend/mem/mem_backend.go b/src/restic/backend/mem/mem_backend.go index 5682d4915..239e2c899 100644 --- a/src/restic/backend/mem/mem_backend.go +++ b/src/restic/backend/mem/mem_backend.go @@ -1,10 +1,11 @@ package mem import ( - "errors" "io" "sync" + "github.com/pkg/errors" + "restic/backend" "restic/debug" ) diff --git a/src/restic/backend/mem/mem_backend_test.go b/src/restic/backend/mem/mem_backend_test.go index a65cdc246..cde3bda1c 100644 --- a/src/restic/backend/mem/mem_backend_test.go +++ b/src/restic/backend/mem/mem_backend_test.go @@ -1,7 +1,7 @@ package mem_test import ( - "errors" + "github.com/pkg/errors" "restic/backend" "restic/backend/mem" diff --git a/src/restic/backend/mock_backend.go b/src/restic/backend/mock_backend.go index 921af4d6c..70429acfd 100644 --- a/src/restic/backend/mock_backend.go +++ b/src/restic/backend/mock_backend.go @@ -1,6 +1,6 @@ package backend -import "errors" +import "github.com/pkg/errors" // MockBackend implements a backend whose functions can be specified. This // should only be used for tests. diff --git a/src/restic/backend/rest/config.go b/src/restic/backend/rest/config.go index c4459344c..61a73144a 100644 --- a/src/restic/backend/rest/config.go +++ b/src/restic/backend/rest/config.go @@ -1,9 +1,10 @@ package rest import ( - "errors" "net/url" "strings" + + "github.com/pkg/errors" ) // Config contains all configuration necessary to connect to a REST server. diff --git a/src/restic/backend/rest/rest.go b/src/restic/backend/rest/rest.go index 125331d78..5894d75a2 100644 --- a/src/restic/backend/rest/rest.go +++ b/src/restic/backend/rest/rest.go @@ -3,7 +3,6 @@ package rest import ( "bytes" "encoding/json" - "errors" "fmt" "io" "net/http" @@ -11,6 +10,8 @@ import ( "path" "strings" + "github.com/pkg/errors" + "restic/backend" ) diff --git a/src/restic/backend/rest/rest_test.go b/src/restic/backend/rest/rest_test.go index bbcfff9b0..4e77cf612 100644 --- a/src/restic/backend/rest/rest_test.go +++ b/src/restic/backend/rest/rest_test.go @@ -1,11 +1,12 @@ package rest_test import ( - "errors" "fmt" "net/url" "os" + "github.com/pkg/errors" + "restic/backend" "restic/backend/rest" "restic/backend/test" diff --git a/src/restic/backend/s3/config.go b/src/restic/backend/s3/config.go index 5cd74ce79..70991363d 100644 --- a/src/restic/backend/s3/config.go +++ b/src/restic/backend/s3/config.go @@ -1,10 +1,11 @@ package s3 import ( - "errors" "net/url" "path" "strings" + + "github.com/pkg/errors" ) // Config contains all configuration necessary to connect to an s3 compatible diff --git a/src/restic/backend/s3/s3.go b/src/restic/backend/s3/s3.go index c4e1aae54..ff3ff627d 100644 --- a/src/restic/backend/s3/s3.go +++ b/src/restic/backend/s3/s3.go @@ -2,10 +2,11 @@ package s3 import ( "bytes" - "errors" "io" "strings" + "github.com/pkg/errors" + "github.com/minio/minio-go" "restic/backend" diff --git a/src/restic/backend/s3/s3_test.go b/src/restic/backend/s3/s3_test.go index 586398de9..6fd9c3bf6 100644 --- a/src/restic/backend/s3/s3_test.go +++ b/src/restic/backend/s3/s3_test.go @@ -1,11 +1,12 @@ package s3_test import ( - "errors" "fmt" "net/url" "os" + "github.com/pkg/errors" + "restic/backend" "restic/backend/s3" "restic/backend/test" diff --git a/src/restic/backend/sftp/config.go b/src/restic/backend/sftp/config.go index e6dfd0d27..942efc3e1 100644 --- a/src/restic/backend/sftp/config.go +++ b/src/restic/backend/sftp/config.go @@ -1,11 +1,12 @@ package sftp import ( - "errors" "fmt" "net/url" "path" "strings" + + "github.com/pkg/errors" ) // Config collects all information required to connect to an sftp server. diff --git a/src/restic/backend/sftp/sftp.go b/src/restic/backend/sftp/sftp.go index 577f5bbb2..e023bf1be 100644 --- a/src/restic/backend/sftp/sftp.go +++ b/src/restic/backend/sftp/sftp.go @@ -4,7 +4,6 @@ import ( "bufio" "crypto/rand" "encoding/hex" - "errors" "fmt" "io" "os" @@ -13,6 +12,8 @@ import ( "strings" "time" + "github.com/pkg/errors" + "restic/backend" "restic/debug" diff --git a/src/restic/backend/test/tests_test.go b/src/restic/backend/test/tests_test.go index 1674f1f5e..5dbba88a4 100644 --- a/src/restic/backend/test/tests_test.go +++ b/src/restic/backend/test/tests_test.go @@ -1,7 +1,7 @@ package test_test import ( - "errors" + "github.com/pkg/errors" "restic/backend" "restic/backend/mem" diff --git a/src/restic/cache.go b/src/restic/cache.go index e4b8507ca..1060c0a4d 100644 --- a/src/restic/cache.go +++ b/src/restic/cache.go @@ -1,7 +1,6 @@ package restic import ( - "errors" "fmt" "io" "os" @@ -9,6 +8,8 @@ import ( "runtime" "strings" + "github.com/pkg/errors" + "restic/backend" "restic/debug" "restic/fs" diff --git a/src/restic/checker/checker.go b/src/restic/checker/checker.go index fc15b35fd..9a3a518d5 100644 --- a/src/restic/checker/checker.go +++ b/src/restic/checker/checker.go @@ -6,6 +6,8 @@ import ( "fmt" "sync" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/crypto" diff --git a/src/restic/crypto/crypto.go b/src/restic/crypto/crypto.go index 17cfa3097..71bf8c15c 100644 --- a/src/restic/crypto/crypto.go +++ b/src/restic/crypto/crypto.go @@ -5,9 +5,10 @@ import ( "crypto/cipher" "crypto/rand" "encoding/json" - "errors" "fmt" + "github.com/pkg/errors" + "golang.org/x/crypto/poly1305" ) diff --git a/src/restic/filter/filter.go b/src/restic/filter/filter.go index 7105a76a0..ccef3a6f6 100644 --- a/src/restic/filter/filter.go +++ b/src/restic/filter/filter.go @@ -1,9 +1,10 @@ package filter import ( - "errors" "path/filepath" "strings" + + "github.com/pkg/errors" ) // ErrBadString is returned when Match is called with the empty string as the diff --git a/src/restic/fuse/file.go b/src/restic/fuse/file.go index ef6766d9e..f6dfa771e 100644 --- a/src/restic/fuse/file.go +++ b/src/restic/fuse/file.go @@ -4,9 +4,10 @@ package fuse import ( - "errors" "sync" + "github.com/pkg/errors" + "restic" "restic/backend" "restic/debug" diff --git a/src/restic/fuse/file_test.go b/src/restic/fuse/file_test.go index 12bcb8598..cb1c67452 100644 --- a/src/restic/fuse/file_test.go +++ b/src/restic/fuse/file_test.go @@ -5,11 +5,12 @@ package fuse import ( "bytes" - "errors" "math/rand" "testing" "time" + "github.com/pkg/errors" + "bazil.org/fuse" "restic" diff --git a/src/restic/fuse/link.go b/src/restic/fuse/link.go index 1cf02df0f..732446a7a 100644 --- a/src/restic/fuse/link.go +++ b/src/restic/fuse/link.go @@ -4,11 +4,12 @@ package fuse import ( + "restic" + "restic/repository" + "bazil.org/fuse" "bazil.org/fuse/fs" "golang.org/x/net/context" - "restic" - "restic/repository" ) // Statically ensure that *file implements the given interface diff --git a/src/restic/index/index.go b/src/restic/index/index.go index 0d2d70397..e2fa2e216 100644 --- a/src/restic/index/index.go +++ b/src/restic/index/index.go @@ -2,7 +2,6 @@ package index import ( - "errors" "fmt" "os" "restic" @@ -12,6 +11,8 @@ import ( "restic/pack" "restic/types" "restic/worker" + + "github.com/pkg/errors" ) // Pack contains information about the contents of a pack. diff --git a/src/restic/node_windows.go b/src/restic/node_windows.go index c238cf87c..08a7f86a2 100644 --- a/src/restic/node_windows.go +++ b/src/restic/node_windows.go @@ -1,8 +1,9 @@ package restic import ( - "errors" "syscall" + + "github.com/pkg/errors" ) // mknod() creates a filesystem node (file, device diff --git a/src/restic/pack/pack.go b/src/restic/pack/pack.go index 4ffbf4d70..d29081827 100644 --- a/src/restic/pack/pack.go +++ b/src/restic/pack/pack.go @@ -3,11 +3,12 @@ package pack import ( "bytes" "encoding/binary" - "errors" "fmt" "io" "sync" + "github.com/pkg/errors" + "restic/backend" "restic/crypto" ) diff --git a/src/restic/pipe/pipe.go b/src/restic/pipe/pipe.go index 92343f545..78562f0fd 100644 --- a/src/restic/pipe/pipe.go +++ b/src/restic/pipe/pipe.go @@ -1,12 +1,13 @@ package pipe import ( - "errors" "fmt" "os" "path/filepath" "sort" + "github.com/pkg/errors" + "restic/debug" "restic/fs" ) diff --git a/src/restic/repository/config.go b/src/restic/repository/config.go index 46f739d35..df7fd2b73 100644 --- a/src/restic/repository/config.go +++ b/src/restic/repository/config.go @@ -4,10 +4,11 @@ import ( "crypto/rand" "crypto/sha256" "encoding/hex" - "errors" "io" "testing" + "github.com/pkg/errors" + "restic/backend" "restic/debug" diff --git a/src/restic/repository/index.go b/src/restic/repository/index.go index 86968ba1d..bdf70c351 100644 --- a/src/restic/repository/index.go +++ b/src/restic/repository/index.go @@ -3,12 +3,13 @@ package repository import ( "bytes" "encoding/json" - "errors" "fmt" "io" "sync" "time" + "github.com/pkg/errors" + "restic/backend" "restic/crypto" "restic/debug" diff --git a/src/restic/repository/key.go b/src/restic/repository/key.go index 2599f6e2e..3ef78e6b2 100644 --- a/src/restic/repository/key.go +++ b/src/restic/repository/key.go @@ -2,12 +2,13 @@ package repository import ( "encoding/json" - "errors" "fmt" "os" "os/user" "time" + "github.com/pkg/errors" + "restic/backend" "restic/crypto" "restic/debug" diff --git a/src/restic/repository/parallel_test.go b/src/restic/repository/parallel_test.go index dfcce0a15..6aab24b0e 100644 --- a/src/restic/repository/parallel_test.go +++ b/src/restic/repository/parallel_test.go @@ -1,11 +1,12 @@ package repository_test import ( - "errors" "math/rand" "testing" "time" + "github.com/pkg/errors" + "restic/backend" "restic/repository" . "restic/test" diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index 8949b813f..eaa7e530c 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -3,11 +3,12 @@ package repository import ( "bytes" "encoding/json" - "errors" "fmt" "io" "os" + "github.com/pkg/errors" + "restic/backend" "restic/crypto" "restic/debug" diff --git a/src/restic/snapshot.go b/src/restic/snapshot.go index 3eaa0b61f..0b2374d6c 100644 --- a/src/restic/snapshot.go +++ b/src/restic/snapshot.go @@ -1,13 +1,14 @@ package restic import ( - "errors" "fmt" "os" "os/user" "path/filepath" "time" + "github.com/pkg/errors" + "restic/backend" "restic/repository" ) diff --git a/src/restic/tree.go b/src/restic/tree.go index 067dc6b7e..9bfcfd7ee 100644 --- a/src/restic/tree.go +++ b/src/restic/tree.go @@ -1,10 +1,11 @@ package restic import ( - "errors" "fmt" "sort" + "github.com/pkg/errors" + "restic/backend" "restic/debug" "restic/pack" diff --git a/src/restic/worker/pool_test.go b/src/restic/worker/pool_test.go index f70664419..329ce9a88 100644 --- a/src/restic/worker/pool_test.go +++ b/src/restic/worker/pool_test.go @@ -1,9 +1,10 @@ package worker_test import ( - "errors" "testing" + "github.com/pkg/errors" + "restic/worker" )