This is a creation in Article, where the information may have evolved or changed.
Reprinted from http://www.fenby.com/blog/blog/113
Package builtin
import "builtin"
Overview
Index
Overview▾
Package Builtin provides documentation for Go ' s predeclared identifiers. The items documented here is not actually in package builtin but their descriptions here allow Godoc to present documenta tion for the language ' s special identifiers.
Index▾
Constants
Func Append (Slice []type, Elems ... Type) []type
Func Cap (v Type) int
Func Close (c chan<-Type)
Func Complex (R, I floattype) ComplexType
Func copy (DST, src []type) int
Func Delete (M map[type]type1, key Type)
Func imag (c ComplexType) Floattype
Func len (v Type) int
Func make (type, size Integertype) Type
Func new (Type) *type
Func Panic (v interface{})
Func Real (c ComplexType) Floattype
Func recover () interface{}
Type ComplexType
Type Floattype
Type Integertype
Type type
Type Type1
type bool
Type byte
Type complex128
Type complex64
Type error
Type float32
Type float64
type int
Type Int16
Type int32
Type Int64
Type int8
Type Rune
Type string
Type UINT
Type UInt16
Type UInt32
Type UInt64
Type Uint8
Type UIntPtr
Package files
Builtin.go
Constants
Const ( true = 0 = = 0//untyped bool. False = 0! = 0//untyped bool.)
True and False are the untyped Boolean values.
Const IOTA = 0//untyped int.
Iota is a predeclared identifier representing the untyped integer ordinal number of the current const specification in a ( usually parenthesized) const declaration. It is zero-indexed.
Func Append
Func Append (Slice []type, Elems ... Type) []type
The Append built-in function appends elements to the end of a slice. If it has sufficient capacity, the destination are resliced to accommodate the new elements. If it does not, a new underlying array would be allocated. Append returns the updated slice. It is therefore necessary to store the result of append, often in the variable holding the slice itself:
Slice = append (slice, elem1, elem2) slice = append (slice, anotherslice ...)
As a special case, it was legal to append a string to a byte slice, like this:
Slice = Append ([]byte ("Hello"), "World" ...)
Func cap
Func Cap (v Type) int
The CAP built-in function returns the capacity of V, according to its type:
Array:the number of elements in V (same as Len (v)). Pointer to array:the number of elements in *v (same as Len (v)). Slice:the Maximum length The Slice can reach when Resliced;if v are nil, cap (v) is zero. Channel:the channel buffer capacity, in units of Elements;if v are nil, cap (v) is zero.
Func Close
Func Close (c chan<-Type)
The close built-in function closes a channel, which must be either bidirectional or send-only. It should is executed only by the sender, never the receiver, and have the effect of the shutting down the channel after the LA St sent value is received. After the last value have been received from a closed channel C, any receive from C would succeed without blocking, Returnin G The zero value for the channel element. The form
X, OK: = <-c
would also set OK to false for a closed channel.
Func Complex
Func Complex (R, I floattype) ComplexType
The complex built-in function constructs a complex value from both floating-point values. The real and imaginary parts must is of the same size, either float32 or float64 (or assignable to them), and the return V Alue'll is the corresponding complex type (complex64 for float32, complex128 for float64).
Func copy
Func copy (DST, src []type) int
The copy built-in function copies elements from a source slice into a destination slice. (as a special case, it also would copy bytes from a string to a slice of bytes.) The source and destination may overlap. Copy returns the number of elements copied, which would be the minimum of Len (SRC) and Len (DST).
Func Delete
Func Delete (M map[type]type1, key Type)
The Delete built-in function deletes the element with the specified key (M[key]) from the map. If m is nil or there are no such element, delete is a no-op.
Func imag
Func imag (c ComplexType) Floattype
The Imag built-in function returns the imaginary part of the complex number C. The return value is floating point type corresponding to the type of C.
Func len
Func len (v Type) int
The Len built-in function returns the length of V, according to its type:
Array:the number of elements in V.pointer to array:the number of elements in *v (even if V is nil). Slice, or map:the number of elements in V; If V is nil and Len (v) is zero. String:the number of bytes in v.channel:the number of elements queued (unread) in the Channel Buffer;if v is nil, Len (v) is zero.
Func make
Func make (type, size Integertype) Type
The Make built-in function allocates and initializes a object of type slice, map, or Chan (only). Like new, the first argument was a type, not a value. Unlike new, make's return type is the same as the type of its argument, and not a pointer to it. The specification of the result depends on the type:
Slice:the size Specifies the length. The capacity of the slice isequal to its length. A second integer argument may be provided tospecify a different capacity; It must is no smaller than thelength, so make ([]int, 0, ten) allocates a slice of length 0 andcapacity 10.map:an Initial A Llocation is made according to the size but theresulting map has length 0. The size may be omitted, in which Casea small starting size is allocated. Channel:the Channel ' s buffer is initialized with the specifiedbuffer capacity. If Zero, or the size is omitted, the channel isunbuffered.
Func New
Func new (Type) *type
The new built-in function allocates memory. The first argument is a type, not a value, and the value returned are a pointer to a newly allocated zero value of that Typ E.
Func Panic
Func Panic (v interface{})
The panic built-in function stops normal execution of the current goroutine. When a function f calls panic, normal execution of F stops immediately. Any functions whose execution is deferred by F is run in the usual a, and then F returns to its caller. To the caller G, the invocation of F then behaves like a call to panic, terminating G's execution and running any deferred Functions. This continues until all functions in the executing goroutine has stopped, in reverse order. at (that), the program is terminated and the error condition are reported, including the value of the argument to panic . This termination sequence are called panicking and can be controlled by the built-in function recover.
Func Real
Func Real (c ComplexType) Floattype
The real built-in function returns the real part of the complex number C. The return value is floating point type corresponding to the type of C.
Func Recover
Func recover () interface{}
The Recover built-in function allows a program to manage behavior of a panicking goroutine. Executing a call-to-recover inside a deferred function (but no function called by it) stops the panicking sequence by Restoring normal execution and retrieves the error value passed to the call of panic. If recover is called outside the deferred function it would not stop a panicking sequence. In this case, or when the goroutine are not panicking, or if the argument supplied to panic was nil, recover returns nil. Thus the return value from recover reports whether the goroutine is panicking.
Type ComplexType
Type ComplexType complex64
ComplexType is here for the purposes of documentation only. It's a stand-in for either complex type:complex64 or complex128.
Type Floattype
Type Floattype float32
Floattype is here for the purposes of documentation only. It's a stand-in for either float Type:float32 or float64.
Type Integertype
Type Integertype int
Integertype is here for the purposes of documentation only. It's a stand-in for any integer type:int, uint, int8 etc.
Type type
Type type int
purposes of documentation only. It is a stand-in for any Go type, but represents the same type for any given function invocation.
var nil type//type must be a pointer, channel, Func, interface, map, or slice type
Nil is a predeclared identifier representing the zero value for a pointer, channel, Func, interface, map, or slice type.
Type Type1
Type Type1 int
Type1 is here for the purposes of documentation only. It is a stand-in for any Go type, but represents the same type for any given function invocation.
type bool
type bool BOOL
BOOL is the set of Boolean values, True and false.
Type byte
Type byte byte
Byte is a alias for uint8 and are equivalent to uint8 in all ways. It is used, by convention, to distinguish byte values from 8-bit unsigned integer values.
Type complex128
Type complex128 complex128
Complex128 is the set of all complex numbers with float64 real and imaginary parts.
Type complex64
Type complex64 complex64
Complex64 is the set of all complex numbers with float32 real and imaginary parts.
Type error
Type Error Interface { error () string}
The error built-in interface type is the conventional interface for representing a error condition, with the nil value re Presenting no error.
Type float32
Type float32 float32
Float32 is the set of all IEEE-754 32-bit floating-point numbers.
Type float64
Type float64 float64
Float64 is the set of all IEEE-754 64-bit floating-point numbers.
type int
type int int
An int is a signed an integer type that's at least a size. It is a distinct type, however, and isn't an alias for, say, Int32.
Type Int16
Type Int16 int16
Int16 is the set of all signed 16-bit integers. Range: -32768 through 32767.
Type int32
Type int32 int32
Int32 is the set of all signed 32-bit integers. Range: -2147483648 through 2147483647.
Type Int64
Type Int64 Int64
Int64 is the set of all signed 64-bit integers. Range: -9223372036854775808 through 9223372036854775807.
Type int8
Type int8 int8
Int8 is the set of all signed 8-bit integers. Range: -128 through 127.
Type Rune
Type Rune Rune
Rune is a alias for Int32 and was equivalent to int32 in all ways. It is used, by convention, to distinguish character values from integer values.
Type string
Type string string
String is the set of all strings of 8-bit bytes, conventionally and not necessarily representing utf-8-encoded text. A string may be empty and not nil. Values of string type are immutable.
Type UINT
Type UINT UINT
UINT is a unsigned integer type is at least-a size. It is a distinct type, however, and isn't an alias for, say, UInt32.
Type UInt16
Type UInt16 uint16
UInt16 is the set of all unsigned 16-bit integers. Range:0 through 65535.
Type UInt32
Type UInt32 UInt32
UInt32 is the set of all unsigned 32-bit integers. Range:0 through 4294967295.
Type UInt64
Type UInt64 UInt64
UInt64 is the set of all unsigned 64-bit integers. Range:0 through 18446744073709551615.
Type Uint8
Type Uint8 uint8
Uint8 is the set of all unsigned 8-bit integers. Range:0 through 255.
Type UIntPtr
Type UIntPtr uintptr
UIntPtr is a integer type that's large enough to hold the bit pattern of any pointer.