From aa0ae7554c460947ff40ae43eb10a098dc4e3f6d Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Mon, 9 Dec 2013 23:25:13 -0500 Subject: [PATCH] os: clarify docs for Rename. Three changes: 1. mention "move" to clarify things up. 2. use {old,new}path instead of {old,new}name, which makes it clear what relative path would do here. 3. mention "OS-specific restrictions might apply". Fixes #6887. R=golang-dev, alex.brainman, iant, r CC=golang-dev https://golang.org/cl/36930044 --- src/pkg/os/file.go | 3 +++ src/pkg/os/file_plan9.go | 3 +-- src/pkg/os/file_posix.go | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go index 2dd1fcf282f65a..18cd61d3a8491d 100644 --- a/src/pkg/os/file.go +++ b/src/pkg/os/file.go @@ -140,6 +140,9 @@ func (f *File) Write(b []byte) (n int, err error) { if n < 0 { n = 0 } + if n != len(b) { + err = io.ErrShortWrite + } epipecheck(f, e) diff --git a/src/pkg/os/file_plan9.go b/src/pkg/os/file_plan9.go index 708163ee1c08da..278fae772cec71 100644 --- a/src/pkg/os/file_plan9.go +++ b/src/pkg/os/file_plan9.go @@ -313,8 +313,7 @@ func Remove(name string) error { return nil } -// Rename renames a file. -func Rename(oldname, newname string) error { +func rename(oldname, newname string) error { var d syscall.Dir d.Null() diff --git a/src/pkg/os/file_posix.go b/src/pkg/os/file_posix.go index a8bef359b95b29..90838682b683ef 100644 --- a/src/pkg/os/file_posix.go +++ b/src/pkg/os/file_posix.go @@ -48,8 +48,7 @@ func Readlink(name string) (string, error) { } } -// Rename renames a file. -func Rename(oldname, newname string) error { +func rename(oldname, newname string) error { e := syscall.Rename(oldname, newname) if e != nil { return &LinkError{"rename", oldname, newname, e}