func Read(f *File, b []byte) (n int, err error)
type error interface {
Error() string
}
panic(42)
panic("unreachable")
panic(Error("cannot parse"))
package runtime
type Error interface {
error
// and perhaps other methods
}
type Reader interface {
Read(p []byte) (n int, err error)
Close() error
}
type Writer interface {
Write(p []byte) (n int, err error)
Close() error
}
// ReadWriter's methods are Read, Write, and Close.
type ReadWriter interface {
Reader // includes methods of Reader in ReadWriter's method set
Writer // includes methods of Writer in ReadWriter's method set
}
// A simple File interface.
interface {
Read([]byte) (int, error)
Write([]byte) (int, error)
Close() error
}
func (p T) Read(p []byte) (n int, err error)
func (p T) Write(p []byte) (n int, err error)
func (p T) Close() error
type MyInt int
interface {
~[]byte // the underlying type of []byte is itself
~MyInt // illegal: the underlying type of MyInt is not MyInt
~error // illegal: error is an interface
}
func f(n int) (res int, err error) {
if _, err := f(n-1); err != nil {
return // invalid return statement: err is shadowed
}
return
}
Types:
any bool byte comparable
complex64 complex128 error float32 float64
int int8 int16 int32 int64 rune string
uint uint8 uint16 uint32 uint64 uintptr
Constants:
true false iota
Zero value:
nil
Functions:
append cap close complex copy delete imag len
make new panic print println real recover
Recommend
The Go Programming Language Specification Errors
The Go Programming Language Specification Program initialization and execution Program execution
The Go Programming Language Specification Program initialization and execution The zero value
The Go Programming Language Specification Packages An example package
The Go Programming Language Specification Packages Import declarations
The Go Programming Language Specification Packages Package clause
The Go Programming Language Specification Packages Source file organization
The Go Programming Language Specification Built-in functions Bootstrapping
The Go Programming Language Specification Built-in functions Handling panics
The Go Programming Language Specification Built-in functions Manipulating complex numbers
The Go Programming Language Specification Built-in functions Deletion of map elements
The Go Programming Language Specification Built-in functions Appending to and copying slices
The Go Programming Language Specification Built-in functions Making slices, maps and channels
The Go Programming Language Specification Built-in functions Allocation
The Go Programming Language Specification Built-in functions Length and capacity
The Go Programming Language Specification Statements Defer statements
The Go Programming Language Specification Statements Fallthrough statements
The Go Programming Language Specification Statements Goto statements
The Go Programming Language Specification Statements Continue statements
The Go Programming Language Specification Statements Break statements
The Go Programming Language Specification Statements Return statements
The Go Programming Language Specification Statements Select statements
The Go Programming Language Specification Statements Go statements
The Go Programming Language Specification Statements For statements For statements with range clause
The Go Programming Language Specification Statements For statements For statements with for clause
The Go Programming Language Specification Statements For statements
The Go Programming Language Specification Statements Switch statements Type switches
The Go Programming Language Specification Statements Switch statements Expression switches
The Go Programming Language Specification Statements Switch statements
The Go Programming Language Specification Statements If statements
The Go Programming Language Specification Statements Assignments
The Go Programming Language Specification Statements IncDec statements
The Go Programming Language Specification Statements Send statements
The Go Programming Language Specification Statements Expression statements
The Go Programming Language Specification Statements Labeled statements
The Go Programming Language Specification Statements Empty statements
The Go Programming Language Specification Statements
The Go Programming Language Specification Expressions Order of evaluation
The Go Programming Language Specification Expressions Constant expressions
The Go Programming Language Specification Expressions Conversions