package main import ( "fmt" "github.com/oklog/ulid" "github.com/rs/xid" "math/rand" "strings" "time" ) func main(){ //获取主键ID ak := xid.New() appKey := ak.String() //新增就生成一个secret t := time.Now().UTC() entropy := rand.New(rand.NewSource(t.UnixNano())) appSecret := strings.ToLower(ulid.MustNew(ulid.Timestamp(t), entropy).String()) fmt.Println(appKey,appSecret) }