Skip to content

Commit

Permalink
feat: update .golangci.yaml and optimize the project
Browse files Browse the repository at this point in the history
  • Loading branch information
sliveryou committed Jan 27, 2024
1 parent e0ed845 commit 6c2234b
Show file tree
Hide file tree
Showing 29 changed files with 496 additions and 448 deletions.
164 changes: 143 additions & 21 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
run:
go: '1.16'
concurrency: 4
timeout: 5m
tests: true
skip-dirs:
- id-generator/uuid/satori

linters-settings:
gosimple:
go: "1.16"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
staticcheck:
go: "1.16"
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-SA1019", "-SA5008" ]
errcheck:
# https://github.com/kisielk/errcheck#errcheck
ignore: fmt:.*,os:.*
goconst:
# https://github.com/jgautheron/goconst#usage
ignore-tests: true
Expand All @@ -20,57 +18,181 @@ linters-settings:
gocritic:
# https://go-critic.github.io/overview#checks-overview
disabled-checks:
- appendAssign
- ifElseChain
gofumpt:
lang-version: "1.16"
# https://github.com/mvdan/gofumpt#gofumpt
extra-rules: true
gosimple:
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
revive:
ignore-generated-header: true
severity: warning
# https://github.com/mgechev/revive#available-rules
rules:
- name: context-keys-type
- name: time-equal
- name: time-naming
- name: var-declaration
- name: unexported-return
- name: errorf
- name: blank-imports
- name: context-as-argument
# - name: dot-imports
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
# - name: exported
- name: exported
- name: if-return
- name: increment-decrement
# - name: var-naming
# - name: package-comments
- name: var-naming
arguments:
- [ "ID" ] # allow list
- name: range
- name: receiver-naming
- name: indent-error-flow
- name: argument-limit
- name: file-header
- name: empty-block
- name: superfluous-else
- name: confusing-naming
- name: get-return
- name: modifies-parameter
- name: confusing-results
# - name: deep-exit
- name: unused-parameter
- name: unreachable-code
# - name: add-constant
- name: unnecessary-stmt
- name: struct-tag
- name: modifies-value-receiver
- name: constant-logical-expr
- name: bool-literal-in-expr
- name: redefines-builtin-id
- name: function-result-limit
- name: imports-blacklist
- name: range-val-in-closure
- name: range-val-address
- name: waitgroup-by-value
- name: atomic
- name: empty-lines
- name: call-to-gc
- name: duplicated-imports
- name: import-shadowing
- name: string-of-int
- name: string-format
- name: early-return
- name: unconditional-recursion
- name: identical-branches
- name: defer
- name: unexported-naming
- name: nested-structs
- name: useless-break
- name: banned-characters
- name: optimize-operands-order
# - name: use-any
- name: datarace
- name: comment-spacings
- name: redundant-import-alias
- name: import-alias-naming
- name: enforce-map-style
staticcheck:
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
stylecheck:
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-ST1000", "-ST1003" ]

linters:
disable-all: true
enable:
- gosimple
- govet
- ineffassign
- staticcheck
# - structcheck
- typecheck
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
# - exhaustive
- exportloopref
- forcetypeassert
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
# - godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
# - gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosimple
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- ireturn
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
# - wrapcheck
- zerologlint

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: _test.go
linters:
- dupl
- unparam
39 changes: 22 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,30 @@ import (
"github.com/sliveryou/go-tool/cipher"
)

type Cipher
func MustNewAesCbc(key, iv string) Cipher
func NewAesCbc(key, iv string) (Cipher, error)
var _ Cipher = (*aes.Cbc)(nil)

func MustNewAesCbc(key, iv string) *aes.Cbc
func NewAesCbc(key, iv string) (*aes.Cbc, error)
type Cipher interface {
Encrypt(src []byte) ([]byte, error)
Decrypt(src []byte) ([]byte, error)
}

// aes
import (
"github.com/sliveryou/go-tool/cipher/aes"
)

func AesCbcDecrypt(key, iv, src []byte) ([]byte, error)
func AesCbcDecryptBase64(key, iv []byte, msg string) ([]byte, error)
func AesCbcDecryptHex(key, iv []byte, msg string) ([]byte, error)
func AesCbcEncrypt(key, iv, src []byte) ([]byte, error)
func AesCbcEncryptBase64(key, iv, src []byte) (string, error)
func AesCbcEncryptHex(key, iv, src []byte) (string, error)
type AesCbc
func NewAesCbc(key, iv []byte) (*AesCbc, error)
func (a *AesCbc) Decrypt(src []byte) ([]byte, error)
func (a *AesCbc) Encrypt(src []byte) ([]byte, error)
func CbcDecrypt(key, iv, src []byte) ([]byte, error)
func CbcDecryptBase64(key, iv []byte, msg string) ([]byte, error)
func CbcDecryptHex(key, iv []byte, msg string) ([]byte, error)
func CbcEncrypt(key, iv, src []byte) ([]byte, error)
func CbcEncryptBase64(key, iv, src []byte) (string, error)
func CbcEncryptHex(key, iv, src []byte) (string, error)
type Cbc
func NewCbc(key, iv []byte) (*Cbc, error)
func (c *Cbc) Decrypt(src []byte) ([]byte, error)
func (c *Cbc) Encrypt(src []byte) ([]byte, error)

// pkcs
import (
Expand Down Expand Up @@ -80,8 +85,8 @@ func DecToBin(dec int64) string
func DecToHex(dec int64) string
func Float64ToBytes(f float64) []byte
func HexDecodeBytes(h string) []byte
func HexToBin(hex string) string
func HexToDec(hex string) int64
func HexToBin(h string) string
func HexToDec(h string) int64
func HexsDecodeBytes(hs []byte) []byte
func Int64ToBytes(i int64) []byte
func RunesToBytes(runes []rune) []byte
Expand Down Expand Up @@ -270,8 +275,8 @@ func ContainFloat64(slice []float64, value float64, places ...int) (index int)
func ContainInt(slice []int, value int) (index int)
func ContainInt32(slice []int32, value int32) (index int)
func ContainInt64(slice []int64, value int64) (index int)
func ContainString(slice []string, value string) (index int)
func ContainRune(slice []rune, value rune) (index int)
func ContainString(slice []string, value string) (index int)
func Count(slice interface{}) map[interface{}]int
func CountBool(slice []bool) map[bool]int
func CountFloat(slice []float64) map[float64]int
Expand Down Expand Up @@ -440,7 +445,7 @@ func UnixMillisecond(t time.Time, location ...*time.Location) int64
func UnixNanosecond(t time.Time, location ...*time.Location) int64
func UnixSecond(t time.Time, location ...*time.Location) int64
func UnixToTime(timestamp int64, location ...*time.Location) time.Time
func UnixTodayRange(location ...*time.Location) (int64, int64)
func UnixTodayRange(location ...*time.Location) (start, end int64)
```

### validator
Expand Down
Loading

0 comments on commit 6c2234b

Please sign in to comment.