github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/data/id/id.go (about)

     1  package id
     2  
     3  import (
     4  	"github.com/angenalZZZ/gofunc/data/id/shortid"
     5  	"github.com/google/uuid"
     6  	"github.com/rs/xid"
     7  )
     8  
     9  // L9 short id 9 chars
    10  func L9() string {
    11  	s := shortid.MustGenerate()
    12  	if len(s) == 10 {
    13  		return s[0:9]
    14  	}
    15  	return s
    16  }
    17  
    18  // L10 short id 10 chars
    19  func L10() string {
    20  	s := shortid.MustGenerate()
    21  	if len(s) == 10 {
    22  		return s
    23  	}
    24  	return s + "0"
    25  }
    26  
    27  // L20 xid 20 chars
    28  func L20() string {
    29  	s := xid.New().String()
    30  	return s
    31  }
    32  
    33  // L32 uuid 32 chars
    34  func L32() string {
    35  	s := uuid.New().String()
    36  	return s[0:8] + s[9:13] + s[14:18] + s[19:23] + s[24:]
    37  }
    38  
    39  // L36 uuid 36 chars
    40  func L36() string {
    41  	s := uuid.New().String()
    42  	return s
    43  }