Documentation ¶
Index ¶
- Constants
- Variables
- func SeedMathRand()
- type ID
- func (id *ID) ClusterID() uint32
- func (id *ID) Counter() uint32
- func (id *ID) Encode(serverRoomID, clusterID, machineID, workID, opID uint32) (string, error)
- func (id *ID) FromString(s string) error
- func (id *ID) MachineID() uint32
- func (id *ID) OpID() uint32
- func (id *ID) ServerRoomID() uint32
- func (id *ID) SetAlphabet(alphabet string) *ID
- func (id *ID) SetMinLength(minLength int) *ID
- func (id *ID) SetSalt(salt string) *ID
- func (id *ID) Timestamp() int64
- func (id *ID) WorkID() uint32
Constants ¶
View Source
const ( VERSION = "0.0.1" DEFAULT_ALPHABET = hashids.DefaultAlphabet DEFAULT_MIN_LENGTH = 28 DEFAULT_SALT = `aC%eNsc8@!03Yb#69d` RAW_LEN = 4 // 4 * 4 bytes )
Variables ¶
View Source
var ( // SeededSecurely is set to true if a cryptographically secure seed // was used to initialize rand. When false, the start time is used // as a seed. SeededSecurely bool )
Functions ¶
func SeedMathRand ¶
func SeedMathRand()
SeedMathRand provides weak, but guaranteed seeding, which is better than running with Go's default seed of 1. A call to SeedMathRand() is expected to be called via init(), but never a second time.
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
func (*ID) Encode ¶
Encode generates globally unique id serverroomID: [0, 64) clusterID: [0, 256) machineID: [0, 512) workID: [0, 8) opID: [0, 64)
func (*ID) FromString ¶
FromString reads an ID from its string representation
func (*ID) ServerRoomID ¶
Serverroomid returns the serverroomid part of the id.
func (*ID) SetAlphabet ¶
SetAlphabet set alphabet of hashids
func (*ID) SetMinLength ¶
SetMinLength set minlength of hashids
Click to show internal directories.
Click to hide internal directories.