Skip to content

Commit

Permalink
fix: golangci-lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
golangboy committed Feb 24, 2024
1 parent 408046f commit d2e5c6b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion event/listener/template_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (t *TemplateConfigListener) loadThemeConfig(ctx context.Context) error {
if err != nil {
return err
}
themeBasePath := ""
var themeBasePath string
if isEnabledAbsolutePath {
themeBasePath = blogBaseURL + "/themes/" + theme.FolderName
} else {
Expand Down
2 changes: 1 addition & 1 deletion model/dto/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Page struct {
}

func NewPage(content interface{}, totalCount int64, page param.Page) *Page {
contentLen := 0
var contentLen int
r := reflect.ValueOf(content)

if !r.IsNil() && r.Kind() != reflect.Slice {
Expand Down
2 changes: 0 additions & 2 deletions template/extension/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package extension
import (
"context"
"math/rand"
"time"

"github.com/go-sonic/sonic/model/dto"
"github.com/go-sonic/sonic/service"
Expand Down Expand Up @@ -45,7 +44,6 @@ func (l *linkExtension) addListLinksRandom() {
if err != nil {
return nil, err
}
rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(links), func(i, j int) {
links[i], links[j] = links[j], links[i]
})
Expand Down
2 changes: 0 additions & 2 deletions template/extension/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package extension

import (
"math/rand"
"time"

"github.com/go-sonic/sonic/template"
"github.com/go-sonic/sonic/util"
Expand All @@ -26,7 +25,6 @@ func (t *toolExtension) addRainbow() {
}

func (t *toolExtension) addRandom() {
rand.Seed(time.Now().UnixNano())
random := func(min, max int) int {
return min + rand.Intn(max-min)
}
Expand Down
8 changes: 4 additions & 4 deletions util/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ZipFile(dst string, srcs ...string) (err error) {
// 通过文件信息,创建 zip 的文件信息
fh, err := zip.FileInfoHeader(fi)
if err != nil {
return
return err
}
if path == src {
fh.Name = filepath.Base(src)
Expand All @@ -58,7 +58,7 @@ func ZipFile(dst string, srcs ...string) (err error) {
// 写入文件信息,并返回一个 Write 结构
w, err := zw.CreateHeader(fh)
if err != nil {
return
return err
}

// 检测,如果不是标准文件就只写入头信息,不写入文件数据到 w
Expand All @@ -70,14 +70,14 @@ func ZipFile(dst string, srcs ...string) (err error) {
// 打开要压缩的文件
fr, err := os.Open(path)
if err != nil {
return
return err
}
defer fr.Close()

// 将打开的文件 Copy 到 w
_, err = io.Copy(w, fr)
if err != nil {
return
return err
}
// 输出压缩的内容

Expand Down

0 comments on commit d2e5c6b

Please sign in to comment.