diff --git a/internal/lib/_errors/errors.go b/internal/lib/_errors/errors.go deleted file mode 100644 index 5f95bdef..00000000 --- a/internal/lib/_errors/errors.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package errors - -// llgo:skipall -import ( - _ "unsafe" -) - -// Unwrap returns the result of calling the Unwrap method on err, if err's -// type contains an Unwrap method returning error. -// Otherwise, Unwrap returns nil. -// -// Unwrap only calls a method of the form "Unwrap() error". -// In particular Unwrap does not unwrap errors returned by [Join]. -func Unwrap(err error) error { - u, ok := err.(interface { - Unwrap() error - }) - if !ok { - return nil - } - return u.Unwrap() -} - -// New returns an error that formats as the given text. -// Each call to New returns a distinct error value even if the text is identical. -func New(text string) error { - return &errorString{text} -} - -// errorString is a trivial implementation of error. -type errorString struct { - s string -} - -func (e *errorString) Error() string { - return e.s -} - -// ErrUnsupported indicates that a requested operation cannot be performed, -// because it is unsupported. For example, a call to [os.Link] when using a -// file system that does not support hard links. -// -// Functions and methods should not return this error but should instead -// return an error including appropriate context that satisfies -// -// errors.Is(err, errors.ErrUnsupported) -// -// either by directly wrapping ErrUnsupported or by implementing an Is method. -// -// Functions and methods should document the cases in which an error -// wrapping this will be returned. -var ErrUnsupported = New("unsupported operation") diff --git a/internal/lib/syscall/syscall_unix.go b/internal/lib/syscall/syscall_unix.go index 30d66e4f..73755270 100644 --- a/internal/lib/syscall/syscall_unix.go +++ b/internal/lib/syscall/syscall_unix.go @@ -7,7 +7,6 @@ package syscall import ( - "errors" "unsafe" "github.com/goplus/llgo/c" @@ -35,8 +34,9 @@ func (e Errno) Is(target error) bool { return e == EEXIST || e == ENOTEMPTY case oserror.ErrNotExist: return e == ENOENT - case errors.ErrUnsupported: - return e == ENOSYS || e == ENOTSUP || e == EOPNOTSUPP + // TODO(xsw): go1.21 + // case errors.ErrUnsupported: + // return e == ENOSYS || e == ENOTSUP || e == EOPNOTSUPP } return false }