A little 2 file application that reads a config file and stores it in a struct
. How do pass part of the config struct
to the fetchTemperature
function?
Configuration
package configuration
type Config struct {
Temperatures []struct {
Temperature
}
}
type Temperature struct {
AppId string
}
func Load() Config {
var c Config
// -- 8< -- snip -- 8< --
return c
}
Main
package main
import "configuration"
var c configuration.Config = configuration.Load()
func main() {
for _, t := range c.Temperatures {
fetchTemperature(t)
}
}
func fetchTemperature(t configuration.Temperature) {
// -- 8< -- snip -- 8< --
}
Gives me:
cannot use t (type struct { configuration.Temperature }) as type configuration.Temperature in argument to fetchTemperature
Isn't t
of configuration.Temperature
and if not, how do I pass the struct
around?