snowflake

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

Snowflake

提供简易的Snowflake算法


快速上手

获取下一个ID
package main

import (
  "github.com/sirupsen/logrus"
  "github.com/surh-go/snowflake"
  
  _"github.com/surh-go/logrus_conf"
)

func main() {
  logrus.Info(snowflake.NextID().String())
}

解析ID
package main

import (
  "github.com/sirupsen/logrus"
  "github.com/surh-go/snowflake"
  
  _"github.com/surh-go/logrus_conf"
)

func main() {
  var id int64 = 24074082846773248
  info := ParseID(&id)
  logrus.Info("Timestamp: ", info.Timestamp)
  logrus.Info("MachineID: ", info.MachineID)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextID

func NextID() *models.ID

NextID 下一个ID

func ParseID

func ParseID(id *int64) *models.Info

ParseID 解析ID

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL