mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 12:44:02 +03:00
FILE / ScuroNeko/mtg
conntypes/id.go
Исходный файл и его история в репозитории.
25 lines
305 B
Go
25 lines
305 B
Go
package conntypes
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
const ConnIDLength = 8
|
|
|
|
type ConnID [ConnIDLength]byte
|
|
|
|
func (c ConnID) String() string {
|
|
return hex.EncodeToString(c[:])
|
|
}
|
|
|
|
func NewConnID() ConnID {
|
|
var id ConnID
|
|
|
|
if _, err := rand.Read(id[:]); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return id
|
|
}
|