package builtin

Import Path
	builtin (on go.dev)

Involved Source Files Package builtin provides documentation for Go's predeclared identifiers. The items documented here are not actually in package builtin but their descriptions here allow godoc to present documentation for the language's special identifiers.
Package-Level Type Names (total 22)
/* sort by: | */
any is an alias for interface{} and is equivalent to interface{} in all ways.
bool is the set of boolean values, true and false.
byte is an alias for uint8 and is equivalent to uint8 in all ways. It is used, by convention, to distinguish byte values from 8-bit unsigned integer values.
comparable is an interface that is implemented by all comparable types (booleans, numbers, strings, pointers, channels, arrays of comparable types, structs whose fields are all comparable types). The comparable interface may only be used as a type parameter constraint, not as the type of a variable.
complex128 is the set of all complex numbers with float64 real and imaginary parts.
complex64 is the set of all complex numbers with float32 real and imaginary parts.
The error built-in interface type is the conventional interface for representing an error condition, with the nil value representing no error. ( error) Error() string compress/bzip2.StructuralError compress/flate.CorruptInputError compress/flate.InternalError *compress/flate.ReadError *compress/flate.WriteError crypto/aes.KeySizeError crypto/des.KeySizeError crypto/rc4.KeySizeError crypto/tls.AlertError *crypto/tls.CertificateVerificationError crypto/tls.RecordHeaderError crypto/x509.CertificateInvalidError crypto/x509.ConstraintViolationError crypto/x509.HostnameError crypto/x509.InsecureAlgorithmError crypto/x509.SystemRootsError crypto/x509.UnhandledCriticalExtension crypto/x509.UnknownAuthorityError debug/dwarf.DecodeError *debug/elf.FormatError *debug/gosym.DecodingError debug/gosym.UnknownFileError *debug/gosym.UnknownLineError *debug/macho.FormatError *debug/pe.FormatError encoding/ascii85.CorruptInputError encoding/asn1.StructuralError encoding/asn1.SyntaxError encoding/base32.CorruptInputError encoding/base64.CorruptInputError *encoding/csv.ParseError encoding/hex.InvalidByteError *encoding/json.InvalidUnmarshalError *encoding/json.InvalidUTF8Error *encoding/json.MarshalerError *encoding/json.SyntaxError *encoding/json.UnmarshalFieldError *encoding/json.UnmarshalTypeError *encoding/json.UnsupportedTypeError *encoding/json.UnsupportedValueError *encoding/xml.SyntaxError *encoding/xml.TagPathError encoding/xml.UnmarshalError *encoding/xml.UnsupportedTypeError *go/build.MultiplePackageError *go/build.NoGoError *go/build/constraint.SyntaxError go/scanner.Error go/scanner.ErrorList *go/types.ArgumentError go/types.Error *html/template.Error image/jpeg.FormatError image/jpeg.UnsupportedError image/png.FormatError image/png.UnsupportedError *internal/fuzz.MalformedCorpusError *internal/poll.DeadlineExceededError *internal/reflectlite.ValueError *internal/testpty.PtyError *io/fs.PathError math/big.ErrNaN *net.AddrError *net.DNSConfigError *net.DNSError net.Error (interface) net.InvalidAddrError *net.OpError *net.ParseError net.UnknownNetworkError *net/http.MaxBytesError *net/http.ProtocolError net/rpc.ServerError *net/textproto.Error net/textproto.ProtocolError *net/url.Error net/url.EscapeError net/url.InvalidHostError *os.LinkError *os.SyscallError *os/exec.Error *os/exec.ExitError os/user.UnknownGroupError os/user.UnknownGroupIdError os/user.UnknownUserError os/user.UnknownUserIdError *reflect.ValueError *regexp/syntax.Error runtime.Error (interface) *runtime.PanicNilError *runtime.TypeAssertionError *strconv.NumError syscall.Errno *testing/quick.CheckEqualError *testing/quick.CheckError testing/quick.SetupError text/template.ExecError *time.ParseError vendor/golang.org/x/net/http2/hpack.DecodingError vendor/golang.org/x/net/http2/hpack.InvalidIndexError
float32 is the set of all IEEE-754 32-bit floating-point numbers.
float64 is the set of all IEEE-754 64-bit floating-point numbers.
int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.
int16 is the set of all signed 16-bit integers. Range: -32768 through 32767.
int32 is the set of all signed 32-bit integers. Range: -2147483648 through 2147483647.
int64 is the set of all signed 64-bit integers. Range: -9223372036854775808 through 9223372036854775807.
int8 is the set of all signed 8-bit integers. Range: -128 through 127.
rune is an alias for int32 and is equivalent to int32 in all ways. It is used, by convention, to distinguish character values from integer values.
string is the set of all strings of 8-bit bytes, conventionally but not necessarily representing UTF-8-encoded text. A string may be empty, but not nil. Values of string type are immutable.
uint is an unsigned integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, uint32.
uint16 is the set of all unsigned 16-bit integers. Range: 0 through 65535.
uint32 is the set of all unsigned 32-bit integers. Range: 0 through 4294967295.
uint64 is the set of all unsigned 64-bit integers. Range: 0 through 18446744073709551615.
uint8 is the set of all unsigned 8-bit integers. Range: 0 through 255.
uintptr is an integer type that is large enough to hold the bit pattern of any pointer.
Package-Level Functions (total 18)
The append built-in function appends elements to the end of a slice. If it has sufficient capacity, the destination is resliced to accommodate the new elements. If it does not, a new underlying array will 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 is legal to append a string to a byte slice, like this: slice = append([]byte("hello "), "world"...)
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 is nil, cap(v) is zero. Channel: the channel buffer capacity, in units of elements; if v is nil, cap(v) is zero. For some arguments, such as a simple array expression, the result can be a constant. See the Go language specification's "Length and capacity" section for details.
Type Parameters: T: ~[]Type | ~map[Type]Type1 The clear built-in function clears maps and slices. For maps, clear deletes all entries, resulting in an empty map. For slices, clear sets all elements up to the length of the slice to the zero value of the respective element type. If the argument type is a type parameter, the type parameter's type set must contain only map or slice types, and clear performs the operation implied by the type argument.
The close built-in function closes a channel, which must be either bidirectional or send-only. It should be executed only by the sender, never the receiver, and has the effect of shutting down the channel after the last sent value is received. After the last value has been received from a closed channel c, any receive from c will succeed without blocking, returning the zero value for the channel element. The form x, ok := <-c will also set ok to false for a closed and empty channel.
The complex built-in function constructs a complex value from two floating-point values. The real and imaginary parts must be of the same size, either float32 or float64 (or assignable to them), and the return value will be the corresponding complex type (complex64 for float32, complex128 for float64).
The copy built-in function copies elements from a source slice into a destination slice. (As a special case, it also will copy bytes from a string to a slice of bytes.) The source and destination may overlap. Copy returns the number of elements copied, which will be the minimum of len(src) and len(dst).
The delete built-in function deletes the element with the specified key (m[key]) from the map. If m is nil or there is no such element, delete is a no-op.
The imag built-in function returns the imaginary part of the complex number c. The return value will be floating point type corresponding to the type of c.
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, 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. For some arguments, such as a string literal or a simple array expression, the result can be a constant. See the Go language specification's "Length and capacity" section for details.
The make built-in function allocates and initializes an object of type slice, map, or chan (only). Like new, the first argument is a type, not a value. Unlike new, make's return type is the same as the type of its argument, 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 is equal to its length. A second integer argument may be provided to specify a different capacity; it must be no smaller than the length. For example, make([]int, 0, 10) allocates an underlying array of size 10 and returns a slice of length 0 and capacity 10 that is backed by this underlying array. Map: An empty map is allocated with enough space to hold the specified number of elements. The size may be omitted, in which case a small starting size is allocated. Channel: The channel's buffer is initialized with the specified buffer capacity. If zero, or the size is omitted, the channel is unbuffered.
Type Parameters: T: cmp.Ordered The max built-in function returns the largest value of a fixed number of arguments of [cmp.Ordered] types. There must be at least one argument. If T is a floating-point type and any of the arguments are NaNs, max will return NaN.
Type Parameters: T: cmp.Ordered The min built-in function returns the smallest value of a fixed number of arguments of [cmp.Ordered] types. There must be at least one argument. If T is a floating-point type and any of the arguments are NaNs, min will return NaN.
The new built-in function allocates memory. The first argument is a type, not a value, and the value returned is a pointer to a newly allocated zero value of that type.
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 was deferred by F are run in the usual way, 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 have stopped, in reverse order. At that point, the program is terminated with a non-zero exit code. This termination sequence is called panicking and can be controlled by the built-in function recover. Starting in Go 1.21, calling panic with a nil interface value or an untyped nil causes a run-time error (a different panic). The GODEBUG setting panicnil=1 disables the run-time error.
The print built-in function formats its arguments in an implementation-specific way and writes the result to standard error. Print is useful for bootstrapping and debugging; it is not guaranteed to stay in the language.
The println built-in function formats its arguments in an implementation-specific way and writes the result to standard error. Spaces are always added between arguments and a newline is appended. Println is useful for bootstrapping and debugging; it is not guaranteed to stay in the language.
The real built-in function returns the real part of the complex number c. The return value will be floating point type corresponding to the type of c.
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 not any 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 will not stop a panicking sequence. In this case, or when the goroutine is not panicking, recover returns nil. Prior to Go 1.21, recover would also return nil if panic is called with a nil argument. See [panic] for details.
Package-Level Variables (only one)
nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type.
Package-Level Constants (total 3)
true and false are the two untyped boolean values.
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.
true and false are the two untyped boolean values.