Skip to content

Commit 0543bf0

Browse files
authored
Merge pull request #1996 from xushiwei/q
mini spec: errors
2 parents 467331f + 049541f commit 0543bf0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

doc/spec-mini.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,22 @@ error
449449
any
450450
```
451451

452+
#### Errors
453+
454+
The predeclared type `error` is defined as
455+
456+
```go
457+
type error interface {
458+
Error() string
459+
}
460+
```
461+
462+
It is the conventional interface for representing an `error` condition, with the nil value representing no error. For instance, a function to read data from a file might be defined:
463+
464+
```go
465+
func Read(f *File, b []byte) (n int, err error)
466+
```
467+
452468
### Classes
453469

454470
TODO (classfile)
@@ -1878,6 +1894,6 @@ func main() { … }
18781894
Program execution begins by [initializing the program](#program-initialization) and then invoking the function `main` in package `main`. When that function invocation returns, the program exits. It does not wait for other (non-main) goroutines to complete.
18791895

18801896

1881-
## Errors
1897+
### Run-time panics¶
18821898

18831899
TODO

0 commit comments

Comments
 (0)