I wish go's type inference worked inside struct literals. Filling out config structs would be so much easier if this worked:
type Config struct {
Runtime struct {
Debug bool
}
}
c := Config{
Runtime: {
Debug: true,
},
}
^^ why can't this work? It seems unambiguous.
The initial Config{ defines the type and tells the compiler exactly what everything inside it must be....
The reason that I wrote the struct that way is that it makes it very easy to read when the struct gets bigger. The sub-structs become basically just namespaces on the fields they encompass. But if you then have to write a literal by redefining the struct, the literal becomes impossible to read
c := Config{
Runtime: struct { Debug bool }{
Debug: true,
},
}