Created
December 18, 2015 18:38
-
-
Save yifan-gu/50bfb8bffd839c219e7b to your computer and use it in GitHub Desktop.
lock
This file contains hidden or 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 ( | |
"fmt" | |
"os" | |
"github.com/coreos/rkt/pkg/lock" | |
) | |
func lockAndPrint() { | |
lock.ExclusiveLock("/tmp/hello", lock.Dir) | |
fmt.Println("hello") | |
} | |
func main() { | |
os.Mkdir("/tmp/hello", 0777) | |
defer os.RemoveAll("/tmp/hello") | |
lockAndPrint() | |
lockAndPrint() | |
} |
Author
yifan-gu
commented
Dec 18, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment