github.com/secure-build/gitlab-runner@v12.5.0+incompatible/helpers/random_uuid.go (about)

     1  package helpers
     2  
     3  import (
     4  	"crypto/rand"
     5  	"encoding/hex"
     6  )
     7  
     8  func GenerateRandomUUID(length int) (string, error) {
     9  	data := make([]byte, length)
    10  	_, err := rand.Read(data)
    11  	if err != nil {
    12  		return "", err
    13  	}
    14  
    15  	return hex.EncodeToString(data), nil
    16  }