Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
d9877e22
Commit
d9877e22
authored
Nov 01, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec: add error
R=golang-dev, dsymonds, r, r CC=golang-dev
https://golang.org/cl/5308072
parent
9a056354
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
14 deletions
+34
-14
doc/go_spec.html
doc/go_spec.html
+34
-14
No files found.
doc/go_spec.html
View file @
d9877e22
<!-- title The Go Programming Language Specification -->
<!-- title The Go Programming Language Specification -->
<!-- subtitle Version of
October 25
, 2011 -->
<!-- subtitle Version of
November 1
, 2011 -->
<!--
<!--
TODO
TODO
...
@@ -1498,12 +1498,10 @@ the body of any nested function.
...
@@ -1498,12 +1498,10 @@ the body of any nested function.
The following identifiers are implicitly declared in the universe block:
The following identifiers are implicitly declared in the universe block:
</p>
</p>
<pre
class=
"grammar"
>
<pre
class=
"grammar"
>
Basic types:
Types:
bool byte complex64 complex128 float32 float64
bool byte complex64 complex128 error float32 float64
int8 int16 int32 int64 rune string uint8 uint16 uint32 uint64
int int8 int16 int32 int64 rune string
uint uint8 uint16 uint32 uint64 uintptr
Architecture-specific convenience types:
int uint uintptr
Constants:
Constants:
true false iota
true false iota
...
@@ -4323,7 +4321,7 @@ func complex_f3() (re float64, im float64) {
...
@@ -4323,7 +4321,7 @@ func complex_f3() (re float64, im float64) {
return
return
}
}
func (devnull) Write(p []byte) (n int, _
os.E
rror) {
func (devnull) Write(p []byte) (n int, _
e
rror) {
n = len(p)
n = len(p)
return
return
}
}
...
@@ -5172,6 +5170,28 @@ the <code>init</code> functions: it will not start the next
...
@@ -5172,6 +5170,28 @@ the <code>init</code> functions: it will not start the next
the previous one has returned.
the previous one has returned.
</p>
</p>
<h2
id=
"Errors"
>
Errors
</h2>
<p>
The predeclared type
<code>
error
</code>
is defined as
</p>
<pre>
type error interface {
Error() string
}
</pre>
<p>
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:
</p>
<pre>
func Read(f *File, b []byte) (n int, err error)
</pre>
<h2
id=
"Run_time_panics"
>
Run-time panics
</h2>
<h2
id=
"Run_time_panics"
>
Run-time panics
</h2>
<p>
<p>
...
@@ -5179,18 +5199,18 @@ Execution errors such as attempting to index an array out
...
@@ -5179,18 +5199,18 @@ Execution errors such as attempting to index an array out
of bounds trigger a
<i>
run-time panic
</i>
equivalent to a call of
of bounds trigger a
<i>
run-time panic
</i>
equivalent to a call of
the built-in function
<a
href=
"#Handling_panics"
><code>
panic
</code></a>
the built-in function
<a
href=
"#Handling_panics"
><code>
panic
</code></a>
with a value of the implementation-defined interface type
<code>
runtime.Error
</code>
.
with a value of the implementation-defined interface type
<code>
runtime.Error
</code>
.
That type
defines at least the method
That type
satisfies the predeclared interface type
<
code>
String() string
</code>
. The exact error values that
<
a
href=
"#Errors"
><code>
error
</code></a>
.
represent distinct run-time error conditions are unspecified,
The exact error values that
at least for now
.
represent distinct run-time error conditions are unspecified
.
</p>
</p>
<pre>
<pre>
package runtime
package runtime
type Error interface {
type Error interface {
String() string
error
// and perhaps others
// and perhaps other
method
s
}
}
</pre>
</pre>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment