init project
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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()
|
||||
}
|
||||
Reference in New Issue
Block a user