43 lines
798 B
Go
43 lines
798 B
Go
package generator
|
|
|
|
import (
|
|
"fmt"
|
|
uuid2 "github.com/gofrs/uuid"
|
|
"math/rand"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func MedicalRecordNumberRand() string {
|
|
return RandStringRunes(10)
|
|
}
|
|
|
|
func RandStringRunes(n int) string {
|
|
rand.Seed(time.Now().UnixNano()) // seed the random number generator
|
|
|
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
b := make([]byte, n)
|
|
for i := range b {
|
|
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
|
}
|
|
|
|
return string(b)
|
|
}
|
|
|
|
// format -> <uuid>-<time unix>
|
|
func GenerateFileName() string {
|
|
return fmt.Sprintf("%v-%v", GenerateUUID(), strconv.Itoa(int(time.Now().Unix())))
|
|
}
|
|
|
|
func GenerateUUID() string {
|
|
id := uuid.New()
|
|
return id.String()
|
|
}
|
|
|
|
func GenerateUUIDV4() string {
|
|
id, _ := uuid2.NewV4()
|
|
return id.String()
|
|
}
|