Dave Cheney 10 éve
szülő
commit
9c1c579e61
2 módosított fájl, 3 hozzáadás és 11 törlés
  1. 0 9
      errors.go
  2. 3 2
      errors_test.go

+ 0 - 9
errors.go

@@ -33,12 +33,3 @@ func Cause(err error) error {
 	}
 	return err
 }
-
-// cause implements the interface required by Cause.
-type cause struct {
-	err error
-}
-
-func (c *cause) Cause() error {
-	return c.err
-}

+ 3 - 2
errors_test.go

@@ -38,10 +38,11 @@ type nilError struct{}
 func (nilError) Error() string { return "nil error" }
 
 type causeError struct {
-	cause
+	cause error
 }
 
 func (e *causeError) Error() string { return "cause error" }
+func (e *causeError) Cause() error { return e.cause }
 
 func TestCause(t *testing.T) {
 	tests := []struct {
@@ -65,7 +66,7 @@ func TestCause(t *testing.T) {
 		want: io.EOF,
 	}, {
 		// caused error returns cause
-		err:  &causeError{cause{err: io.EOF}},
+		err:  &causeError{cause: io.EOF},
 		want: io.EOF,
 	}}