Cómo inicializar correctamente una estructura anidada (nested struct) en Go?
¡Hola a todos! Soy nuevo en Go y tengo un problema con la inicialización de estructuras anidadas. Estoy escribiendo un pequeño proyecto para trabajar con una API del clima.
Tengo estas estructuras:
```go
type WeatherResponse struct {
Location Location
Current CurrentWeather
}
type Location struct {
Name string
Country string
Lat float64
Lon float64
}
type CurrentWeather struct {
Temperature float64
Humidity int
Condition string
Wind WindInfo
}
type WindInfo struct {
Speed float64
Deg int
}
```
Estoy intentando crear una instancia de `WeatherResponse` y llenar todos los campos de inmediato, pero obtengo errores de compilación. Probé diferentes opciones:
```go
// Opción 1 - no funciona
data := WeatherResponse{
Location.Name: "Moscow",
Location.Country: "Russia",
CurrentWeather.Temperature: 22.5,
}
// Opción 2 - tampoco funciona
data := WeatherResponse{
Location{"Moscow", "Russia", 55.75, 37.62},
Current