From 36494b0acdb3d2123f85f5506d7d3153ca66937d Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Mon, 14 Nov 2011 20:53:03 +1100 Subject: [PATCH] doc/progs: fix windows version to satisfy new error R=rsc CC=golang-dev https://golang.org/cl/5376089 --- doc/progs/file_windows.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/doc/progs/file_windows.go b/doc/progs/file_windows.go index ce3ad5248d..e6a355049a 100644 --- a/doc/progs/file_windows.go +++ b/doc/progs/file_windows.go @@ -28,10 +28,7 @@ var ( ) func OpenFile(name string, mode int, perm uint32) (file *File, err error) { - r, e := syscall.Open(name, mode, perm) - if e != 0 { - err = os.Errno(e) - } + r, err := syscall.Open(name, mode, perm) return newFile(r, name), err } @@ -54,22 +51,16 @@ func (file *File) Close() error { if file == nil { return os.EINVAL } - e := syscall.Close(file.fd) + err := syscall.Close(file.fd) file.fd = syscall.InvalidHandle // so it can't be closed again - if e != 0 { - return os.Errno(e) - } - return nil + return err } func (file *File) Read(b []byte) (ret int, err error) { if file == nil { return -1, os.EINVAL } - r, e := syscall.Read(file.fd, b) - if e != 0 { - err = os.Errno(e) - } + r, err := syscall.Read(file.fd, b) return int(r), err } @@ -77,10 +68,7 @@ func (file *File) Write(b []byte) (ret int, err error) { if file == nil { return -1, os.EINVAL } - r, e := syscall.Write(file.fd, b) - if e != 0 { - err = os.Errno(e) - } + r, err := syscall.Write(file.fd, b) return int(r), err }