Cloud Services
AWS
Azure
Google Cloud
Salesforce
Microsoft
SAP
August 18, 2023
There is no optional param support in golang. But we can use variadic arguments. The function actually receives a slice of whatever type you specify.
func foo(params ...int) {
fmt.Println(len(params))
}
func main() {
foo()
foo(1)
foo(1,2,3)
foo([]int{1, 2, 3, 4}...)
}
Work with our skilled Golang developers to accelerate your project and boost its performance.
Hire Golang Developer