diff --git a/README.md b/README.md index 3680977..a670aed 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,17 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/aberic/gnomon)](https://goreportcard.com/report/github.com/aberic/gnomon) [![GolangCI](https://golangci.com/badges/github.com/aberic/gnomon.svg)](https://golangci.com/r/github.com/aberic/gnomon) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/4f11995425294f42aec6a207b8aab367)](https://www.codacy.com/manual/aberic/gnomon?utm_source=github.com&utm_medium=referral&utm_content=aberic/gnomon&utm_campaign=Badge_Grade) -[![Travis (.org)](https://img.shields.io/travis/aberic/gnomon.svg?label=travis-ci%20build)](https://www.travis-ci.org/aberic/gnomon) +[![Travis (.org)](https://img.shields.io/travis/aberic/gnomon.svg?label=build)](https://www.travis-ci.org/aberic/gnomon) [![Coveralls github](https://img.shields.io/coveralls/github/aberic/gnomon.svg)](https://coveralls.io/github/aberic/gnomon?branch=master) # Gnomon -通用go工具库 +通用编写go应用的公共库。 -### 开发环境 +## 开发环境 * Go 1.12+ * Darwin/amd64 -### 测试环境 +## 测试环境 * Go 1.11+ * Linux/x64 diff --git a/hash.go b/hash.go index 5feab70..5a0456a 100644 --- a/hash.go +++ b/hash.go @@ -30,7 +30,7 @@ type HashCommon struct{} // MD5 MD5 func (h *HashCommon) MD5(text string) string { hash := md5.New() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } @@ -43,34 +43,34 @@ func (h *HashCommon) MD516(text string) string { // Sha1 Sha1 func (h *HashCommon) Sha1(text string) string { hash := sha1.New() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } // Sha224 Sha224 func (h *HashCommon) Sha224(text string) string { hash := crypto.SHA224.New() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } // Sha256 Sha256 func (h *HashCommon) Sha256(text string) string { hash := sha256.New() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } // Sha384 Sha384 func (h *HashCommon) Sha384(text string) string { hash := sha512.New384() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } // Sha512 Sha512 func (h *HashCommon) Sha512(text string) string { hash := sha512.New() - hash.Write([]byte(text)) + _, _ = hash.Write([]byte(text)) return hex.EncodeToString(hash.Sum(nil)) } diff --git a/scale.go b/scale.go index 51d8c2b..d1d4ef2 100644 --- a/scale.go +++ b/scale.go @@ -188,8 +188,7 @@ func (s *ScaleCommon) IntToHexString(i int) string { // HexStringToUint64 int字符串转int func (s *ScaleCommon) HexStringToUint64(hex string) uint64 { hexLen := len(hex) - var uint64Hex uint64 - uint64Hex = 0 + var uint64Hex uint64 = 0 for i := 0; i < hexLen; i++ { uint64Hex += uint64(intHexMap[hex[i:i+1]]) * uint64(math.Pow(16, float64(hexLen-i-1))) } @@ -199,8 +198,7 @@ func (s *ScaleCommon) HexStringToUint64(hex string) uint64 { // HexStringToInt64 int字符串转int func (s *ScaleCommon) HexStringToInt64(hex string) int64 { hexLen := len(hex) - var int64Hex int64 - int64Hex = 0 + var int64Hex int64 = 0 for i := 0; i < hexLen; i++ { int64Hex += int64(intHexMap[hex[i:i+1]]) * int64(math.Pow(16, float64(hexLen-i-1))) } @@ -300,8 +298,7 @@ func (s *ScaleCommon) IntToDuoString(i int) string { // DuoStringToUint64 int字符串转int func (s *ScaleCommon) DuoStringToUint64(duo string) uint64 { duoLen := len(duo) - var uint64Duo uint64 - uint64Duo = 0 + var uint64Duo uint64 = 0 for i := 0; i < duoLen; i++ { uint64Duo += uint64(intDuoMap[duo[i:i+1]]) * uint64(math.Pow(32, float64(duoLen-i-1))) } @@ -311,8 +308,7 @@ func (s *ScaleCommon) DuoStringToUint64(duo string) uint64 { // DuoStringToInt64 int字符串转int func (s *ScaleCommon) DuoStringToInt64(duo string) int64 { duoLen := len(duo) - var int64Duo int64 - int64Duo = 0 + var int64Duo int64 = 0 for i := 0; i < duoLen; i++ { int64Duo += int64(intDuoMap[duo[i:i+1]]) * int64(math.Pow(32, float64(duoLen-i-1))) } @@ -412,8 +408,7 @@ func (s *ScaleCommon) IntToDDuoString(i int) string { // DDuoStringToUint64 int字符串转int func (s *ScaleCommon) DDuoStringToUint64(dDuo string) uint64 { dDuoLen := len(dDuo) - var uint64DDuo uint64 - uint64DDuo = 0 + var uint64DDuo uint64 = 0 for i := 0; i < dDuoLen; i++ { uint64DDuo += uint64(intDDuoMap[dDuo[i:i+1]]) * uint64(math.Pow(64, float64(dDuoLen-i-1))) } @@ -423,8 +418,7 @@ func (s *ScaleCommon) DDuoStringToUint64(dDuo string) uint64 { // DDuoStringToInt64 int字符串转int func (s *ScaleCommon) DDuoStringToInt64(dDuo string) int64 { dDuoLen := len(dDuo) - var int64DDuo int64 - int64DDuo = 0 + var int64DDuo int64 = 0 for i := 0; i < dDuoLen; i++ { int64DDuo += int64(intDDuoMap[dDuo[i:i+1]]) * int64(math.Pow(64, float64(dDuoLen-i-1))) }