mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-11-01 18:42:34 +00:00
fmt code
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
```go
|
||||
type error interface {
|
||||
Error() string
|
||||
Error() string
|
||||
}
|
||||
```
|
||||
|
||||
@@ -46,17 +46,17 @@ package syscall
|
||||
type Errno uintptr // operating system error code
|
||||
|
||||
var errors = [...]string{
|
||||
1: "operation not permitted", // EPERM
|
||||
2: "no such file or directory", // ENOENT
|
||||
3: "no such process", // ESRCH
|
||||
// ...
|
||||
1: "operation not permitted", // EPERM
|
||||
2: "no such file or directory", // ENOENT
|
||||
3: "no such process", // ESRCH
|
||||
// ...
|
||||
}
|
||||
|
||||
func (e Errno) Error() string {
|
||||
if 0 <= int(e) && int(e) < len(errors) {
|
||||
return errors[e]
|
||||
}
|
||||
return fmt.Sprintf("errno %d", e)
|
||||
if 0 <= int(e) && int(e) < len(errors) {
|
||||
return errors[e]
|
||||
}
|
||||
return fmt.Sprintf("errno %d", e)
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user