mirror of https://github.com/dtm-labs/dtm.git
csharpjavadistributed-transactionsdtmgogolangmicroservicenodejsphpdatabasesagaseatatcctransactiontransactionsxapythondistributed
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
456 B
32 lines
456 B
package common
|
|
|
|
import (
|
|
"github.com/bwmarrin/snowflake"
|
|
)
|
|
|
|
var gNode *snowflake.Node = nil
|
|
|
|
func GenGid() string {
|
|
return gNode.Generate().Base58()
|
|
}
|
|
|
|
func init() {
|
|
node, err := snowflake.NewNode(1)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
gNode = node
|
|
}
|
|
|
|
func PanicIfError(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func If(condition bool, trueObj interface{}, falseObj interface{}) interface{} {
|
|
if condition {
|
|
return trueObj
|
|
}
|
|
return falseObj
|
|
}
|
|
|