The use of anonymous structs in table driven tests is really what made me enjoy writing tests in go. I’ve tried to replicate similar patterns in java/junit but it looks a little too verbose according to my co-workers…
type ServerOpts {
Port int // default it to defaultPort somewhere
}
Also I have a question here. Another article/talks mentions that such config structs are an anti-pattern. So which one is true or in which cases would it be chose. Personally I am currently going with (exported) Default* variables in cases where something like this makes sense - in a similar way to the Go standard library.
The use of anonymous structs in table driven tests is really what made me enjoy writing tests in go. I’ve tried to replicate similar patterns in java/junit but it looks a little too verbose according to my co-workers…
There is a typo (missing struct):
Also I have a question here. Another article/talks mentions that such config structs are an anti-pattern. So which one is true or in which cases would it be chose. Personally I am currently going with (exported) Default* variables in cases where something like this makes sense - in a similar way to the Go standard library.