[PR #10] [MERGED] Make Go linter happy #40

Closed
opened 2026-02-28 01:20:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tufanbarisyildirim/gonginx/pull/10
Author: @qba73
Created: 7/31/2022
Status: Merged
Merged: 7/31/2022
Merged by: @tufanbarisyildirim

Base: masterHead: linterfix


📝 Commits (2)

📊 Changes

7 files changed (+51 additions, -14 deletions)

View changed files

.github/workflows/golangci-lint.yml (+43 -0)
📝 Makefile (+4 -1)
📝 dumper.go (+1 -2)
📝 http.go (+1 -3)
📝 parser/lexer_test.go (+0 -4)
📝 parser/parser.go (+1 -1)
📝 upstream_server.go (+1 -3)

📄 Description

Hi @tufanbarisyildirim, if you don't mind this PR introduces additional quality checks using Go linter. I have run Go linter locally on my laptop and this PR includes suggested fixes.

Executing Go linter before the change:

➜  gonginx git:(linterfix) golangci-lint run ./...

parser/lexer_test.go:100:6: `panicFunc` is unused (deadcode)
func panicFunc() {
     ^
parser/parser.go:165:4: S1023: redundant break statement (gosimple)
			break
			^
dumper.go:112:9: S1030: should use buf.String() instead of string(buf.Bytes()) (gosimple)
	return string(buf.Bytes())
	       ^
http.go:46:2: S1011: should replace loop with `directives = append(directives, h.Directives...)` (gosimple)
	for _, directive := range h.Directives {
	^
upstream_server.go:58:2: S1011: should replace loop with `directive.Parameters = append(directive.Parameters, uss.Flags...)` (gosimple)
	for _, flag := range uss.Flags {
	^

After changes applied:

➜  gonginx git:(linterfix) golangci-lint run ./...

Also, if you are ok with it I am including a separate github action to run linter automatically on PRs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tufanbarisyildirim/gonginx/pull/10 **Author:** [@qba73](https://github.com/qba73) **Created:** 7/31/2022 **Status:** ✅ Merged **Merged:** 7/31/2022 **Merged by:** [@tufanbarisyildirim](https://github.com/tufanbarisyildirim) **Base:** `master` ← **Head:** `linterfix` --- ### 📝 Commits (2) - [`334c3b4`](https://github.com/tufanbarisyildirim/gonginx/commit/334c3b49d43dd433042fff889337b07483a06e9d) Make Go linter happy - [`ffec900`](https://github.com/tufanbarisyildirim/gonginx/commit/ffec900dbac44d014429375723f1475e1657aa47) Update Go version in gh action ### 📊 Changes **7 files changed** (+51 additions, -14 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/golangci-lint.yml` (+43 -0) 📝 `Makefile` (+4 -1) 📝 `dumper.go` (+1 -2) 📝 `http.go` (+1 -3) 📝 `parser/lexer_test.go` (+0 -4) 📝 `parser/parser.go` (+1 -1) 📝 `upstream_server.go` (+1 -3) </details> ### 📄 Description Hi @tufanbarisyildirim, if you don't mind this PR introduces additional quality checks using [Go linter](https://golangci-lint.run/usage/quick-start). I have run Go linter locally on my laptop and this PR includes suggested fixes. Executing Go linter before the change: ``` ➜ gonginx git:(linterfix) golangci-lint run ./... parser/lexer_test.go:100:6: `panicFunc` is unused (deadcode) func panicFunc() { ^ parser/parser.go:165:4: S1023: redundant break statement (gosimple) break ^ dumper.go:112:9: S1030: should use buf.String() instead of string(buf.Bytes()) (gosimple) return string(buf.Bytes()) ^ http.go:46:2: S1011: should replace loop with `directives = append(directives, h.Directives...)` (gosimple) for _, directive := range h.Directives { ^ upstream_server.go:58:2: S1011: should replace loop with `directive.Parameters = append(directive.Parameters, uss.Flags...)` (gosimple) for _, flag := range uss.Flags { ^ ``` After changes applied: ``` ➜ gonginx git:(linterfix) golangci-lint run ./... ``` Also, if you are ok with it I am including a separate [github action](https://github.com/marketplace/actions/run-golangci-lint) to run linter automatically on PRs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 01:20:39 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gonginx#40
No description provided.