github.com/ndau/noms@v1.0.5/go/util/random/id.go (about)

     1  package random
     2  
     3  import (
     4  	"crypto/rand"
     5  	"encoding/hex"
     6  
     7  	"github.com/ndau/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  }