This is a creation in Article, where the information may have evolved or changed.
Small example:
Package Mainimport"FMT"/*function exercises, variable parameters use write a function add support 1 or more int add, and return add result write a function concat, support 1 or more string concatenation, and return the result*/func Add (aint, Arg ...int)int{sum:=a forI: =0; I < Len (ARG); i++{sum+=Arg[i]}returnSum}func concat (astring, Arg ...string) (Resultstring) {result=a forI: =0; I < Len (ARG); i++{result+=Arg[i]}return}func Main () {sum:= Add (Ten,3,3,3,3,3) fmt. PRINTLN (SUM) Res:=concat ("Hello"," ","Big Cock") fmt. Println (RES)}
99 Multiplication Table:
Package Mainimport"FMT"//99 multiplication TableFunc multi () { forI: =0; I <9; i++ { forJ: =0; J <= I; J + +{fmt. Printf ("%d*%d=%d\t", (i +1), j+1, (i+1) * (j+1) } fmt. PRINTLN ()}}func main () {multi ()}