Avatar ·

How to pass a default value to a Go method if the language doesn't have function overloading?

Hello everyone! I just started learning Go after Python and encountered an unexpected problem. In Python, I'm used to writing functions with default arguments, for example: ```python def greet(name, greeting="Hello"): print(f"{greeting}, {name}!") ``` If you call `greet("Alice")`, greeting automatically becomes "Hello". If needed, you can pass your own value: `greet("Alice", "Hi")`. Now I'm writing in Go and want to create a similar method. Let's say I have a `Config` struct and a `NewClient` method that takes a server address and timeout. I want the default timeout to be 30 seconds, but sometimes the user could set their own. In Go, I tried to write it like this: ```go type Config struct { Address string Timeout int } func NewClient(address string, timeout int) *Conf