From: Brad Fitzpatrick Date: Sat, 18 Feb 2012 12:45:43 +0000 (-0800) Subject: os: document the type of link errors X-Git-Tag: weekly.2012-02-22~129 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a5f21c95dc279f421c094a592d65bf2ef89e87d6;p=gostls13.git os: document the type of link errors R=golang-dev, r CC=golang-dev https://golang.org/cl/5673090 --- diff --git a/src/pkg/os/file_plan9.go b/src/pkg/os/file_plan9.go index 70041f22aa..cb0e9ef928 100644 --- a/src/pkg/os/file_plan9.go +++ b/src/pkg/os/file_plan9.go @@ -276,7 +276,6 @@ func Remove(name string) error { } // Rename renames a file. -// If there is an error, it will be of type *PathError. func Rename(oldname, newname string) error { var d Dir d.Null() @@ -340,12 +339,15 @@ func Pipe() (r *File, w *File, err error) { // not supported on Plan 9 // Link creates a hard link. +// If there is an error, it will be of type *LinkError. func Link(oldname, newname string) error { - return ErrPlan9 + return &LinkError{"link", oldname, newname, ErrPlan9} } +// Symlink creates newname as a symbolic link to oldname. +// If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { - return ErrPlan9 + return &LinkError{"symlink", oldname, newname, ErrPlan9} } func Readlink(name string) (string, error) { diff --git a/src/pkg/os/file_posix.go b/src/pkg/os/file_posix.go index 8861af1c7d..2ffc2ee083 100644 --- a/src/pkg/os/file_posix.go +++ b/src/pkg/os/file_posix.go @@ -38,6 +38,7 @@ func (e *LinkError) Error() string { } // Link creates newname as a hard link to the oldname file. +// If there is an error, it will be of type *LinkError. func Link(oldname, newname string) error { e := syscall.Link(oldname, newname) if e != nil { @@ -47,6 +48,7 @@ func Link(oldname, newname string) error { } // Symlink creates newname as a symbolic link to oldname. +// If there is an error, it will be of type *LinkError. func Symlink(oldname, newname string) error { e := syscall.Symlink(oldname, newname) if e != nil {