Skip to content

Commit 53db556

Browse files
golangboyjakezhu9
authored andcommittedFeb 24, 2024
fix: golangci-lint errors
1 parent 408046f commit 53db556

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed
 

‎event/listener/template_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (t *TemplateConfigListener) loadThemeConfig(ctx context.Context) error {
119119
if err != nil {
120120
return err
121121
}
122-
themeBasePath := ""
122+
var themeBasePath string
123123
if isEnabledAbsolutePath {
124124
themeBasePath = blogBaseURL + "/themes/" + theme.FolderName
125125
} else {

‎model/dto/base.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Page struct {
2929
}
3030

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

3535
if !r.IsNil() && r.Kind() != reflect.Slice {

‎template/extension/link.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package extension
33
import (
44
"context"
55
"math/rand"
6-
"time"
76

87
"github.com/go-sonic/sonic/model/dto"
98
"github.com/go-sonic/sonic/service"
@@ -45,7 +44,6 @@ func (l *linkExtension) addListLinksRandom() {
4544
if err != nil {
4645
return nil, err
4746
}
48-
rand.Seed(time.Now().UnixNano())
4947
rand.Shuffle(len(links), func(i, j int) {
5048
links[i], links[j] = links[j], links[i]
5149
})

‎template/extension/tool.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package extension
22

33
import (
44
"math/rand"
5-
"time"
65

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

2827
func (t *toolExtension) addRandom() {
29-
rand.Seed(time.Now().UnixNano())
3028
random := func(min, max int) int {
3129
return min + rand.Intn(max-min)
3230
}

‎util/file.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func ZipFile(dst string, srcs ...string) (err error) {
4040
// 通过文件信息,创建 zip 的文件信息
4141
fh, err := zip.FileInfoHeader(fi)
4242
if err != nil {
43-
return
43+
return err
4444
}
4545
if path == src {
4646
fh.Name = filepath.Base(src)
@@ -58,7 +58,7 @@ func ZipFile(dst string, srcs ...string) (err error) {
5858
// 写入文件信息,并返回一个 Write 结构
5959
w, err := zw.CreateHeader(fh)
6060
if err != nil {
61-
return
61+
return err
6262
}
6363

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

7777
// 将打开的文件 Copy 到 w
7878
_, err = io.Copy(w, fr)
7979
if err != nil {
80-
return
80+
return err
8181
}
8282
// 输出压缩的内容
8383

0 commit comments

Comments
 (0)
Please sign in to comment.