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