github.com/jbendotnet/noms@v0.0.0-20190904222105-c43e4293ea92/go/util/random/id.go (about)

     1  package random
     2  
     3  import (
     4  	"crypto/rand"
     5  	"encoding/hex"
     6  
     7  	"github.com/attic-labs/noms/go/d"
     8  )
     9  
    10  var (
    11  	reader = rand.Reader
    12  )
    13  
    14  // Id creates a unique ID which is a random 16 byte hex string
    15  func Id() string {
    16  	data := make([]byte, 16)
    17  	_, err := reader.Read(data)
    18  	d.Chk.NoError(err)
    19  	return hex.EncodeToString(data)
    20  }