package uid import "github.com/sqids/sqids-go" // use your own random version of alphabets // there is online util at the bottomt of this page: https://sqids.org/go var opts sqids.Options = sqids.Options{ Alphabet: "fsvjrnGWiTk2Lt1l5MzEhFH73CIg60ByexQPYpX9Ro8ZKawAVUdNuDJbmqScO4", } // Encode a slice of IDs into one unique ID func Encode(ids []uint64) (string, error) { s, err := sqids.New() if err != nil { return "", err } return s.Encode(ids) // "86Rf07" } // Decode an ID back to slice of IDs func Decode(id string) ([]uint64, error) { s, err := sqids.New() if err != nil { return nil, err } return s.Decode(id), nil }