doc/codelab/wiki/index.html | 16 ++++++++-------- doc/codelab/wiki/wiki.html | 16 ++++++++-------- doc/debugging_with_gdb.html | 4 ++-- src/cmd/cgo/out.go | 2 +- src/cmd/goinstall/main.go | 2 +- src/cmd/govet/govet.go | 38 +++++++++++++++++++------------------- src/pkg/compress/bzip2/bit_reader.go | 2 +- src/pkg/crypto/rsa/rsa.go | 3 +-- src/pkg/crypto/tls/conn.go | 2 +- src/pkg/crypto/x509/verify.go | 2 +- src/pkg/exp/ssh/channel.go | 2 +- src/pkg/exp/types/gcimporter.go | 2 +- src/pkg/fmt/print.go | 2 +- src/pkg/go/ast/print.go | 2 +- src/pkg/go/printer/printer.go | 2 +- src/pkg/go/scanner/errors.go | 4 ++-- src/pkg/gob/error.go | 10 +++++----- src/pkg/old/netchan/import.go | 2 +- src/pkg/os/dir_plan9.go | 4 ++-- src/pkg/os/dir_unix.go | 2 +- src/pkg/os/file_unix.go | 2 +- src/pkg/os/file_windows.go | 2 +- src/pkg/regexp/all_test.go | 2 +- src/pkg/rpc/debug.go | 2 +- src/pkg/rpc/server.go | 25 ++++++++++++------------- src/pkg/runtime/error.go | 2 +- src/pkg/smtp/auth.go | 4 ++-- src/pkg/tabwriter/tabwriter.go | 2 +- src/pkg/template/doc.go | 4 ++-- src/pkg/template/exec.go | 2 +- src/pkg/template/exec_test.go | 2 +- src/pkg/template/funcs.go | 4 ++-- src/pkg/template/helper.go | 4 ++-- src/pkg/utf8/string.go | 20 ++++---------------- diff --git a/doc/codelab/wiki/index.html b/doc/codelab/wiki/index.html index 21248c18614184a4bdbc66a4c4c44163df8e37fb..3dafc5cbef36f6c0c07345937cf1f4b9121f9dea 100644 --- a/doc/codelab/wiki/index.html +++ b/doc/codelab/wiki/index.html @@ -107,7 +107,7 @@

This method's signature reads: "This is a method named save that takes as its receiver p, a pointer to Page . It takes -no parameters, and returns a value of type os.Error." +no parameters, and returns a value of type error."

@@ -116,7 +116,7 @@ file. For simplicity, we will use the Title as the file name.

-The save method returns an os.Error value because +The save method returns an error value because that is the return type of WriteFile (a standard library function that writes a byte slice to a file). The save method returns the error value, to let the application handle it should anything go wrong while @@ -152,7 +152,7 @@

Functions can return multiple values. The standard library function -io.ReadFile returns []byte and os.Error. +io.ReadFile returns []byte and error. In loadPage, error isn't being handled yet; the "blank identifier" represented by the underscore (_) symbol is used to throw away the error return value (in essence, assigning the value to nothing). @@ -161,7 +161,7 @@

But what happens if ReadFile encounters an error? For example, the file might not exist. We should not ignore such errors. Let's modify the -function to return *Page and os.Error. +function to return *Page and error.

@@ -178,7 +178,7 @@
 

Callers of this function can now check the second parameter; if it is nil then it has successfully loaded a Page. If not, it will be an -os.Error that can be handled by the caller (see the error that can be handled by the caller (see the os package documentation for details).

@@ -337,7 +337,7 @@ HTML, and writes it to w, the http.ResponseWriter.

-Again, note the use of _ to ignore the os.Error +Again, note the use of _ to ignore the error return value from loadPage. This is done here for simplicity and generally considered bad practice. We will attend to this later.

@@ -711,7 +711,7 @@

Then we create an init function, which will be called before main at program initialization. The function template.Must is a convenience wrapper that panics when passed a -non-nil os.Error value, and otherwise returns the +non-nil error value, and otherwise returns the *Template unaltered. A panic is appropriate here; if the templates can't be loaded the only sensible thing to do is exit the program.

@@ -768,7 +768,7 @@ The function regexp.MustCompile will parse and compile the regular expression, and return a regexp.Regexp. MustCompile is distinct from Compile in that it will panic if the expression compilation fails, while Compile returns -an os.Error as a second parameter. +an error as a second parameter.

diff --git a/doc/codelab/wiki/wiki.html b/doc/codelab/wiki/wiki.html index 634babd8b8f2988441756062131ed5192cd10dfe..c3dee3f709f9d1625d4b4096ceea473c55a7d42c 100644 --- a/doc/codelab/wiki/wiki.html +++ b/doc/codelab/wiki/wiki.html @@ -101,7 +101,7 @@

This method's signature reads: "This is a method named save that takes as its receiver p, a pointer to Page . It takes -no parameters, and returns a value of type os.Error." +no parameters, and returns a value of type error."

@@ -110,7 +110,7 @@ file. For simplicity, we will use the Title as the file name.

-The save method returns an os.Error value because +The save method returns an error value because that is the return type of WriteFile (a standard library function that writes a byte slice to a file). The save method returns the error value, to let the application handle it should anything go wrong while @@ -142,7 +142,7 @@

Functions can return multiple values. The standard library function -io.ReadFile returns []byte and os.Error. +io.ReadFile returns []byte and error. In loadPage, error isn't being handled yet; the "blank identifier" represented by the underscore (_) symbol is used to throw away the error return value (in essence, assigning the value to nothing). @@ -151,7 +151,7 @@

But what happens if ReadFile encounters an error? For example, the file might not exist. We should not ignore such errors. Let's modify the -function to return *Page and os.Error. +function to return *Page and error.

@@ -161,7 +161,7 @@
 

Callers of this function can now check the second parameter; if it is nil then it has successfully loaded a Page. If not, it will be an -os.Error that can be handled by the caller (see the error that can be handled by the caller (see the os package documentation for details).

@@ -297,7 +297,7 @@ HTML, and writes it to w, the http.ResponseWriter.

-Again, note the use of _ to ignore the os.Error +Again, note the use of _ to ignore the error return value from loadPage. This is done here for simplicity and generally considered bad practice. We will attend to this later.

@@ -575,7 +575,7 @@

Then we create an init function, which will be called before main at program initialization. The function template.Must is a convenience wrapper that panics when passed a -non-nil os.Error value, and otherwise returns the +non-nil error value, and otherwise returns the *Template unaltered. A panic is appropriate here; if the templates can't be loaded the only sensible thing to do is exit the program.

@@ -622,7 +622,7 @@ The function regexp.MustCompile will parse and compile the regular expression, and return a regexp.Regexp. MustCompile is distinct from Compile in that it will panic if the expression compilation fails, while Compile returns -an os.Error as a second parameter. +an error as a second parameter.

diff --git a/doc/debugging_with_gdb.html b/doc/debugging_with_gdb.html index 04850c0266fbb33d054249e9d62dd8c6d2474195..874c468345f4d0a53393c77c6ebfab66e81c5d47 100644 --- a/doc/debugging_with_gdb.html +++ b/doc/debugging_with_gdb.html @@ -288,8 +288,8 @@ #0 0x000000000040facb in runtime.gosched () at /home/lvd/g/src/pkg/runtime/proc.c:873 #1 0x00000000004031c9 in runtime.chanrecv (c=void, ep=void, selected=void, received=void) at /home/lvd/g/src/pkg/runtime/chan.c:342 #2 0x0000000000403299 in runtime.chanrecv1 (t=void, c=void) at/home/lvd/g/src/pkg/runtime/chan.c:423 -#3 0x000000000043075b in testing.RunTests (matchString={void (struct string, struct string, bool *, os.Error *)} 0x7ffff7f9ef60, tests= []testing.InternalTest = {...}) at /home/lvd/g/src/pkg/testing/testing.go:201 -#4 0x00000000004302b1 in testing.Main (matchString={void (struct string, struct string, bool *, os.Error *)} 0x7ffff7f9ef80, tests= []testing.InternalTest = {...}, benchmarks= []testing.InternalBenchmark = {...}) +#3 0x000000000043075b in testing.RunTests (matchString={void (struct string, struct string, bool *, error *)} 0x7ffff7f9ef60, tests= []testing.InternalTest = {...}) at /home/lvd/g/src/pkg/testing/testing.go:201 +#4 0x00000000004302b1 in testing.Main (matchString={void (struct string, struct string, bool *, error *)} 0x7ffff7f9ef80, tests= []testing.InternalTest = {...}, benchmarks= []testing.InternalBenchmark = {...}) at /home/lvd/g/src/pkg/testing/testing.go:168 #5 0x0000000000400dc1 in main.main () at /home/lvd/g/src/pkg/regexp/_testmain.go:98 #6 0x00000000004022e7 in runtime.mainstart () at /home/lvd/g/src/pkg/runtime/amd64/asm.s:78 diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 25f4f3e663799bd1616af8f1ed1a781fa805bff7..86e4d3282d1ca89d8c68a9f257eadd8317b13166 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -276,7 +276,7 @@ /* nil interface */ v[0] = 0; v[1] = 0; } else { - ·_Cerrno(v, e); /* fill in v as os.Error for errno e */ + ·_Cerrno(v, e); /* fill in v as error for errno e */ } }`) } diff --git a/src/cmd/goinstall/main.go b/src/cmd/goinstall/main.go index 431a535f9b6c4ec4f74c5b2d1e47dd36c63f8e29..7414a250525553e579fccf6a4138b2a543ea0bdf 100644 --- a/src/cmd/goinstall/main.go +++ b/src/cmd/goinstall/main.go @@ -304,7 +304,7 @@ } // run runs the command cmd in directory dir with standard input stdin. // If the command fails, run prints the command and output on standard error -// in addition to returning a non-nil os.Error. +// in addition to returning a non-nil error. func run(dir string, stdin []byte, cmd ...string) error { return genRun(dir, stdin, cmd, false) } diff --git a/src/cmd/govet/govet.go b/src/cmd/govet/govet.go index 08b9845b3709abb60bfe6bc69b9a4f151aad48ba..e826f89d71ada7e5f01bb0deb63cea227b77413f 100644 --- a/src/cmd/govet/govet.go +++ b/src/cmd/govet/govet.go @@ -232,23 +232,23 @@ // method doesn't have a fmt.ScanState as its first argument, // we let it go. But if it does have a fmt.ScanState, then the // rest has to match. var canonicalMethods = map[string]MethodSig{ - // "Flush": {{}, {"os.Error"}}, // http.Flusher and jpeg.writer conflict - "Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter - "GobDecode": {[]string{"[]byte"}, []string{"os.Error"}}, // gob.GobDecoder - "GobEncode": {[]string{}, []string{"[]byte", "os.Error"}}, // gob.GobEncoder - "MarshalJSON": {[]string{}, []string{"[]byte", "os.Error"}}, // json.Marshaler - "MarshalXML": {[]string{}, []string{"[]byte", "os.Error"}}, // xml.Marshaler - "Peek": {[]string{"=int"}, []string{"[]byte", "os.Error"}}, // image.reader (matching bufio.Reader) - "ReadByte": {[]string{}, []string{"byte", "os.Error"}}, // io.ByteReader - "ReadFrom": {[]string{"=io.Reader"}, []string{"int64", "os.Error"}}, // io.ReaderFrom - "ReadRune": {[]string{}, []string{"rune", "int", "os.Error"}}, // io.RuneReader - "Scan": {[]string{"=fmt.ScanState", "rune"}, []string{"os.Error"}}, // fmt.Scanner - "Seek": {[]string{"=int64", "int"}, []string{"int64", "os.Error"}}, // io.Seeker - "UnmarshalJSON": {[]string{"[]byte"}, []string{"os.Error"}}, // json.Unmarshaler - "UnreadByte": {[]string{}, []string{"os.Error"}}, - "UnreadRune": {[]string{}, []string{"os.Error"}}, - "WriteByte": {[]string{"byte"}, []string{"os.Error"}}, // jpeg.writer (matching bufio.Writer) - "WriteTo": {[]string{"=io.Writer"}, []string{"int64", "os.Error"}}, // io.WriterTo + // "Flush": {{}, {"error"}}, // http.Flusher and jpeg.writer conflict + "Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter + "GobDecode": {[]string{"[]byte"}, []string{"error"}}, // gob.GobDecoder + "GobEncode": {[]string{}, []string{"[]byte", "error"}}, // gob.GobEncoder + "MarshalJSON": {[]string{}, []string{"[]byte", "error"}}, // json.Marshaler + "MarshalXML": {[]string{}, []string{"[]byte", "error"}}, // xml.Marshaler + "Peek": {[]string{"=int"}, []string{"[]byte", "error"}}, // image.reader (matching bufio.Reader) + "ReadByte": {[]string{}, []string{"byte", "error"}}, // io.ByteReader + "ReadFrom": {[]string{"=io.Reader"}, []string{"int64", "error"}}, // io.ReaderFrom + "ReadRune": {[]string{}, []string{"rune", "int", "error"}}, // io.RuneReader + "Scan": {[]string{"=fmt.ScanState", "rune"}, []string{"error"}}, // fmt.Scanner + "Seek": {[]string{"=int64", "int"}, []string{"int64", "error"}}, // io.Seeker + "UnmarshalJSON": {[]string{"[]byte"}, []string{"error"}}, // json.Unmarshaler + "UnreadByte": {[]string{}, []string{"error"}}, + "UnreadRune": {[]string{}, []string{"error"}}, + "WriteByte": {[]string{"byte"}, []string{"error"}}, // jpeg.writer (matching bufio.Writer) + "WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo } func (f *File) checkMethod(id *ast.Ident, t *ast.FuncType) { @@ -560,11 +560,11 @@ type BadTypeUsedInTests struct { X int "hello" // ERROR "struct field tag" } -func (t *BadTypeUsedInTests) Scan(x fmt.ScanState, c byte) { // ERROR "method Scan[(]x fmt.ScanState, c byte[)] should have signature Scan[(]fmt.ScanState, rune[)] os.Error" +func (t *BadTypeUsedInTests) Scan(x fmt.ScanState, c byte) { // ERROR "method Scan[(]x fmt.ScanState, c byte[)] should have signature Scan[(]fmt.ScanState, rune[)] error" } type BadInterfaceUsedInTests interface { - ReadByte() byte // ERROR "method ReadByte[(][)] byte should have signature ReadByte[(][)] [(]byte, os.Error[)]" + ReadByte() byte // ERROR "method ReadByte[(][)] byte should have signature ReadByte[(][)] [(]byte, error[)]" } // printf is used by the test. diff --git a/src/pkg/compress/bzip2/bit_reader.go b/src/pkg/compress/bzip2/bit_reader.go index 390ee7c92658f9983a110b5b97ec69b6396757d7..d058c14833ba362631b0ca6db3020092bf5de0d3 100644 --- a/src/pkg/compress/bzip2/bit_reader.go +++ b/src/pkg/compress/bzip2/bit_reader.go @@ -10,7 +10,7 @@ "io" ) // bitReader wraps an io.Reader and provides the ability to read values, -// bit-by-bit, from it. Its Read* methods don't return the usual os.Error +// bit-by-bit, from it. Its Read* methods don't return the usual error // because the error handling was verbose. Instead, any error is kept and can // be checked afterwards. type bitReader struct { diff --git a/src/pkg/crypto/rsa/rsa.go b/src/pkg/crypto/rsa/rsa.go index d1b9577cd3dc724edafc373f3dae94bb4c530a11..c9344ffadffecf2ce22c77d648f425cccf5bd77f 100644 --- a/src/pkg/crypto/rsa/rsa.go +++ b/src/pkg/crypto/rsa/rsa.go @@ -55,8 +55,7 @@ R *big.Int // product of primes prior to this (inc p and q). } // Validate performs basic sanity checks on the key. -// It returns nil if the key is valid, or else an os.Error describing a problem. - +// It returns nil if the key is valid, or else an error describing a problem. func (priv *PrivateKey) Validate() error { // Check that the prime factors are actually prime. Note that this is // just a sanity check. Since the random witnesses chosen by diff --git a/src/pkg/crypto/tls/conn.go b/src/pkg/crypto/tls/conn.go index c0523370d61fa52edf9a7919849f93a4f77c9031..6312c34d6d75523b67ce28cd4697e4ba9240c7a6 100644 --- a/src/pkg/crypto/tls/conn.go +++ b/src/pkg/crypto/tls/conn.go @@ -828,7 +828,7 @@ return c.ocspResponse } // VerifyHostname checks that the peer certificate chain is valid for -// connecting to host. If so, it returns nil; if not, it returns an os.Error +// connecting to host. If so, it returns nil; if not, it returns an error // describing the problem. func (c *Conn) VerifyHostname(host string) error { c.handshakeMutex.Lock() diff --git a/src/pkg/crypto/x509/verify.go b/src/pkg/crypto/x509/verify.go index 49056cfa2dbb333c0c60c661ce74aa5d7f15d293..3021d20a67f154f5c03c34a48c64644fbdc97886 100644 --- a/src/pkg/crypto/x509/verify.go +++ b/src/pkg/crypto/x509/verify.go @@ -226,7 +226,7 @@ return true } // VerifyHostname returns nil if c is a valid certificate for the named host. -// Otherwise it returns an os.Error describing the mismatch. +// Otherwise it returns an error describing the mismatch. func (c *Certificate) VerifyHostname(h string) error { if len(c.DNSNames) > 0 { for _, match := range c.DNSNames { diff --git a/src/pkg/exp/ssh/channel.go b/src/pkg/exp/ssh/channel.go index 428e71c8069ada08abc9518ea9132b86aa298431..6ff8203ce27d6cb29f37c9317f60cd111407ca19 100644 --- a/src/pkg/exp/ssh/channel.go +++ b/src/pkg/exp/ssh/channel.go @@ -20,7 +20,7 @@ // other methods on the Channel may be called. If they are then the // peer is likely to signal a protocol error and drop the connection. Reject(reason RejectionReason, message string) error - // Read may return a ChannelRequest as an os.Error. + // Read may return a ChannelRequest as an error. Read(data []byte) (int, error) Write(data []byte) (int, error) Close() error diff --git a/src/pkg/exp/types/gcimporter.go b/src/pkg/exp/types/gcimporter.go index d88af9503111f92cd2dcabd6259c2fb1747be2b6..69dbd5ac5f34c2c766ef66f9f9808d3b82d4d7ae 100644 --- a/src/pkg/exp/types/gcimporter.go +++ b/src/pkg/exp/types/gcimporter.go @@ -188,7 +188,7 @@ func (p *gcParser) error(err interface{}) { if s, ok := err.(string); ok { err = errors.New(s) } - // panic with a runtime.Error if err is not an os.Error + // panic with a runtime.Error if err is not an error panic(importError{p.scanner.Pos(), err.(error)}) } diff --git a/src/pkg/fmt/print.go b/src/pkg/fmt/print.go index 8191ab3b4515c793522b61fd7e0acc5ef230edc7..13456445449b5850bb7c6c31d6a9b9d403860940 100644 --- a/src/pkg/fmt/print.go +++ b/src/pkg/fmt/print.go @@ -198,7 +198,7 @@ return s } // Errorf formats according to a format specifier and returns the string -// as a value that satisfies os.Error. +// as a value that satisfies error. func Errorf(format string, a ...interface{}) error { return errors.New(Sprintf(format, a...)) } diff --git a/src/pkg/go/ast/print.go b/src/pkg/go/ast/print.go index 70c9547e3cd910419a8353aece751606b71aa8cb..fb3068e1e937af928cb9e704b100acb46096f801 100644 --- a/src/pkg/go/ast/print.go +++ b/src/pkg/go/ast/print.go @@ -114,7 +114,7 @@ n += m return } -// localError wraps locally caught os.Errors so we can distinguish +// localError wraps locally caught errors so we can distinguish // them from genuine panics which we don't want to return as errors. type localError struct { err error diff --git a/src/pkg/go/printer/printer.go b/src/pkg/go/printer/printer.go index 2a1445dae3b74aae5dea8837953919d760ea1bf6..8f1ed1159dfb7a8ae2f580f1b5db977e9a828801 100644 --- a/src/pkg/go/printer/printer.go +++ b/src/pkg/go/printer/printer.go @@ -54,7 +54,7 @@ inLiteral pmode = 1 << iota noExtraLinebreak ) -// local error wrapper so we can distinguish os.Errors we want to return +// local error wrapper so we can distinguish errors we want to return // as errors from genuine panics (which we don't want to return as errors) type osError struct { err error diff --git a/src/pkg/go/scanner/errors.go b/src/pkg/go/scanner/errors.go index 7621cf55c160ca29d436d1dc279a04d735729eb8..cd9620b878b78f5814103399099df567655108ac 100644 --- a/src/pkg/go/scanner/errors.go +++ b/src/pkg/go/scanner/errors.go @@ -135,8 +135,8 @@ return list } -// GetError is like GetErrorList, but it returns an os.Error instead -// so that a nil result can be assigned to an os.Error variable and +// GetError is like GetErrorList, but it returns an error instead +// so that a nil result can be assigned to an error variable and // remains nil. // func (h *ErrorVector) GetError(mode int) error { diff --git a/src/pkg/gob/error.go b/src/pkg/gob/error.go index b0c40086d5263edd4be707535fb3535a3ca377b3..fbae8b683da74038a930e055219246e278b6ee88 100644 --- a/src/pkg/gob/error.go +++ b/src/pkg/gob/error.go @@ -9,16 +9,16 @@ // Errors in decoding and encoding are handled using panic and recover. // Panics caused by user error (that is, everything except run-time panics // such as "index out of bounds" errors) do not leave the file that caused -// them, but are instead turned into plain os.Error returns. Encoding and -// decoding functions and methods that do not return an os.Error either use +// them, but are instead turned into plain error returns. Encoding and +// decoding functions and methods that do not return an error either use // panic to report an error or are guaranteed error-free. -// A gobError wraps an os.Error and is used to distinguish errors (panics) generated in this package. +// A gobError is used to distinguish errors (panics) generated in this package. type gobError struct { err error } -// errorf is like error but takes Printf-style arguments to construct an os.Error. +// errorf is like error_ but takes Printf-style arguments to construct an error. // It always prefixes the message with "gob: ". func errorf(format string, args ...interface{}) { error_(fmt.Errorf("gob: "+format, args...)) @@ -30,7 +30,7 @@ panic(gobError{err}) } // catchError is meant to be used as a deferred function to turn a panic(gobError) into a -// plain os.Error. It overwrites the error return of the function that deferred its call. +// plain error. It overwrites the error return of the function that deferred its call. func catchError(err *error) { if e := recover(); e != nil { *err = e.(gobError).err // Will re-panic if not one of our errors, such as a runtime error. diff --git a/src/pkg/old/netchan/import.go b/src/pkg/old/netchan/import.go index 0c00e1574e01109d4eddca626087690c755b5f17..7243672ecd3cc3ec50d2ec85a05a14d8b557a897 100644 --- a/src/pkg/old/netchan/import.go +++ b/src/pkg/old/netchan/import.go @@ -186,7 +186,7 @@ // channel will have buffer space for size values, or 1 value if size < 1. // The channel to be bound to the remote site's channel is provided // in the call and may be of arbitrary channel type. // Despite the literal signature, the effective signature is -// ImportNValues(name string, chT chan T, dir Dir, size, n int) os.Error +// ImportNValues(name string, chT chan T, dir Dir, size, n int) error // Example usage: // imp, err := NewImporter("tcp", "netchanserver.mydomain.com:1234") // if err != nil { log.Fatal(err) } diff --git a/src/pkg/os/dir_plan9.go b/src/pkg/os/dir_plan9.go index abf98768d4c48ab829175af52dd2174681c128c1..263881e0c1c012f5ef41f31fb4907d1100547f65 100644 --- a/src/pkg/os/dir_plan9.go +++ b/src/pkg/os/dir_plan9.go @@ -22,7 +22,7 @@ // // If n <= 0, Readdir returns all the FileInfo from the directory in // a single slice. In this case, if Readdir succeeds (reads all // the way to the end of the directory), it returns the slice and a -// nil os.Error. If it encounters an error before the end of the +// nil error. If it encounters an error before the end of the // directory, Readdir returns the FileInfo read until that point // and a non-nil error. func (file *File) Readdir(n int) (fi []FileInfo, err error) { @@ -87,7 +87,7 @@ // // If n <= 0, Readdirnames returns all the names from the directory in // a single slice. In this case, if Readdirnames succeeds (reads all // the way to the end of the directory), it returns the slice and a -// nil os.Error. If it encounters an error before the end of the +// nil error. If it encounters an error before the end of the // directory, Readdirnames returns the names read until that point and // a non-nil error. func (file *File) Readdirnames(n int) (names []string, err error) { diff --git a/src/pkg/os/dir_unix.go b/src/pkg/os/dir_unix.go index df89a0e82e480c820e4a3e3e6fd01df3ead5f771..e59c1af2ea758c4cdd353455202b07a35c83a6c0 100644 --- a/src/pkg/os/dir_unix.go +++ b/src/pkg/os/dir_unix.go @@ -24,7 +24,7 @@ // // If n <= 0, Readdirnames returns all the names from the directory in // a single slice. In this case, if Readdirnames succeeds (reads all // the way to the end of the directory), it returns the slice and a -// nil os.Error. If it encounters an error before the end of the +// nil error. If it encounters an error before the end of the // directory, Readdirnames returns the names read until that point and // a non-nil error. func (f *File) Readdirnames(n int) (names []string, err error) { diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go index dc8e6f003451d918f5e091b9956cfc2f0419db8f..f4038168fcc199be0bdb0840cf98f0604d91aa7f 100644 --- a/src/pkg/os/file_unix.go +++ b/src/pkg/os/file_unix.go @@ -141,7 +141,7 @@ // // If n <= 0, Readdir returns all the FileInfo from the directory in // a single slice. In this case, if Readdir succeeds (reads all // the way to the end of the directory), it returns the slice and a -// nil os.Error. If it encounters an error before the end of the +// nil error. If it encounters an error before the end of the // directory, Readdir returns the FileInfo read until that point // and a non-nil error. func (file *File) Readdir(n int) (fi []FileInfo, err error) { diff --git a/src/pkg/os/file_windows.go b/src/pkg/os/file_windows.go index 96cadce4d8c835ef45d092e555c831301689f618..a8c36cb1bc55c31bf4cc63254fc05cfc04c89966 100644 --- a/src/pkg/os/file_windows.go +++ b/src/pkg/os/file_windows.go @@ -131,7 +131,7 @@ // // If n <= 0, Readdir returns all the FileInfo from the directory in // a single slice. In this case, if Readdir succeeds (reads all // the way to the end of the directory), it returns the slice and a -// nil os.Error. If it encounters an error before the end of the +// nil error. If it encounters an error before the end of the // directory, Readdir returns the FileInfo read until that point // and a non-nil error. func (file *File) Readdir(n int) (fi []FileInfo, err error) { diff --git a/src/pkg/regexp/all_test.go b/src/pkg/regexp/all_test.go index c707b119bde226811daea6762d565140a07d7002..8810796daf2d4176dad4e665d5a7044aa06cc94d 100644 --- a/src/pkg/regexp/all_test.go +++ b/src/pkg/regexp/all_test.go @@ -32,7 +32,7 @@ /* type stringError struct { re string - err os.Error + err error } var bad_re = []stringError{ diff --git a/src/pkg/rpc/debug.go b/src/pkg/rpc/debug.go index f29ea8dba00059613c247873c028c9607df9e14d..02d577f6779a2126cfcccd1d3549c787cd696941 100644 --- a/src/pkg/rpc/debug.go +++ b/src/pkg/rpc/debug.go @@ -27,7 +27,7 @@ {{range .Method}} - + {{end}} diff --git a/src/pkg/rpc/server.go b/src/pkg/rpc/server.go index 39652b9f4198f3dd61567c016b132e7bbac87732..0f7f0b47a647ad7ef806e7d020c46b684bc532f1 100644 --- a/src/pkg/rpc/server.go +++ b/src/pkg/rpc/server.go @@ -18,12 +18,12 @@ - the method receiver is exported or local (defined in the package registering the service). - the method has two arguments, both exported or local types. - the method's second argument is a pointer. - - the method has return type os.Error. + - the method has return type error. The method's first argument represents the arguments provided by the caller; the second argument represents the result parameters to be returned to the caller. The method's return value, if non-nil, is passed back as a string that the client - sees as an os.ErrorString. + sees as if created by errors.New. The server may handle requests on a single connection by calling ServeConn. More typically it will create a network listener and call Accept or, for an HTTP @@ -55,14 +55,14 @@ } type Arith int - func (t *Arith) Multiply(args *Args, reply *int) os.Error { + func (t *Arith) Multiply(args *Args, reply *int) error { *reply = args.A * args.B return nil } - func (t *Arith) Divide(args *Args, quo *Quotient) os.Error { + func (t *Arith) Divide(args *Args, quo *Quotient) error { if args.B == 0 { - return os.ErrorString("divide by zero") + return errors.New("divide by zero") } quo.Quo = args.A / args.B quo.Rem = args.A % args.B @@ -133,10 +133,9 @@ DefaultRPCPath = "/_goRPC_" DefaultDebugPath = "/debug/rpc" ) -// Precompute the reflect type for os.Error. Can't use os.Error directly +// Precompute the reflect type for error. Can't use error directly // because Typeof takes an empty interface value. This is annoying. -var unusedError *error -var typeOfOsError = reflect.TypeOf(unusedError).Elem() +var typeOfError = reflect.TypeOf((*error)(nil)).Elem() type methodType struct { sync.Mutex // protects counters @@ -210,7 +209,7 @@ // Register publishes in the server the set of methods of the // receiver value that satisfy the following conditions: // - exported method // - two arguments, both pointers to exported structs -// - one return value, of type os.Error +// - one return value, of type error // It returns an error if the receiver is not an exported type or has no // suitable methods. // The client accesses each method using a string of the form "Type.Method", @@ -281,13 +280,13 @@ if !isExportedOrBuiltinType(replyType) { log.Println("method", mname, "reply type not exported or local:", replyType) continue } - // Method needs one out: os.Error. + // Method needs one out: error. if mtype.NumOut() != 1 { log.Println("method", mname, "has wrong number of outs:", mtype.NumOut()) continue } - if returnType := mtype.Out(0); returnType != typeOfOsError { - log.Println("method", mname, "returns", returnType.String(), "not os.Error") + if returnType := mtype.Out(0); returnType != typeOfError { + log.Println("method", mname, "returns", returnType.String(), "not error") continue } s.method[mname] = &methodType{method: method, ArgType: argType, ReplyType: replyType} @@ -339,7 +338,7 @@ mtype.Unlock() function := mtype.method.Func // Invoke the method, providing a new value for the reply. returnValues := function.Call([]reflect.Value{s.rcvr, argv, replyv}) - // The return value for the method is an os.Error. + // The return value for the method is an error. errInter := returnValues[0].Interface() errmsg := "" if errInter != nil { diff --git a/src/pkg/runtime/error.go b/src/pkg/runtime/error.go index 13dc52b32aaa52a34ec64b8e5f4020d21787dd56..4b0ee4931ee8179765af3785522b0ccb9bbdf8ba 100644 --- a/src/pkg/runtime/error.go +++ b/src/pkg/runtime/error.go @@ -10,7 +10,7 @@ error // RuntimeError is a no-op function but // serves to distinguish types that are runtime - // errors from ordinary os.Errors: a type is a + // errors from ordinary errors: a type is a // runtime error if it has a RuntimeError method. RuntimeError() } diff --git a/src/pkg/smtp/auth.go b/src/pkg/smtp/auth.go index c4cdcb130d2dd352fd3f7b30f2739a3e4cfb69a4..10a757fc64307f1c420145f594e74d0d7dfd8df5 100644 --- a/src/pkg/smtp/auth.go +++ b/src/pkg/smtp/auth.go @@ -13,7 +13,7 @@ // It returns the name of the authentication protocol // and optionally data to include in the initial AUTH message // sent to the server. It can return proto == "" to indicate // that the authentication should be skipped. - // If it returns a non-nil os.Error, the SMTP client aborts + // If it returns a non-nil error, the SMTP client aborts // the authentication attempt and closes the connection. Start(server *ServerInfo) (proto string, toServer []byte, err error) @@ -21,7 +21,7 @@ // Next continues the authentication. The server has just sent // the fromServer data. If more is true, the server expects a // response, which Next should return as toServer; otherwise // Next should return toServer == nil. - // If Next returns a non-nil os.Error, the SMTP client aborts + // If Next returns a non-nil error, the SMTP client aborts // the authentication attempt and closes the connection. Next(fromServer []byte, more bool) (toServer []byte, err error) } diff --git a/src/pkg/tabwriter/tabwriter.go b/src/pkg/tabwriter/tabwriter.go index 670e3c53909a1302d263ff34240bbbc45782aeb6..d588b385d2e88ade3f96d9dd33f33ab4887e3ee1 100644 --- a/src/pkg/tabwriter/tabwriter.go +++ b/src/pkg/tabwriter/tabwriter.go @@ -212,7 +212,7 @@ } print("\n") } -// local error wrapper so we can distinguish os.Errors we want to return +// local error wrapper so we can distinguish errors we want to return // as errors from genuine panics (which we don't want to return as errors) type osError struct { err error diff --git a/src/pkg/template/doc.go b/src/pkg/template/doc.go index a52f32d91b942c3ceab6d520480e7a4db3923029..42f9e560be148b733e542d21c88dbfa648f8322a 100644 --- a/src/pkg/template/doc.go +++ b/src/pkg/template/doc.go @@ -117,7 +117,7 @@ such as .Method The result is the value of invoking the method with dot as the receiver, dot.Method(). Such a method must have one return value (of - any type) or two return values, the second of which is an os.Error. + any type) or two return values, the second of which is an error. If it has two and the returned error is non-nil, execution terminates and an error is returned to the caller as the value of Execute. Method invocations may be chained and combined with fields and keys @@ -159,7 +159,7 @@ passed as the last argument of the following command. The output of the final command in the pipeline is the value of the pipeline. The output of a command will be either one value or two values, the second of -which has type os.Error. If that second value is present and evaluates to +which has type error. If that second value is present and evaluates to non-nil, execution terminates and the error is returned to the caller of Execute. diff --git a/src/pkg/template/exec.go b/src/pkg/template/exec.go index 7850f6daf5a39f931b67a4e3cd772a5aeadf4aba..228477ce7972d32f1beaebabdfb05c197bb82e25 100644 --- a/src/pkg/template/exec.go +++ b/src/pkg/template/exec.go @@ -492,7 +492,7 @@ if final.IsValid() { argv[i] = final } result := fun.Call(argv) - // If we have an os.Error that is not nil, stop execution and return that error to the caller. + // If we have an error that is not nil, stop execution and return that error to the caller. if len(result) == 2 && !result[1].IsNil() { s.errorf("error calling %s: %s", name, result[1].Interface().(error)) } diff --git a/src/pkg/template/exec_test.go b/src/pkg/template/exec_test.go index 20839c3e348a296a4838ba71c23b111f304f3643..e32de4d40ffbbd933363de58c731320ecf33bbe7 100644 --- a/src/pkg/template/exec_test.go +++ b/src/pkg/template/exec_test.go @@ -158,7 +158,7 @@ sort.Strings(keys) return keys } -// EPERM returns a value and an os.Error according to its argument. +// EPERM returns a value and an error according to its argument. func (t *T) EPERM(error bool) (bool, error) { if error { return true, os.EPERM diff --git a/src/pkg/template/funcs.go b/src/pkg/template/funcs.go index 59c2ee708c368c4d57826575fe4c5505ebe1c8b4..26c3a6e8488622bfffdd2889b300dff8fc139ada 100644 --- a/src/pkg/template/funcs.go +++ b/src/pkg/template/funcs.go @@ -17,7 +17,7 @@ ) // FuncMap is the type of the map defining the mapping from names to functions. // Each function must have either a single return value, or two return values of -// which the second has type os.Error. If the second argument evaluates to non-nil +// which the second has type error. If the second argument evaluates to non-nil // during execution, execution terminates and Execute returns an error. type FuncMap map[string]interface{} @@ -68,7 +68,7 @@ } // goodFunc checks that the function or method has the right result signature. func goodFunc(typ reflect.Type) bool { - // We allow functions with 1 result or 2 results where the second is an os.Error. + // We allow functions with 1 result or 2 results where the second is an error. switch { case typ.NumOut() == 1: return true diff --git a/src/pkg/template/helper.go b/src/pkg/template/helper.go index b7a9deeba97736fa8e731233ac113390b7c0d537..a743a8326ec255f6715d5e8b3e0b492ea6fd9fe9 100644 --- a/src/pkg/template/helper.go +++ b/src/pkg/template/helper.go @@ -14,7 +14,7 @@ ) // Functions and methods to parse a single template. -// Must is a helper that wraps a call to a function returning (*Template, os.Error) +// Must is a helper that wraps a call to a function returning (*Template, error) // and panics if the error is non-nil. It is intended for use in variable initializations // such as // var t = template.Must(template.New("name").Parse("text")) @@ -66,7 +66,7 @@ } // Functions and methods to parse a set. -// SetMust is a helper that wraps a call to a function returning (*Set, os.Error) +// SetMust is a helper that wraps a call to a function returning (*Set, error) // and panics if the error is non-nil. It is intended for use in variable initializations // such as // var s = template.SetMust(template.ParseSetFiles("file")) diff --git a/src/pkg/utf8/string.go b/src/pkg/utf8/string.go index ce430ba4f599a2f60b9352805c564165233c6491..443decf056cdea432e314243d00251ca11c00123 100644 --- a/src/pkg/utf8/string.go +++ b/src/pkg/utf8/string.go @@ -4,6 +4,8 @@ // license that can be found in the LICENSE file. package utf8 +import "errors" + // String wraps a regular string with a small structure that provides more // efficient indexing by code point index, as opposed to byte index. // Scanning incrementally forwards or backwards is O(1) per index operation @@ -193,19 +195,5 @@ } return r } -// We want the panic in At(i) to satisfy os.Error, because that's what -// runtime panics satisfy, but we can't import os. This is our solution. - -// error is the type of the error returned if a user calls String.At(i) with i out of range. -// It satisfies os.Error and runtime.Error. -type error_ string - -func (err error_) String() string { - return string(err) -} - -func (err error_) RunTimeError() { -} - -var outOfRange = error_("utf8.String: index out of range") -var sliceOutOfRange = error_("utf8.String: slice index out of range") +var outOfRange = errors.New("utf8.String: index out of range") +var sliceOutOfRange = errors.New("utf8.String: slice index out of range")
MethodCalls
{{.Name}}({{.Type.ArgType}}, {{.Type.ReplyType}}) os.Error{{.Name}}({{.Type.ArgType}}, {{.Type.ReplyType}}) error {{.Type.NumCalls}}