那么,没有任何具体的原因,使代理自己的结构?

无论如何,你有2个选项:

正确的方法,只需将代理移动到其自己的结构中,例如:

 type Configuration struct { Val string Proxy } type Proxy struct { Address string Port string } func main() { c := &Configuration{ Val: "test", Proxy: Proxy{ Address: "addr", Port: "port", }, } fmt.Println(c) } 

不太正确和丑陋的方式,但仍然有效:

 c := &Configuration{ Val: "test", Proxy: struct { Address string Port string }{ Address: "addr", Port: "80", }, }