diff --git a/CHANGELOG.md b/CHANGELOG.md index fe47fd64..cc2446ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## v1.0.13 / 2021-06-04 +## v1.0.14 / 2021-06-04 - 优化 - 增加go.mod +- 修复代码 ## v1.0.11 / 2021-05-31 diff --git a/helper/http/http.go b/helper/http/http.go index 6d8f0c84..206f864c 100644 --- a/helper/http/http.go +++ b/helper/http/http.go @@ -3,7 +3,7 @@ package http import ( "encoding/json" "github.com/bitly/go-simplejson" - "github.com/dtapps/GoLibrary/helper/request" + "github.com/dtapps/go-library/helper/request" "gopkg.in/h2non/gentleman.v2" "gopkg.in/h2non/gentleman.v2/plugins/body" ) diff --git a/helper/string/string.go b/helper/string/string.go new file mode 100644 index 00000000..36bb5d9d --- /dev/null +++ b/helper/string/string.go @@ -0,0 +1,13 @@ +package string + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" +) + +func HmacSha256Hex(key, strToSign string) string { + hasher := hmac.New(sha256.New, []byte(key)) + hasher.Write([]byte(strToSign)) + return hex.EncodeToString(hasher.Sum(nil)) +} diff --git a/helper/time/time.go b/helper/time/time.go index eae49027..31aa4c70 100644 --- a/helper/time/time.go +++ b/helper/time/time.go @@ -2,6 +2,15 @@ package time import "time" +const ( + RFC822Format = "Mon, 02 Jan 2006 15:04:05 MST" + ISO8601Format = "2006-01-02T15:04:05Z" +) + +func NowUTCSeconds() int64 { return time.Now().UTC().Unix() } + +func NowUTCNanoSeconds() int64 { return time.Now().UTC().UnixNano() } + // GetCurrentDate 获取当前的时间 - 字符串 func GetCurrentDate() string { return time.Now().Format("2006/01/02 15:04:05") @@ -26,3 +35,8 @@ func GetCurrentNanoUnix() int64 { func GetCurrentWjDate() string { return time.Now().Format("20060102") } + +func FormatISO8601Date(timestamp_second int64) string { + tm := time.Unix(timestamp_second, 0).UTC() + return tm.Format(ISO8601Format) +} diff --git a/service/ddk/Ddk.go b/service/ddk/Ddk.go index e405015b..d98bf877 100644 --- a/service/ddk/Ddk.go +++ b/service/ddk/Ddk.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" "github.com/bitly/go-simplejson" - "github.com/dtapps/GoLibrary/service" + "github.com/dtapps/go-library/service" "github.com/nilorg/sdk/convert" "io" "io/ioutil" diff --git a/service/jdk/Jdk.go b/service/jdk/Jdk.go index 2fbabc39..925dd022 100644 --- a/service/jdk/Jdk.go +++ b/service/jdk/Jdk.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" "github.com/bitly/go-simplejson" - "github.com/dtapps/GoLibrary/service" + "github.com/dtapps/go-library/service" "github.com/nilorg/sdk/convert" "io" "io/ioutil" diff --git a/service/tbk/Tbk.go b/service/tbk/Tbk.go index 90953918..f7155c80 100644 --- a/service/tbk/Tbk.go +++ b/service/tbk/Tbk.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" "github.com/bitly/go-simplejson" - "github.com/dtapps/GoLibrary/service" + "github.com/dtapps/go-library/service" "github.com/nilorg/sdk/convert" "io" "io/ioutil"