mirror of
https://github.com/golang/go.git
synced 2025-11-02 17:50:56 +00:00
os: fix LinkError creation on windows.
Not only carrying invalid info but also this caused Error to crash with null pointer exception. Change-Id: Ibfe63d20eb9b9178ea618e59c74111e9245a6779 Reviewed-on: https://go-review.googlesource.com/6270 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
2b417dc3e1
commit
c2025c4131
2 changed files with 10 additions and 3 deletions
|
|
@ -508,9 +508,8 @@ func Link(oldname, newname string) error {
|
|||
if err != nil {
|
||||
return &LinkError{"link", oldname, newname, err}
|
||||
}
|
||||
|
||||
e := syscall.CreateHardLink(n, o, 0)
|
||||
if e != nil {
|
||||
err = syscall.CreateHardLink(n, o, 0)
|
||||
if err != nil {
|
||||
return &LinkError{"link", oldname, newname, err}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -533,6 +533,14 @@ func TestHardLink(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("link %q, %q failed: %v", to, from, err)
|
||||
}
|
||||
|
||||
none := "hardlinktestnone"
|
||||
err = Link(none, none)
|
||||
// Check the returned error is well-formed.
|
||||
if lerr, ok := err.(*LinkError); !ok || lerr.Error() == "" {
|
||||
t.Errorf("link %q, %q failed to return a valid error", none, none)
|
||||
}
|
||||
|
||||
defer Remove(from)
|
||||
tostat, err := Stat(to)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue