all: Make all error implementations pointer types (#6726)
This matches the convention of the stdlib and avoids ambiguity: when
customErr{} and &customErr{} both implement error, client code needs to
check for both.
Memory use should remain the same, since storing a non-pointer type in
an interface value still copies the value to the heap.
This commit is contained in:
@@ -19,7 +19,7 @@ type TraversesSymlinkError struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func (e TraversesSymlinkError) Error() string {
|
||||
func (e *TraversesSymlinkError) Error() string {
|
||||
return fmt.Sprintf("traverses symlink: %s", e.path)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ type NotADirectoryError struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func (e NotADirectoryError) Error() string {
|
||||
func (e *NotADirectoryError) Error() string {
|
||||
return fmt.Sprintf("not a directory: %s", e.path)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user