-
-
Save didi1246888/0659f75d62c2951475fcc7c5a5e3749e to your computer and use it in GitHub Desktop.
This file contains 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 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