【Go】Built-in function

Built-in functions can be understood as system functions in the Go language

Go predefines some functions. These functions can be used directly without introducing any other package modules. We call them built-in functions.

Go’s current built-in functions are:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// for channel communication
close

// used to delete instances in map
new

// exception handling
panic

// plural correlation
complex
real
imag

delete

// for built-in type memory allocation
make
recover

len

// append slice
append

// Low-level print function, can be used without introducing fmt
print
println
cap

// copy slice
copy

The specific function usage will be described in detail in the corresponding chapters later. It is difficult to fully understand the introduction in advance.

Take a look at print

1
2
3
4
5
6
7
8
9
package main

func main () {
    list: = [] string {"a", "b", "c", "d", "e", "f"}

    for k, v: = range list {
        println(k, v)
    }
}

Save as helloworld.go and execute the result

1
2
3
4
5
6
7
[me@VM_0_14_centos go] # go run helloworld.go
0 a
1 b
2 c
3 d
4 e
5 f

Persist in original technology sharing, your support will encourage me to continue to create!