Replace stdlib errors with github.com/pkg/errors

This commit is contained in:
Alexander Neumann 2016-08-21 17:46:23 +02:00
parent 17a38faa43
commit 444a268ce0
48 changed files with 92 additions and 47 deletions

View file

@ -2,7 +2,6 @@ package main
import ( import (
"bufio" "bufio"
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -14,6 +13,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/pkg/errors"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )

View file

@ -2,10 +2,11 @@ package main
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"os" "os"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"

View file

@ -1,11 +1,12 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"time" "time"
"github.com/pkg/errors"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
"restic" "restic"

View file

@ -8,6 +8,8 @@ import (
"io" "io"
"os" "os"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/pack" "restic/pack"

View file

@ -1,7 +1,7 @@
package main package main
import ( import (
"errors" "github.com/pkg/errors"
"restic/repository" "restic/repository"
) )

View file

@ -1,9 +1,10 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/repository" "restic/repository"
) )

View file

@ -1,9 +1,10 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
) )

View file

@ -1,9 +1,10 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -9,6 +8,8 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/backend/local" "restic/backend/local"
"restic/backend/rest" "restic/backend/rest"

View file

@ -2,11 +2,12 @@ package main
import ( import (
"fmt" "fmt"
"github.com/jessevdk/go-flags"
"os" "os"
"restic" "restic"
"restic/debug" "restic/debug"
"runtime" "runtime"
"github.com/jessevdk/go-flags"
) )
func init() { func init() {

View file

@ -2,7 +2,6 @@ package restic
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -11,6 +10,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"
"restic/fs" "restic/fs"

View file

@ -2,13 +2,14 @@ package restic_test
import ( import (
"crypto/rand" "crypto/rand"
"errors"
"io" "io"
mrand "math/rand" mrand "math/rand"
"sync" "sync"
"testing" "testing"
"time" "time"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/pack" "restic/pack"

View file

@ -1,6 +1,6 @@
package backend package backend
import "errors" import "github.com/pkg/errors"
// ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix // ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix
// could be found. // could be found.

View file

@ -1,8 +1,9 @@
package backend package backend
import ( import (
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
) )
// Handle is used to store and access data in a backend. // Handle is used to store and access data in a backend.

View file

@ -5,7 +5,8 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"github.com/pkg/errors"
) )
// Hash returns the ID for data. // Hash returns the ID for data.

View file

@ -1,8 +1,9 @@
package local package local
import ( import (
"errors"
"strings" "strings"
"github.com/pkg/errors"
) )
// ParseConfig parses a local backend config. // ParseConfig parses a local backend config.

View file

@ -1,13 +1,14 @@
package local package local
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"
"restic/fs" "restic/fs"

View file

@ -1,10 +1,11 @@
package mem package mem
import ( import (
"errors"
"io" "io"
"sync" "sync"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"
) )

View file

@ -1,7 +1,7 @@
package mem_test package mem_test
import ( import (
"errors" "github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/backend/mem" "restic/backend/mem"

View file

@ -1,6 +1,6 @@
package backend package backend
import "errors" import "github.com/pkg/errors"
// MockBackend implements a backend whose functions can be specified. This // MockBackend implements a backend whose functions can be specified. This
// should only be used for tests. // should only be used for tests.

View file

@ -1,9 +1,10 @@
package rest package rest
import ( import (
"errors"
"net/url" "net/url"
"strings" "strings"
"github.com/pkg/errors"
) )
// Config contains all configuration necessary to connect to a REST server. // Config contains all configuration necessary to connect to a REST server.

View file

@ -3,7 +3,6 @@ package rest
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -11,6 +10,8 @@ import (
"path" "path"
"strings" "strings"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
) )

View file

@ -1,11 +1,12 @@
package rest_test package rest_test
import ( import (
"errors"
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/backend/rest" "restic/backend/rest"
"restic/backend/test" "restic/backend/test"

View file

@ -1,10 +1,11 @@
package s3 package s3
import ( import (
"errors"
"net/url" "net/url"
"path" "path"
"strings" "strings"
"github.com/pkg/errors"
) )
// Config contains all configuration necessary to connect to an s3 compatible // Config contains all configuration necessary to connect to an s3 compatible

View file

@ -2,10 +2,11 @@ package s3
import ( import (
"bytes" "bytes"
"errors"
"io" "io"
"strings" "strings"
"github.com/pkg/errors"
"github.com/minio/minio-go" "github.com/minio/minio-go"
"restic/backend" "restic/backend"

View file

@ -1,11 +1,12 @@
package s3_test package s3_test
import ( import (
"errors"
"fmt" "fmt"
"net/url" "net/url"
"os" "os"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/backend/s3" "restic/backend/s3"
"restic/backend/test" "restic/backend/test"

View file

@ -1,11 +1,12 @@
package sftp package sftp
import ( import (
"errors"
"fmt" "fmt"
"net/url" "net/url"
"path" "path"
"strings" "strings"
"github.com/pkg/errors"
) )
// Config collects all information required to connect to an sftp server. // Config collects all information required to connect to an sftp server.

View file

@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"crypto/rand" "crypto/rand"
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -13,6 +12,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"

View file

@ -1,7 +1,7 @@
package test_test package test_test
import ( import (
"errors" "github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/backend/mem" "restic/backend/mem"

View file

@ -1,7 +1,6 @@
package restic package restic
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -9,6 +8,8 @@ import (
"runtime" "runtime"
"strings" "strings"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"
"restic/fs" "restic/fs"

View file

@ -6,6 +6,8 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/crypto" "restic/crypto"

View file

@ -5,9 +5,10 @@ import (
"crypto/cipher" "crypto/cipher"
"crypto/rand" "crypto/rand"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
"golang.org/x/crypto/poly1305" "golang.org/x/crypto/poly1305"
) )

View file

@ -1,9 +1,10 @@
package filter package filter
import ( import (
"errors"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/pkg/errors"
) )
// ErrBadString is returned when Match is called with the empty string as the // ErrBadString is returned when Match is called with the empty string as the

View file

@ -4,9 +4,10 @@
package fuse package fuse
import ( import (
"errors"
"sync" "sync"
"github.com/pkg/errors"
"restic" "restic"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"

View file

@ -5,11 +5,12 @@ package fuse
import ( import (
"bytes" "bytes"
"errors"
"math/rand" "math/rand"
"testing" "testing"
"time" "time"
"github.com/pkg/errors"
"bazil.org/fuse" "bazil.org/fuse"
"restic" "restic"

View file

@ -4,11 +4,12 @@
package fuse package fuse
import ( import (
"restic"
"restic/repository"
"bazil.org/fuse" "bazil.org/fuse"
"bazil.org/fuse/fs" "bazil.org/fuse/fs"
"golang.org/x/net/context" "golang.org/x/net/context"
"restic"
"restic/repository"
) )
// Statically ensure that *file implements the given interface // Statically ensure that *file implements the given interface

View file

@ -2,7 +2,6 @@
package index package index
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"restic" "restic"
@ -12,6 +11,8 @@ import (
"restic/pack" "restic/pack"
"restic/types" "restic/types"
"restic/worker" "restic/worker"
"github.com/pkg/errors"
) )
// Pack contains information about the contents of a pack. // Pack contains information about the contents of a pack.

View file

@ -1,8 +1,9 @@
package restic package restic
import ( import (
"errors"
"syscall" "syscall"
"github.com/pkg/errors"
) )
// mknod() creates a filesystem node (file, device // mknod() creates a filesystem node (file, device

View file

@ -3,11 +3,12 @@ package pack
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"errors"
"fmt" "fmt"
"io" "io"
"sync" "sync"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/crypto" "restic/crypto"
) )

View file

@ -1,12 +1,13 @@
package pipe package pipe
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"github.com/pkg/errors"
"restic/debug" "restic/debug"
"restic/fs" "restic/fs"
) )

View file

@ -4,10 +4,11 @@ import (
"crypto/rand" "crypto/rand"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"errors"
"io" "io"
"testing" "testing"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"

View file

@ -3,12 +3,13 @@ package repository
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"sync" "sync"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/crypto" "restic/crypto"
"restic/debug" "restic/debug"

View file

@ -2,12 +2,13 @@ package repository
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"os" "os"
"os/user" "os/user"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/crypto" "restic/crypto"
"restic/debug" "restic/debug"

View file

@ -1,11 +1,12 @@
package repository_test package repository_test
import ( import (
"errors"
"math/rand" "math/rand"
"testing" "testing"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/repository" "restic/repository"
. "restic/test" . "restic/test"

View file

@ -3,11 +3,12 @@ package repository
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/crypto" "restic/crypto"
"restic/debug" "restic/debug"

View file

@ -1,13 +1,14 @@
package restic package restic
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"os/user" "os/user"
"path/filepath" "path/filepath"
"time" "time"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/repository" "restic/repository"
) )

View file

@ -1,10 +1,11 @@
package restic package restic
import ( import (
"errors"
"fmt" "fmt"
"sort" "sort"
"github.com/pkg/errors"
"restic/backend" "restic/backend"
"restic/debug" "restic/debug"
"restic/pack" "restic/pack"

View file

@ -1,9 +1,10 @@
package worker_test package worker_test
import ( import (
"errors"
"testing" "testing"
"github.com/pkg/errors"
"restic/worker" "restic/worker"
) )