Definition function uses the keyword func, and the left brace cannot be another line
package Mainimport ("FMT") func main () {A, B: = 1, 2 D (A, B)//pass variable length variable, cannot modify slice index, cannot change slice value at all s1: = []int{1, 2, 3} D1 (S1)//pass slice as parameter, modify index value can achieve effect of modifying original slice x: = 1 D2 (&X)//Pass x memory address}//Parameter return value func a (a int, b string) int {return a}//multiple return values Func B () (A, B, c int) {//No parameters, A, b, C = 1, 2, 3//Because the return value already has a,b,c occupy the inner layer, so directly after the assignment return a, B, c//can omit a,b,c}//variable length arguments, that is, the int parameter can be multiple, passed in is a slice type func C (b String, a ... int) {FMT. Println (a)//output [1,2,3,4,5]}/variable-length parameter pass, passing in variables func D (s ... int) {FMT. Println (s) s[0] = 3 S[1] = 4 FMT. Println (s)}//passes slice as a parameter, copying slice memory address func D1 (s []int) {s[0] = 4 S[1] = 5 FMT. Println (s)}//pointer type passed, can achieve the purpose of modifying variable value func D2 (a *int) {*a = 2//Memory a value becomes 2 fmt. Println (*a)}/* output D----> [1 2]//slice [3 4]//slice 1 2//intd1----> [4 5 3]d2-- --2//parameter is pointer can modify variable value */