// generateID creates a globally unique identifier in the Message-ID format (subset of email address),
// optionally having an additional string appended to the local part.
// Example: 11223344556677889900.11.1234567890@localhost
503775
func generateID(appendWith string) (string, error) {
	random, err := rand.Int(rand.Reader, maxInt64)
	if err != nil {
		return "", nil
	}
	hostname, err := os.Hostname()
	if err != nil {
		hostname = "localhost"
	}
	pid := os.Getpid()
	nanoTime := time.Now().UTC().UnixNano()
	if len(appendWith) == 0 {
		return fmt.Sprintf("%d.%d.%d@%s", nanoTime, pid, random, hostname), nil
	}
	return fmt.Sprintf("%d.%d.%d.%s@%s", nanoTime, pid, random, appendWith, hostname), nil
}
821124
func (q *ParentIdQuery) Id(id string) *ParentIdQuery {
	q.id = id
	return q
}
214854
func genID(length int) string {
	r := make([]byte, length)
	io.ReadFull(rand.Reader, r)
	return base64.URLEncoding.EncodeToString(r)
}
922372
func GenerateIDWithAlg(customIDgenAlg string, payload []byte) (string, error) {
	if customIDgenAlg == "" {
		customIDgenAlg = defaultAlg
	}
	var alg = availableIDgenAlgs[customIDgenAlg]
	if alg.hashFun != nil {
		return alg.hashFun(payload), nil
	}
	return "", fmt.Errorf("Wrong ID generation algorithm was given: %s", customIDgenAlg)
}
600686
func GenerateLenUUID(i int) (string, error) {
	if i < 0 {
		i = 2<<29 + i
	}
	return FormatUUID(fmt.Sprintf("%x", i))
}
59360
func (s *DeleteScriptService) Id(id string) *DeleteScriptService {
	s.id = id
	return s
}
1074724
func (dht *DHT) id(target string) string {
	if dht.IsStandardMode() || target == "" {
		return dht.node.id.RawString()
	}
	return target[:15] + dht.node.id.RawString()[15:]
}
1270821
func (s Session) ID() string {
	if sessionIDStr, ok := s[SessionIDKey]; ok {
		return sessionIDStr.(string)
	}

	buffer := uuid.NewV4()

	s[SessionIDKey] = hex.EncodeToString(buffer.Bytes())
	return s[SessionIDKey].(string)
}
407897
func (t *markedTag) genID() {
	h := sha256.New()
	fmt.Fprintf(h, "%d\n%s", t.Job, t.Key.Encode())
	t.ID = base64.RawURLEncoding.EncodeToString(h.Sum(nil))
}
395527
func (s *DeleteTemplateService) Id(id string) *DeleteTemplateService {
	s.id = id
	return s
}
1302347
func getMessageID(p []byte) (*MessageID, error) {
	if len(p) != MsgIDLength {
		return nil, errors.New("Invalid Message ID")
	}
	return (*MessageID)(unsafe.Pointer(&p[0])), nil
}
471097
func (self *TempHumid) Id() string {
	return fmt.Sprintf("%02x:%02x", self.id>>8, self.id&0xff)
}
587006
func (m *Machine) UniqueID() (id string) {
	uuid, err := uuid.NewV4()
	if err == nil {
		return uuid.String()
	}

	parts := []string{}
	parts = append(parts, randStringRunes(8))
	parts = append(parts, randStringRunes(4))
	parts = append(parts, randStringRunes(4))
	parts = append(parts, randStringRunes(12))

	return strings.Join(parts, "-")
}
792735
func (self *Chime) Id() string {
	return fmt.Sprintf("%02x:%02x", self.id>>8, self.id&0xff)
}
996376
func (t *FpdfTpl) ID() string {
	return fmt.Sprintf("%x", sha1.Sum(t.Bytes()))
}
787840
func ID(c Conn) string {
	l := fmt.Sprintf("%s/%s", c.LocalMultiaddr(), c.LocalPeer().Pretty())
	r := fmt.Sprintf("%s/%s", c.RemoteMultiaddr(), c.RemotePeer().Pretty())
	lh := u.Hash([]byte(l))
	rh := u.Hash([]byte(r))
	ch := u.XOR(lh, rh)
	return peer.ID(ch).Pretty()
}
381489
func (sid *Shortid) Generate() (string, error) {
	return sid.GenerateInternal(nil, sid.epoch)
}