Skip to content

Commit f9a0c7c

Browse files
appleboyclaude
andcommitted
fix: resolve golangci-lint issues in example
- Handle error return values from c.Error (errcheck) - Fix comment formatting with space after // (gocritic) - Add nolint:gosec for example random number usage - Fix misspelling: occured -> occurred 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4010432 commit f9a0c7c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

_example/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ func main() {
117117
}),
118118
logger.WithMessage("Request ended"),
119119
), func(c *gin.Context) {
120-
c.Error(errors.New("some error has occured here"))
121-
c.Error(errors.New("and some error has occured there"))
120+
_ = c.Error(errors.New("some error has occurred here"))
121+
_ = c.Error(errors.New("and some error has occurred there"))
122122
c.String(http.StatusBadGateway, "pong "+fmt.Sprint(time.Now().Unix()))
123123
})
124124

@@ -132,10 +132,10 @@ func main() {
132132
}),
133133
logger.WithSpecificLogLevelByStatusCode(specificLevels),
134134
), func(c *gin.Context) {
135-
//with http-400 StatusBadRequest, it must follow the normal execution, in this case, the log level is warn
136-
//c.String(http.StatusBadRequest, "pong 429 "+fmt.Sprint(time.Now().Unix()))
135+
// with http-400 StatusBadRequest, it must follow the normal execution, in this case, the log level is warn
136+
// c.String(http.StatusBadRequest, "pong 429 "+fmt.Sprint(time.Now().Unix()))
137137

138-
//with http-429 StatusTooManyRequests, it must follow the specific log level defined for this status code (trace)
138+
// with http-429 StatusTooManyRequests, it must follow the specific log level defined for this status code (trace)
139139
c.String(http.StatusTooManyRequests, "pong 429 "+fmt.Sprint(time.Now().Unix()))
140140
})
141141

@@ -154,8 +154,8 @@ func main() {
154154
return e.Any("data1", c.MustGet("data1")).Any("data2", c.MustGet("data2"))
155155
}),
156156
), func(c *gin.Context) {
157-
c.Set("data1", rand.Intn(100))
158-
c.Set("data2", rand.Intn(100))
157+
c.Set("data1", rand.Intn(100)) //nolint:gosec // example code, not for security
158+
c.Set("data2", rand.Intn(100)) //nolint:gosec // example code, not for security
159159
c.String(http.StatusOK, "pong "+fmt.Sprint(time.Now().Unix()))
160160
})
161161

0 commit comments

Comments
 (0)