Infinite Loop

A blog about software engineering, software architecture, distributed systems, cloud computing, and technology leadership.

About

Hi, I'm Vinicius Serpa (or simply Mestre). I'm a staff-level software engineer, currently working as a Systems Architect at Nextpower Inc.

18 July 2026

Go built-in functions complete list

by Vinicius Serpa

Go built-in functions complete list

Go’s built-in functions (or predeclared functions) are available in any Go program without importing any packages. They are part of the language’s predeclared identifiers. Currently, Go provides 18 built-in functions.

Complete List

append
cap
clear
close
complex
copy
delete
imag
len
make
max
min
new
panic
print
println
real
recover

Most Commonly Used Functions

append

Adds elements to a slice.

nums := []int{1, 2}
nums = append(nums, 3, 4)

len

Returns the length of a string, slice, map, channel, or array.

len(nums)

cap

Returns the capacity of a slice, array, or channel.

cap(nums)

This function is commonly used when learning how slices grow internally.

make

Creates and initializes slices, maps, and channels.

users := make([]string, 0, 100)

cache := make(map[string]string)

jobs := make(chan Job, 10)

new

Allocates zeroed memory for a type and returns a pointer to it.

u := new(User)

Equivalent to: u := &User{} in many cases.

Map Functions

delete

Removes a specific key from a map.

delete(users, "carlos")

clear

Removes all elements from a map.

clear(users)

It also works with slices and was introduced in recent Go versions.

Copy Functions

copy

Copies elements between slices.

dst := make([]int, len(src))
copy(dst, src)

Concurrency

close

Closes a channel.

close(ch)

Complex Numbers

Go provides native support for complex numbers.

complex

Creates a complex number.

c := complex(1, 2)

real

Returns the real part.

real(c)

imag

Returns the imaginary part.

imag(c)

Serious Error Handling

panic

Stops the normal execution flow of the program.

panic("something went wrong")

recover

Allows a program to recover from a panic when called inside a deferred function.

defer func() {
    if r := recover(); r != nil {
        fmt.Println(r)
    }
}()

Debugging

print("hello")
println("hello")

These functions exist mainly for quick debugging.

In production code, prefer:

fmt.Print()
fmt.Println()

Recent Additions

Since Go 1.21, the following built-in functions have been added:

max(10, 20, 30)

min(10, 20, 30)

Quick Memorization List

A good way to memorize the most frequently used built-in functions is:

These are by far the built-ins you will encounter most often in professional Go projects.

tags: golang - programming-language