Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4a1937

Browse files
Update 设计模式.md
1 parentb23d8d7 commitf4a1937

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

‎设计模式.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#设计模式
22

3-
1. 责任链模式
3+
4+
5+
##责任链模式
46

57
```go
68
package main
@@ -49,3 +51,32 @@ func main() {
4951

5052
```
5153

54+
55+
56+
57+
58+
##单例模式
59+
60+
```go
61+
package main
62+
63+
import"sync"
64+
65+
type peoplestruct {
66+
}
67+
68+
varinstance *people
69+
varonce sync.Once
70+
71+
funcgetInstance() *people {
72+
once.Do(func() {
73+
instance = &people{}
74+
})
75+
return instance
76+
}
77+
78+
funcmain() {
79+
80+
}
81+
```
82+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp