Skip to content

Instantly share code, notes, and snippets.

@imzjy
Last active August 29, 2015 14:20
Show Gist options
  • Save imzjy/4ba76b3d9dfa07b9fb96 to your computer and use it in GitHub Desktop.
Save imzjy/4ba76b3d9dfa07b9fb96 to your computer and use it in GitHub Desktop.
golang get uid based on time.sleep
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