Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewSIDCommand = cli.Command{ Name: "new", Usage: "New snow id", Flags: []cli.Flag{ cli.Uint64Flag{ Name: "n", Usage: "node number", }, }, Action: func(context *cli.Context) error { nodeNumber := context.Int64("n") node, err := snowflake.NewNode(nodeNumber) if err != nil { return err } fmt.Printf("SID is : %+v\r\n", node.Generate().Int64()) return nil }, }
View Source
var ParseTimeCommand = cli.Command{ Name: "parse", Usage: "Parse snow id to time", Flags: []cli.Flag{ cli.Uint64Flag{ Name: "i", Usage: "snow id", }, }, Action: func(context *cli.Context) error { sid := context.Int64("i") ec := int64(1288834974657) step2 := sid - 4096 step1 := step2 >> 22 unixMill := step1 + ec utcTime := unixMill2Time(unixMill).UTC() locTime := utcTime.Local() fmt.Printf("SID is : %+v\r\nUnixMill is : %+v\r\nUTC time is : %+v\r\nLocal time is : %+v\r\n", sid, unixMill, utcTime, locTime) return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.