go-sonic / sonic

Sonic is a blogging platform developed by Go. Simple and powerful
MIT License
1.99k stars 255 forks source link

fix golangci-lint errors #391

Closed jakezhu9 closed 6 months ago

jakezhu9 commented 6 months ago

golangci-lint reports a number of errors and we should fix them:

config/config.go:107: File is not `gofumpt`-ed (gofumpt)
var mode string
var logMode LogMode
util/file.go:43:5: naked return in func `ZipFile.<func():35>` with 50 lines of code (nakedret)
                                return
                                ^
util/file.go:61:5: naked return in func `ZipFile.<func():35>` with 50 lines of code (nakedret)
                                return
                                ^
util/file.go:73:5: naked return in func `ZipFile.<func():35>` with 50 lines of code (nakedret)
                                return
                                ^
template/extension/link.go:48:3: SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck)
                rand.Seed(time.Now().UnixNano())
                ^
template/extension/tool.go:29:2: SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck)
        rand.Seed(time.Now().UnixNano())
        ^
model/dto/base.go:32:2: assigned to contentLen, but reassigned without using the value (wastedassign)
        contentLen := 0
        ^
event/listener/template_config.go:122:2: assigned to themeBasePath, but reassigned without using the value (wastedassign)
        themeBasePath := ""
        ^

You can run golangci-lint and get the above output by running:

docker run -t --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run -v
jakezhu9 commented 6 months ago

fix in https://github.com/go-sonic/sonic/pull/393 and https://github.com/go-sonic/sonic/pull/392