no message

tags/v0.0.1
zhuxianglong 2 months ago
parent 214967d94d
commit eadd54d13f

@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"sort" "sort"
"strings" "strings"
"sync"
) )
// Order represents an order object used for signing parameters // Order represents an order object used for signing parameters
@ -35,11 +36,18 @@ type SDK struct {
SecretKey string SecretKey string
} }
// New initializes a new SDK with the given configuration // Singleton instance and mutex for thread safety
var instance *SDK
var once2 sync.Once
// New initializes a new SDK with the given configuration, but ensures that only one instance exists.
func New(secretKey string) *SDK { func New(secretKey string) *SDK {
return &SDK{ once2.Do(func() {
SecretKey: secretKey, instance = &SDK{
} SecretKey: secretKey,
}
})
return instance
} }
// Md5String generates MD5 hash of a given string // Md5String generates MD5 hash of a given string

Loading…
Cancel
Save