diff --git a/FFI for Python-Node-PHP/lib/yitidgen.dll b/FFI for Python-Node-PHP/lib/yitidgen.dll index b3b9a92..b7f7126 100644 Binary files a/FFI for Python-Node-PHP/lib/yitidgen.dll and b/FFI for Python-Node-PHP/lib/yitidgen.dll differ diff --git a/Go/source/idgen/YitIdHelper.go b/Go/source/idgen/YitIdHelper.go index 7cf5f00..e1084b3 100644 --- a/Go/source/idgen/YitIdHelper.go +++ b/Go/source/idgen/YitIdHelper.go @@ -58,8 +58,10 @@ func SetIdGenerator(options *IdGeneratorOptions) { func NextId() uint64 { if idGenerator == nil { singletonMutex.Lock() - options := NewIdGeneratorOptions(1) - idGenerator = NewDefaultIdGenerator(options) + if idGenerator == nil { + options := NewIdGeneratorOptions(1) + idGenerator = NewDefaultIdGenerator(options) + } singletonMutex.Unlock() } diff --git a/Go/source/main.go b/Go/source/main.go index f04a935..4426635 100644 --- a/Go/source/main.go +++ b/Go/source/main.go @@ -8,13 +8,13 @@ import ( "yitidgen/regworkerid" ) -///export SetOptions +//export SetOptions func SetOptions(workerId uint16) { var options = idgen.NewIdGeneratorOptions(workerId) idgen.SetIdGenerator(options) } -///export NextId +//export NextId func NextId() uint64 { return idgen.NextId() } @@ -65,5 +65,6 @@ func main() { } -// go build -o target\yitidgengo.dll -buildmode=c-shared main.go - +// go build -o ./target/yitidgengo.dll -buildmode=c-shared main.go +// go install -buildmode=shared -linkshared std +// go build -o ./target/yitidgengo.so -buildmode=c-shared main.go