We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如下代码验证了空结构体多次赋值结果一样,在单例模式中golang-design-pattern/03_singleton/singleton.go line23,即使不用sync.Once 也能通过单元测试,应该给singleton添加一个字段
`package main
import ( "fmt" )
var a1 *singleton1 var a2 *singleton2
type singleton1 struct { } type singleton2 struct { d int }
func getInstance1() *singleton1 { a1 = &singleton1{} return a1 } func getInstance2() *singleton2 { a2 = &singleton2{} return a2 } func main() { b1, c1 := getInstance1(), getInstance1() fmt.Println(b1 == c1) //true b2, c2 := getInstance2(), getInstance2() fmt.Println(b2 == c2) //false } `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
如下代码验证了空结构体多次赋值结果一样,在单例模式中golang-design-pattern/03_singleton/singleton.go line23,即使不用sync.Once 也能通过单元测试,应该给singleton添加一个字段
`package main
import (
"fmt"
)
var a1 *singleton1
var a2 *singleton2
type singleton1 struct {
}
type singleton2 struct {
d int
}
func getInstance1() *singleton1 {
a1 = &singleton1{}
return a1
}
func getInstance2() *singleton2 {
a2 = &singleton2{}
return a2
}
func main() {
b1, c1 := getInstance1(), getInstance1()
fmt.Println(b1 == c1)
//true
b2, c2 := getInstance2(), getInstance2()
fmt.Println(b2 == c2)
//false
}
`
The text was updated successfully, but these errors were encountered: