August 2019
Beginner to intermediate
798 pages
17h 2m
English
Go also supports variadic functions, which are functions that accept a variable number of arguments. The most popular variadic functions can be found in the fmt package. Variadic functions will be illustrated in variadic.go, which will be presented in three parts.
The first part of variadic.go is as follows:
package main
import (
"fmt"
"os"
)
func varFunc(input ...string) {
fmt.Println(input)
}
This code part presents the implementation of a variadic function named varFunc() that accepts string arguments. The input function argument is a slice and will be handled as a slice inside the varFunc() function. The ... operator used as ...Type is called the pack operator, whereas the unpack operator ends with ... and begins with ...
Read now
Unlock full access