Skip to content

Commit c87fed4

Browse files
fix linting
1 parent c04b070 commit c87fed4

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,21 @@ mocks:
111111

112112
# Generate swagger docs
113113
swagger:
114-
swag init -g cmd/server/main.go -o ./docs
114+
swag init -g cmd/server/main.go -o ./docs
115+
116+
# Lint the code
117+
lint:
118+
golangci-lint run
119+
120+
# Lint and fix auto-fixable issues
121+
lint-fix:
122+
golangci-lint run --fix
123+
124+
# Install linting tools
125+
lint-install:
126+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
127+
128+
# Full check (tests + lint)
129+
check: test lint
130+
131+
.PHONY: lint lint-fix lint-install check

internal/models/post.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,11 @@ func (p *Post) ToResponse() PostResponse {
225225

226226
if len(p.TypeData) > 0 {
227227
var typeData interface{}
228-
json.Unmarshal(p.TypeData, &typeData)
229-
response.TypeData = typeData
228+
if err := json.Unmarshal(p.TypeData, &typeData); err == nil {
229+
response.TypeData = typeData
230+
} else {
231+
response.TypeData = nil
232+
}
230233
}
231234
return response
232235
}

internal/services/post.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ func (s *PostService) VoteOnPoll(postID, userID uint, req *models.PollVoteReques
406406

407407
if !pollData.AllowMultiple {
408408
for _, vote := range existingVotes {
409-
s.postRepo.RemoveVoteFromPoll(postID, userID, vote.OptionID)
409+
if err := s.postRepo.RemoveVoteFromPoll(postID, userID, vote.OptionID); err != nil {
410+
return err
411+
}
410412
}
411413
}
412414

0 commit comments

Comments
 (0)