![Learn Data Structures and Algorithms with Golang](https://wfqqreader-1252317822.image.myqcloud.com/cover/744/36698744/b_36698744.jpg)
上QQ阅读APP看书,第一时间看更新
Variadic functions
A function in which we pass an infinite number of arguments, instead of passing them one at a time, is called a variadic function. The type of the final parameter is preceded by an ellipsis (...), while declaring a variadic function; this shows us that the function might be called with any number of arguments of this type.
Variadic functions can be invoked with a variable number of parameters. fmt.Println is a common variadic function, as follows:
//main method
func main() {
var customers []Customer
customers = GetCustomers()
fmt.Println("Before Insert",customers)
var customer Customer
customer.CustomerName = "Arnie Smith"
customer.SSN = "2386343"
InsertCustomer(customer)
customers = GetCustomers()
fmt.Println("After Insert",customers)
}
Run the following commands:
go run database_operations.go
The following screenshot displays the output:
![](https://epubservercos.yuewen.com/AA6936/19470380301498306/epubprivate/OEBPS/Images/9f6c143f-b52f-4e9d-8914-eef2a81aa9d8.png?sign=1738873730-YplOXjDdXNzrhPSbLgmZ2OaKlIzAum0T-0-77accfa01d504ecbfd7a9aa570d83563)
Let's start the update operation in the next section.