Created
April 15, 2016 12:27
-
-
Save metametaclass/a3442966bd02094430496c7e7266d20e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"sync" | |
"fmt" | |
) | |
type Test2 struct { | |
v string; | |
} | |
func (db *Test2) String() string{ | |
return db.v; | |
} | |
type Test1 struct { | |
sync.Mutex | |
a *Test2; | |
} | |
func main() { | |
test := Test1{} | |
defer func() { | |
test.Lock() | |
fmt.Println("cleanup"); | |
test.Unlock() | |
}(); | |
test.Lock() | |
fmt.Println("test", test.a.String()) | |
test.Unlock() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment