Skip to content

Instantly share code, notes, and snippets.

@metametaclass
Created April 15, 2016 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metametaclass/a3442966bd02094430496c7e7266d20e to your computer and use it in GitHub Desktop.
Save metametaclass/a3442966bd02094430496c7e7266d20e to your computer and use it in GitHub Desktop.
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