Last active
August 29, 2015 14:20
-
-
Save imzjy/4ba76b3d9dfa07b9fb96 to your computer and use it in GitHub Desktop.
golang get uid based on time.sleep
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" | |
"time" | |
"strconv" | |
) | |
func main(){ | |
for i := 0; i < 2000; i++ { | |
fmt.Println(Tuid()) | |
} | |
} | |
func Tuid() string { | |
time.Sleep(1 * time.Nanosecond) | |
return strconv.FormatInt(time.Now().UnixNano(), 36) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment