Skip to content

Commit

Permalink
code style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AbericYang committed Sep 19, 2019
1 parent 80b6317 commit ebce65c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -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))
}
18 changes: 6 additions & 12 deletions scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand All @@ -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)))
}
Expand Down Expand Up @@ -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)))
}
Expand All @@ -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)))
}
Expand Down Expand Up @@ -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)))
}
Expand All @@ -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)))
}
Expand Down

0 comments on commit ebce65c

Please sign in to comment.