Skip to content

Commit 4cf3a83

Browse files
liranliran
authored andcommitted
fix: Final golangci-lint fixes
- Add error checking for client.Close() in defer statements - Replace if-else chain with tagged switch statement - golangci-lint now passes with 0 issues
1 parent 3c2a5ef commit 4cf3a83

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

10_testcontainers_go/redis_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestRedisContainer(t *testing.T) {
5959
client := redis.NewClient(&redis.Options{
6060
Addr: redisAddr,
6161
})
62-
defer client.Close()
62+
defer func() { _ = client.Close() }()
6363

6464
// Test Redis operations
6565
t.Run("SET and GET operations", func(t *testing.T) {
@@ -277,7 +277,7 @@ func TestRedisContainer_MultipleOperations(t *testing.T) {
277277
client := redis.NewClient(&redis.Options{
278278
Addr: fmt.Sprintf("%s:%s", host, port.Port()),
279279
})
280-
defer client.Close()
280+
defer func() { _ = client.Close() }()
281281

282282
// Simulate a user session management scenario
283283
t.Run("User session management", func(t *testing.T) {

11_httpexpect/api_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ func createAPIHandler() http.Handler {
5454

5555
// Simple routing - in real app use a router library
5656
id := r.URL.Path[len("/users/"):]
57-
if id == "1" {
57+
switch id {
58+
case "1":
5859
user := User{ID: 1, Name: "John Doe", Email: "john@example.com"}
5960
w.Header().Set("Content-Type", "application/json")
6061
_ = json.NewEncoder(w).Encode(user)
61-
} else if id == "999" {
62-
http.Error(w, "User not found", http.StatusNotFound)
63-
} else {
62+
default:
6463
http.Error(w, "User not found", http.StatusNotFound)
6564
}
6665
})

0 commit comments

Comments
 (0)