Use net.JoinHostPort to concatenate the values you have in the struct
and pass the to http.Server struct.
if _, err := toml.Decode("config.toml", &conf); err != nil {
// handle error
}
addr, err := net.JoinHostPort(conf.Address, conf.PORT)
if err != nil {
// handle error
}
src := &http.Server{
Addr: addr,
}
Be sure to set explicit struct tags on your destination struct that
will be used for unmarshalling the toml. This way the decoder will know
which struct fields to populate.
type Config struct {
PORT string `toml:"port"`
Address string `toml:"address"`
}
This will only be necessary though if you want the fields to map
differently depending on their name.