1 | package main |
---|---|
2 | |
3 | import ( |
4 | "fmt" |
5 | "sync" |
6 | ) |
7 | |
8 | var test2 string = "test" |
9 | |
10 | type TestStructSub2 struct { |
11 | E string |
12 | F int |
13 | } |
14 | |
15 | var instance *TestStructSub2 |
16 | var once sync.Once |
17 | |
18 | func GetTestStructSubMethod() *TestStructSub2 { |
19 | once.Do(func() { |
20 | |
21 | instance = &TestStructSub2{ |
22 | E: "methodTest", |
23 | } |
24 | }) |
25 | return instance |
26 | } |
27 | |
28 | func (ts TestStructSub2) SayGood(word string) { |
29 | fmt.Printf("hello good %s %s", word, ts.E) |
30 | |
31 | test = "" |
32 | } |
33 | |
34 | func TestPackageSayGood(word string) { |
35 | fmt.Printf("hello good %s", word) |
36 | |
37 | test = "" |
38 | } |
39 |
Members