1package main 2 3import ( 4 "fmt" 5) 6 7type Config struct { 8 A string 9} 10 11var conf *Config = &Config{} 12 13func SetConfig() func(*Config) { 14 return func(cf *Config) { 15 conf = cf 16 } 17} 18 19func main() { 20 conf := &Config{ 21 A: "foo", 22 } 23 24 fmt.Println(conf.A) 25} 26 27// Output: 28// foo 29