Why I Prefer Structs Over Variadic Functions in Go

After several years of practicing Go, I must admit that I’m not a big fan of variadic functions1. I’ll try to explain why and why I greatly prefer using structs. Definition Let’s start with a quick reminder of what variadic functions are for those unfamiliar with the concept. This pattern is generally used to configure options in a flexible/dynamic way when creating an instance of a structure. Let’s look at a concrete example: ...

May 10, 2026 · 4 min · Loïc Sikidi

Making Go APIs More Ergonomic with Optional Arguments

Introduction In Go, as in all programming languages, it’s sometimes useful to have optional arguments in functions. The Go language supports this functionality but in a very limited way, as shown in the example below: func Greetings(name string, age ...int) { if len(age) > 0 { fmt.Printf("Hello %s, you are %d years old\n", name, age[0]) } else { fmt.Printf("Hello %s\n", name) } } func main() { Greetings("Alice") Greetings("Bob", 30) Greetings("Chad", 40, 100) // only the first value is used } Note The complete example is available via the Go playground: here. ...

May 9, 2026 · 4 min · Loïc Sikidi