Skip to content

Instantly share code, notes, and snippets.

@didi1246888
Created September 13, 2022 06:20
Show Gist options
  • Save didi1246888/0659f75d62c2951475fcc7c5a5e3749e to your computer and use it in GitHub Desktop.
Save didi1246888/0659f75d62c2951475fcc7c5a5e3749e to your computer and use it in GitHub Desktop.
package mian
import (
"github.com/lithammer/shortuuid/v4"
"fmt"
)
func main() {
id := shortuuid.New()
// id: iDeUtXY5JymyMSGXqsqLYX length: 22
fmt.Println("id:", id, "length:", len(id))
// V22s2vag9bQEZCWcyv5SzL Fixed unchanged
id = shortuuid.NewWithNamespace("http://127.0.0.1.com")
// id: K7pnGHAp7WLKUSducPeCXq length: 22
fmt.Println("id:", id, "length:", len(id))
// NewWithAlphabet Functions can be used to customize the underlying string, which requires non-repetition and a fixed length of 57
str := "12345#$%^&*67890qwerty/;'~!@uiopasdfghjklzxcvbnm,.()_+·><"
id = shortuuid.NewWithAlphabet(str)
// id: q7!o_+y('@;_&dyhk_in9/ length: 22
fmt.Println("id:", id, "length:", len(id))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment