mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
syscall: make plan9 Errno implement the error interface
The Errno type was added to plan9 in CL 750680 but without methods, so it didn't satisfy the error interface. Add Error, Temporary, and Timeout methods to match all other platforms and the Go 1 API contract (api/go1.txt's "pkg syscall, method (Errno) Error() string", etc). And add a test that all platforms have Errno, implementing error. Change-Id: Ie96fe03a31940d52c5bb7828aa1b743d15a9c4ee Reviewed-on: https://go-review.googlesource.com/c/go/+/751100 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
@@ -14,6 +14,7 @@ package syscall
|
||||
import (
|
||||
"errors"
|
||||
"internal/oserror"
|
||||
"internal/strconv"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -30,6 +31,10 @@ const bitSize16 = 2
|
||||
// without build-tagged files, using runtime.GOOS checks instead.
|
||||
type Errno uintptr
|
||||
|
||||
func (e Errno) Error() string { return "errno " + strconv.Itoa(int(e)) }
|
||||
func (e Errno) Temporary() bool { return false }
|
||||
func (e Errno) Timeout() bool { return false }
|
||||
|
||||
// ErrorString implements Error's String method by returning itself.
|
||||
//
|
||||
// ErrorString values can be tested against error values using [errors.Is].
|
||||
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Errno must implement error on all platforms, including plan9.
|
||||
var _ error = syscall.Errno(0)
|
||||
|
||||
func testSetGetenv(t *testing.T, key, value string) {
|
||||
err := syscall.Setenv(key, value)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user