pax_global_header00006660000000000000000000000064134531323500014511gustar00rootroot0000000000000052 comment=08dc5b27f5ced65786776ec936b4298445ec70cf errgo-1.0.1/000077500000000000000000000000001345313235000126265ustar00rootroot00000000000000errgo-1.0.1/LICENSE000066400000000000000000000027451345313235000136430ustar00rootroot00000000000000Copyright © 2013, Roger Peppe All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. errgo-1.0.1/README.md000066400000000000000000000151341345313235000141110ustar00rootroot00000000000000# errgo -- import "gopkg.in/errgo.v1" The errgo package provides a way to create and diagnose errors. It is compatible with the usual Go error idioms but adds a way to wrap errors so that they record source location information while retaining a consistent way for code to inspect errors to find out particular problems. ## Usage #### func Any ```go func Any(error) bool ``` Any returns true. It can be used as an argument to Mask to allow any diagnosis to pass through to the wrapped error. #### func Cause ```go func Cause(err error) error ``` Cause returns the cause of the given error. If err does not implement Causer or its Cause method returns nil, it returns err itself. Cause is the usual way to diagnose errors that may have been wrapped by Mask or NoteMask. #### func Details ```go func Details(err error) string ``` Details returns information about the stack of underlying errors wrapped by err, in the format: [{filename:99: error one} {otherfile:55: cause of error one}] The details are found by type-asserting the error to the Locationer, Causer and Wrapper interfaces. Details of the underlying stack are found by recursively calling Underlying when the underlying error implements Wrapper. #### func Is ```go func Is(err error) func(error) bool ``` Is returns a function that returns whether the an error is equal to the given error. It is intended to be used as a "pass" argument to Mask and friends; for example: return errgo.Mask(err, errgo.Is(http.ErrNoCookie)) would return an error with an http.ErrNoCookie cause only if that was err's diagnosis; otherwise the diagnosis would be itself. #### func Mask ```go func Mask(underlying error, pass ...func(error) bool) error ``` Mask returns an Err that wraps the given underyling error. The error message is unchanged, but the error location records the caller of Mask. If err is nil, Mask returns nil. By default Mask conceals the cause of the wrapped error, but if pass(Cause(err)) returns true for any of the provided pass functions, the cause of the returned error will be Cause(err). For example, the following code will return an error whose cause is the error from the os.Open call when (and only when) the file does not exist. f, err := os.Open("non-existent-file") if err != nil { return errgo.Mask(err, os.IsNotExist) } In order to add context to returned errors, it is conventional to call Mask when returning any error received from elsewhere. #### func MaskFunc ```go func MaskFunc(allow ...func(error) bool) func(error, ...func(error) bool) error ``` MaskFunc returns an equivalent of Mask that always allows the specified causes in addition to any causes specified when the returned function is called. It is defined for convenience, for example when all calls to Mask in a given package wish to allow the same set of causes to be returned. #### func New ```go func New(s string) error ``` New returns a new error with the given error message and no cause. It is a drop-in replacement for errors.New from the standard library. #### func Newf ```go func Newf(f string, a ...interface{}) error ``` Newf returns a new error with the given printf-formatted error message and no cause. #### func NoteMask ```go func NoteMask(underlying error, msg string, pass ...func(error) bool) error ``` NoteMask returns an Err that has the given underlying error, with the given message added as context, and allowing the cause of the underlying error to pass through into the result if allowed by the specific pass functions (see Mask for an explanation of the pass parameter). #### func Notef ```go func Notef(underlying error, f string, a ...interface{}) error ``` Notef returns an Error that wraps the given underlying error and adds the given formatted context message. The returned error has no cause (use NoteMask or WithCausef to add a message while retaining a cause). #### func WithCausef ```go func WithCausef(underlying, cause error, f string, a ...interface{}) error ``` WithCausef returns a new Error that wraps the given (possibly nil) underlying error and associates it with the given cause. The given formatted message context will also be added. #### type Causer ```go type Causer interface { Cause() error } ``` Causer is the type of an error that may provide an error cause for error diagnosis. Cause may return nil if there is no cause (for example because the cause has been masked). #### type Err ```go type Err struct { // Message_ holds the text of the error message. It may be empty // if Underlying is set. Message_ string // Cause_ holds the cause of the error as returned // by the Cause method. Cause_ error // Underlying_ holds the underlying error, if any. Underlying_ error // File and Line identify the source code location where the error was // created. File string Line int } ``` Err holds a description of an error along with information about where the error was created. It may be embedded in custom error types to add extra information that this errors package can understand. #### func (*Err) Cause ```go func (e *Err) Cause() error ``` Cause implements Causer. #### func (*Err) Error ```go func (e *Err) Error() string ``` Error implements error.Error. #### func (*Err) GoString ```go func (e *Err) GoString() string ``` GoString returns the details of the receiving error message, so that printing an error with %#v will produce useful information. #### func (*Err) Location ```go func (e *Err) Location() (file string, line int) ``` Location implements Locationer. #### func (*Err) Message ```go func (e *Err) Message() string ``` Message returns the top level error message. #### func (*Err) SetLocation ```go func (e *Err) SetLocation(callDepth int) ``` Locate records the source location of the error by setting e.Location, at callDepth stack frames above the call. #### func (*Err) Underlying ```go func (e *Err) Underlying() error ``` Underlying returns the underlying error if any. #### type Locationer ```go type Locationer interface { // Location returns the name of the file and the line // number associated with an error. Location() (file string, line int) } ``` Locationer can be implemented by any error type that wants to expose the source location of an error. #### type Wrapper ```go type Wrapper interface { // Message returns the top level error message, // not including the message from the underlying // error. Message() string // Underlying returns the underlying error, or nil // if there is none. Underlying() error } ``` Wrapper is the type of an error that wraps another error. It is exposed so that external types may implement it, but should in general not be used otherwise. errgo-1.0.1/errors.go000066400000000000000000000250371345313235000145000ustar00rootroot00000000000000// Copyright 2014 Roger Peppe. // See LICENCE file for details. // Package errgo provides a way to create // and diagnose errors. It is compatible with // the usual Go error idioms but adds a way to wrap errors // so that they record source location information // while retaining a consistent way for code to // inspect errors to find out particular problems. // package errgo import ( "bytes" "fmt" "log" "runtime" ) const debug = false // Err holds a description of an error along with information about // where the error was created. // // It may be embedded in custom error types to add // extra information that this errors package can // understand. type Err struct { // Message_ holds the text of the error message. It may be empty // if Underlying is set. Message_ string // Cause_ holds the cause of the error as returned // by the Cause method. Cause_ error // Underlying_ holds the underlying error, if any. Underlying_ error // File and Line identify the source code location where the error was // created. File string Line int } // Location implements Locationer. func (e *Err) Location() (file string, line int) { return e.File, e.Line } // Underlying returns the underlying error if any. func (e *Err) Underlying() error { return e.Underlying_ } // Cause implements Causer. func (e *Err) Cause() error { return e.Cause_ } // Message returns the top level error message. func (e *Err) Message() string { return e.Message_ } // Error implements error.Error. func (e *Err) Error() string { switch { case e.Message_ == "" && e.Underlying_ == nil: return "" case e.Message_ == "": return e.Underlying_.Error() case e.Underlying_ == nil: return e.Message_ } return fmt.Sprintf("%s: %v", e.Message_, e.Underlying_) } // GoString returns the details of the receiving error // message, so that printing an error with %#v will // produce useful information. func (e *Err) GoString() string { return Details(e) } // Causer is the type of an error that may provide // an error cause for error diagnosis. Cause may return // nil if there is no cause (for example because the // cause has been masked). type Causer interface { Cause() error } // Wrapper is the type of an error that wraps another error. It is // exposed so that external types may implement it, but should in // general not be used otherwise. type Wrapper interface { // Message returns the top level error message, // not including the message from the underlying // error. Message() string // Underlying returns the underlying error, or nil // if there is none. Underlying() error } // Locationer can be implemented by any error type // that wants to expose the source location of an error. type Locationer interface { // Location returns the name of the file and the line // number associated with an error. Location() (file string, line int) } // Details returns information about the stack of // underlying errors wrapped by err, in the format: // // [{filename:99: error one} {otherfile:55: cause of error one}] // // The details are found by type-asserting the error to // the Locationer, Causer and Wrapper interfaces. // Details of the underlying stack are found by // recursively calling Underlying when the // underlying error implements Wrapper. func Details(err error) string { if err == nil { return "[]" } var s []byte s = append(s, '[') for { s = append(s, '{') if err, ok := err.(Locationer); ok { file, line := err.Location() if file != "" { s = append(s, fmt.Sprintf("%s:%d", file, line)...) s = append(s, ": "...) } } if cerr, ok := err.(Wrapper); ok { s = append(s, cerr.Message()...) err = cerr.Underlying() } else { s = append(s, err.Error()...) err = nil } if debug { if err, ok := err.(Causer); ok { if cause := err.Cause(); cause != nil { s = append(s, fmt.Sprintf("=%T", cause)...) s = append(s, Details(cause)...) } } } s = append(s, '}') if err == nil { break } s = append(s, ' ') } s = append(s, ']') return string(s) } // SetLocation records the source location of the error by setting // e.Location, at callDepth stack frames above the call. func (e *Err) SetLocation(callDepth int) { _, file, line, _ := runtime.Caller(callDepth + 1) e.File, e.Line = file, line } func setLocation(err error, callDepth int) { if e, _ := err.(*Err); e != nil { e.SetLocation(callDepth + 1) } } // New returns a new error with the given error message and no cause. It // is a drop-in replacement for errors.New from the standard library. func New(s string) error { err := &Err{Message_: s} err.SetLocation(1) return err } // Newf returns a new error with the given printf-formatted error // message and no cause. func Newf(f string, a ...interface{}) error { err := &Err{Message_: fmt.Sprintf(f, a...)} err.SetLocation(1) return err } // match returns whether any of the given // functions returns true when called with err as an // argument. func match(err error, pass ...func(error) bool) bool { for _, f := range pass { if f(err) { return true } } return false } // Is returns a function that returns whether the // an error is equal to the given error. // It is intended to be used as a "pass" argument // to Mask and friends; for example: // // return errgo.Mask(err, errgo.Is(http.ErrNoCookie)) // // would return an error with an http.ErrNoCookie cause // only if that was err's diagnosis; otherwise the diagnosis // would be itself. func Is(err error) func(error) bool { return func(err1 error) bool { return err == err1 } } // Any returns true. It can be used as an argument to Mask // to allow any diagnosis to pass through to the wrapped // error. func Any(error) bool { return true } // NoteMask returns an Err that has the given underlying error, // with the given message added as context, and allowing // the cause of the underlying error to pass through into // the result if allowed by the specific pass functions // (see Mask for an explanation of the pass parameter). func NoteMask(underlying error, msg string, pass ...func(error) bool) error { err := noteMask(underlying, msg, pass...) setLocation(err, 1) return err } // noteMask is exactly like NoteMask except it doesn't set the location // of the returned error, so that we can avoid setting it twice // when it's used in other functions. func noteMask(underlying error, msg string, pass ...func(error) bool) error { newErr := &Err{ Underlying_: underlying, Message_: msg, } if len(pass) > 0 { if cause := Cause(underlying); match(cause, pass...) { newErr.Cause_ = cause } } if debug { if newd, oldd := newErr.Cause_, Cause(underlying); newd != oldd { log.Printf("Mask cause %[1]T(%[1]v)->%[2]T(%[2]v)", oldd, newd) log.Printf("call stack: %s", callers(0, 20)) log.Printf("len(allow) == %d", len(pass)) log.Printf("old error %#v", underlying) log.Printf("new error %#v", newErr) } } newErr.SetLocation(1) return newErr } // Mask returns an Err that wraps the given underyling error. The error // message is unchanged, but the error location records the caller of // Mask. // // If err is nil, Mask returns nil. // // By default Mask conceals the cause of the wrapped error, but if // pass(Cause(err)) returns true for any of the provided pass functions, // the cause of the returned error will be Cause(err). // // For example, the following code will return an error whose cause is // the error from the os.Open call when (and only when) the file does // not exist. // // f, err := os.Open("non-existent-file") // if err != nil { // return errgo.Mask(err, os.IsNotExist) // } // // In order to add context to returned errors, it // is conventional to call Mask when returning any // error received from elsewhere. // func Mask(underlying error, pass ...func(error) bool) error { if underlying == nil { return nil } err := noteMask(underlying, "", pass...) setLocation(err, 1) return err } // Notef returns an Error that wraps the given underlying // error and adds the given formatted context message. // The returned error has no cause (use NoteMask // or WithCausef to add a message while retaining a cause). func Notef(underlying error, f string, a ...interface{}) error { err := noteMask(underlying, fmt.Sprintf(f, a...)) setLocation(err, 1) return err } // MaskFunc returns an equivalent of Mask that always allows the // specified causes in addition to any causes specified when the // returned function is called. // // It is defined for convenience, for example when all calls to Mask in // a given package wish to allow the same set of causes to be returned. func MaskFunc(allow ...func(error) bool) func(error, ...func(error) bool) error { return func(err error, allow1 ...func(error) bool) error { var allowEither []func(error) bool if len(allow1) > 0 { // This is more efficient than using a function literal, // because the compiler knows that it doesn't escape. allowEither = make([]func(error) bool, len(allow)+len(allow1)) copy(allowEither, allow) copy(allowEither[len(allow):], allow1) } else { allowEither = allow } err = Mask(err, allowEither...) setLocation(err, 1) return err } } // WithCausef returns a new Error that wraps the given // (possibly nil) underlying error and associates it with // the given cause. The given formatted message context // will also be added. If underlying is nil and f is empty and has no arguments, // the message will be the same as the cause. func WithCausef(underlying, cause error, f string, a ...interface{}) error { var msg string if underlying == nil && f == "" && len(a) == 0 && cause != nil { msg = cause.Error() } else { msg = fmt.Sprintf(f, a...) } err := &Err{ Underlying_: underlying, Cause_: cause, Message_: msg, } err.SetLocation(1) return err } // Cause returns the cause of the given error. If err does not // implement Causer or its Cause method returns nil, it returns err itself. // // Cause is the usual way to diagnose errors that may have // been wrapped by Mask or NoteMask. func Cause(err error) error { var diag error if err, ok := err.(Causer); ok { diag = err.Cause() } if diag != nil { return diag } return err } // callers returns the stack trace of the goroutine that called it, // starting n entries above the caller of callers, as a space-separated list // of filename:line-number pairs with no new lines. func callers(n, max int) []byte { var b bytes.Buffer prev := false for i := 0; i < max; i++ { _, file, line, ok := runtime.Caller(n + 1) if !ok { return b.Bytes() } if prev { fmt.Fprintf(&b, " ") } fmt.Fprintf(&b, "%s:%d", file, line) n++ prev = true } return b.Bytes() } errgo-1.0.1/errors_test.go000066400000000000000000000166141345313235000155400ustar00rootroot00000000000000// Copyright 2014 Roger Peppe. // See LICENCE file for details. package errgo_test import ( "fmt" "io/ioutil" "runtime" "strings" "testing" qt "github.com/frankban/quicktest" "gopkg.in/errgo.v1" ) var ( _ errgo.Wrapper = (*errgo.Err)(nil) _ errgo.Locationer = (*errgo.Err)(nil) _ errgo.Causer = (*errgo.Err)(nil) ) func TestNew(t *testing.T) { c := qt.New(t) err := errgo.New("foo") //err TestNew checkErr(c, err, nil, "foo", "[{$TestNew$: foo}]", err) } func TestNewf(t *testing.T) { c := qt.New(t) err := errgo.Newf("foo %d", 5) //err TestNewf checkErr(c, err, nil, "foo 5", "[{$TestNewf$: foo 5}]", err) } var someErr = errgo.New("some error") //err varSomeErr func annotate1() error { err := errgo.Notef(someErr, "annotate1") //err annotate1 return err } func annotate2() error { err := annotate1() err = errgo.Notef(err, "annotate2") //err annotate2 return err } func TestNoteUsage(t *testing.T) { c := qt.New(t) err0 := annotate2() err, ok := err0.(errgo.Wrapper) c.Assert(ok, qt.Equals, true) underlying := err.Underlying() checkErr( c, err0, underlying, "annotate2: annotate1: some error", "[{$annotate2$: annotate2} {$annotate1$: annotate1} {$varSomeErr$: some error}]", err0) } func TestMask(t *testing.T) { c := qt.New(t) err0 := errgo.WithCausef(nil, someErr, "foo") //err TestMask#0 err := errgo.Mask(err0) //err TestMask#1 checkErr(c, err, err0, "foo", "[{$TestMask#1$: } {$TestMask#0$: foo}]", err) err = errgo.Mask(nil) c.Assert(err, qt.IsNil) } func TestNotef(t *testing.T) { c := qt.New(t) err0 := errgo.WithCausef(nil, someErr, "foo") //err TestNotef#0 err := errgo.Notef(err0, "bar") //err TestNotef#1 checkErr(c, err, err0, "bar: foo", "[{$TestNotef#1$: bar} {$TestNotef#0$: foo}]", err) err = errgo.Notef(nil, "bar") //err TestNotef#2 checkErr(c, err, nil, "bar", "[{$TestNotef#2$: bar}]", err) } func TestNoteMask(t *testing.T) { c := qt.New(t) err0 := errgo.WithCausef(nil, someErr, "foo") //err TestNoteMask#0 err := errgo.NoteMask(err0, "bar") //err TestNoteMask#1 checkErr(c, err, err0, "bar: foo", "[{$TestNoteMask#1$: bar} {$TestNoteMask#0$: foo}]", err) err = errgo.NoteMask(err0, "bar", errgo.Is(someErr)) //err TestNoteMask#2 checkErr(c, err, err0, "bar: foo", "[{$TestNoteMask#2$: bar} {$TestNoteMask#0$: foo}]", someErr) err = errgo.NoteMask(err0, "") //err TestNoteMask#3 checkErr(c, err, err0, "foo", "[{$TestNoteMask#3$: } {$TestNoteMask#0$: foo}]", err) } func TestMaskFunc(t *testing.T) { c := qt.New(t) err0 := errgo.New("zero") err1 := errgo.New("one") allowVals := func(vals ...error) (r []func(error) bool) { for _, val := range vals { r = append(r, errgo.Is(val)) } return } tests := []struct { err error allow0 []func(error) bool allow1 []func(error) bool cause error }{{ err: err0, allow0: allowVals(err0), cause: err0, }, { err: err1, allow0: allowVals(err0), cause: nil, }, { err: err0, allow1: allowVals(err0), cause: err0, }, { err: err0, allow0: allowVals(err1), allow1: allowVals(err0), cause: err0, }, { err: err0, allow0: allowVals(err0, err1), cause: err0, }, { err: err1, allow0: allowVals(err0, err1), cause: err1, }, { err: err0, allow1: allowVals(err0, err1), cause: err0, }, { err: err1, allow1: allowVals(err0, err1), cause: err1, }} for i, test := range tests { c.Logf("test %d", i) wrap := errgo.MaskFunc(test.allow0...) err := wrap(test.err, test.allow1...) cause := errgo.Cause(err) wantCause := test.cause if wantCause == nil { wantCause = err } c.Check(cause, qt.Equals, wantCause) } } type embed struct { *errgo.Err } func TestCause(t *testing.T) { c := qt.New(t) c.Assert(errgo.Cause(someErr), qt.Equals, someErr) causeErr := errgo.New("cause error") underlyingErr := errgo.New("underlying error") //err TestCause#1 err := errgo.WithCausef(underlyingErr, causeErr, "foo %d", 99) //err TestCause#2 c.Assert(errgo.Cause(err), qt.Equals, causeErr) checkErr(c, err, underlyingErr, "foo 99: underlying error", "[{$TestCause#2$: foo 99} {$TestCause#1$: underlying error}]", causeErr) err = &embed{err.(*errgo.Err)} c.Assert(errgo.Cause(err), qt.Equals, causeErr) } func TestWithCausefNoMessage(t *testing.T) { c := qt.New(t) cause := errgo.New("cause") err := errgo.WithCausef(nil, cause, "") c.Assert(err, qt.ErrorMatches, "cause") c.Assert(errgo.Cause(err), qt.Equals, cause) } func TestWithCausefWithUnderlyingButNoMessage(t *testing.T) { c := qt.New(t) err := errgo.New("something") cause := errgo.New("cause") err = errgo.WithCausef(err, cause, "") c.Assert(err, qt.ErrorMatches, "something") c.Assert(errgo.Cause(err), qt.Equals, cause) } func TestDetails(t *testing.T) { c := qt.New(t) c.Assert(errgo.Details(nil), qt.Equals, "[]") otherErr := fmt.Errorf("other") checkErr(c, otherErr, nil, "other", "[{other}]", otherErr) err0 := &embed{errgo.New("foo").(*errgo.Err)} //err TestStack#0 checkErr(c, err0, nil, "foo", "[{$TestStack#0$: foo}]", err0) err1 := &embed{errgo.Notef(err0, "bar").(*errgo.Err)} //err TestStack#1 checkErr(c, err1, err0, "bar: foo", "[{$TestStack#1$: bar} {$TestStack#0$: foo}]", err1) err2 := errgo.Mask(err1) //err TestStack#2 checkErr(c, err2, err1, "bar: foo", "[{$TestStack#2$: } {$TestStack#1$: bar} {$TestStack#0$: foo}]", err2) } func TestMatch(t *testing.T) { c := qt.New(t) type errTest func(error) bool allow := func(ss ...string) []func(error) bool { fns := make([]func(error) bool, len(ss)) for i, s := range ss { s := s fns[i] = func(err error) bool { return err != nil && err.Error() == s } } return fns } tests := []struct { err error fns []func(error) bool ok bool }{{ err: errgo.New("foo"), fns: allow("foo"), ok: true, }, { err: errgo.New("foo"), fns: allow("bar"), ok: false, }, { err: errgo.New("foo"), fns: allow("bar", "foo"), ok: true, }, { err: errgo.New("foo"), fns: nil, ok: false, }, { err: nil, fns: nil, ok: false, }} for i, test := range tests { c.Logf("test %d", i) c.Assert(errgo.Match(test.err, test.fns...), qt.Equals, test.ok) } } func checkErr(c *qt.C, err, underlying error, msg string, details string, cause error) { c.Assert(err, qt.Not(qt.IsNil)) c.Assert(err.Error(), qt.Equals, msg) if err, ok := err.(errgo.Wrapper); ok { c.Assert(err.Underlying(), qt.Equals, underlying) } else { c.Assert(underlying, qt.IsNil) } c.Assert(errgo.Cause(err), qt.Equals, cause) wantDetails := replaceLocations(details) c.Assert(errgo.Details(err), qt.Equals, wantDetails) } func replaceLocations(s string) string { t := "" for { i := strings.Index(s, "$") if i == -1 { break } t += s[0:i] s = s[i+1:] i = strings.Index(s, "$") if i == -1 { panic("no second $") } file, line := location(s[0:i]) t += fmt.Sprintf("%s:%d", file, line) s = s[i+1:] } t += s return t } func location(tag string) (string, int) { line, ok := tagToLine[tag] if !ok { panic(fmt.Errorf("tag %q not found", tag)) } return filename, line } var tagToLine = make(map[string]int) var filename string func init() { data, err := ioutil.ReadFile("errors_test.go") if err != nil { panic(err) } lines := strings.Split(string(data), "\n") for i, line := range lines { if j := strings.Index(line, "//err "); j >= 0 { tagToLine[line[j+len("//err "):]] = i + 1 } } _, filename, _, _ = runtime.Caller(0) } errgo-1.0.1/export_test.go000066400000000000000000000001421345313235000155320ustar00rootroot00000000000000// Copyright 2014 Roger Peppe. // See LICENCE file for details. package errgo var Match = match errgo-1.0.1/go.mod000066400000000000000000000001071345313235000137320ustar00rootroot00000000000000module gopkg.in/errgo.v1 require github.com/frankban/quicktest v1.2.2 errgo-1.0.1/go.sum000066400000000000000000000015471345313235000137700ustar00rootroot00000000000000github.com/frankban/quicktest v1.2.2 h1:xfmOhhoH5fGPgbEAlhLpJH9p0z/0Qizio9osmvn9IUY= github.com/frankban/quicktest v1.2.2/go.mod h1:Qh/WofXFeiAFII1aEBu529AtJo6Zg2VHscnEsbBnJ20= github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42 h1:q3pnF5JFBNRz8sRD+IRj7Y6DMyYGTNqnZ9axTbSfoNI= github.com/google/go-cmp v0.2.1-0.20190312032427-6f77996f0c42/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=