fix: lint errors

This commit is contained in:
Kevin Franklin Kim 2025-09-19 08:53:09 +02:00
parent 7e1298b21b
commit 00dfc6e1f2
No known key found for this signature in database
9 changed files with 50 additions and 51 deletions

View File

@ -118,6 +118,8 @@ linters:
#- wsl # add or remove empty lines [fast: true, auto-fix: false] #- wsl # add or remove empty lines [fast: true, auto-fix: false]
#- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false] #- zerologlint # Detects the wrong usage of `zerolog` that a user forgets to dispatch with `Send` or `Msg` [fast: false, auto-fix: false]
settings: settings:
gomoddirectives:
replace-local: true
gocritic: gocritic:
disabled-checks: disabled-checks:
- ifElseChain - ifElseChain

View File

@ -29,7 +29,7 @@ endif
.husky: .husky:
@git config core.hooksPath .husky @git config core.hooksPath .husky
## === Tasks === ### Tasks
.PHONY: check .PHONY: check
## Run lint & test ## Run lint & test
@ -38,22 +38,22 @@ check: tidy examples lint test
.PHONY: tidy .PHONY: tidy
## Run go mod tidy ## Run go mod tidy
tidy: tidy:
@go mod tidy @find . -name go.mod -execdir go mod tidy \;
.PHONY: lint .PHONY: lint
## Run linter ## Run linter
lint: lint:
@golangci-lint run @find . -name go.mod -execdir golangci-lint run \;
.PHONY: lint.fix .PHONY: lint.fix
## Run linter and fix ## Run linter and fix
lint.fix: lint.fix:
@golangci-lint run --fix @find . -name go.mod -execdir golangci-lint run --fix \;
.PHONY: test .PHONY: test
## Run go test ## Run go test
test: test:
@GO_TEST_TAGS=-skip go test -coverprofile=coverage.out --tags=safe -race ./... @GO_TEST_TAGS=-skip find . -name go.mod -execdir go test -coverprofile=coverage.out --tags=safe -race ./... \;
.PHONY: build .PHONY: build
## Build binary ## Build binary
@ -77,13 +77,6 @@ install:
install.debug: install.debug:
@go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go @go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go
.PHONY: outdated
## Show outdated direct dependencies
outdated:
@go list -u -m -json all | go-mod-outdated -update -direct
## === Tools ===
EXAMPLES=basic errors monitor nullable union time types EXAMPLES=basic errors monitor nullable union time types
define examples define examples
.PHONY: example.$(1) .PHONY: example.$(1)
@ -105,10 +98,8 @@ example.$(1).lint:
endef endef
$(foreach p,$(EXAMPLES),$(eval $(call examples,$(p)))) $(foreach p,$(EXAMPLES),$(eval $(call examples,$(p))))
## === Examples ===
.PHONY: examples .PHONY: examples
## Build examples ## Generate examples
examples: examples:
@for name in example/*/; do\ @for name in example/*/; do\
if [ $$name != "example/node_modules/" ]; then \ if [ $$name != "example/node_modules/" ]; then \
@ -118,36 +109,23 @@ examples:
done done
.PHONY: examples .PHONY: examples
## === Utils === ### Utils
.PHONY: help
## Show help text ## Show help text
help: help:
@echo "gotsrpc\n"
@echo "Usage:\n make [task]"
@awk '{ \ @awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \ if($$0 ~ /^### /){ \
helpCommand = substr($$0, index($$0, ":") + 2); \ if(help) printf "%-23s %s\n\n", cmd, help; help=""; \
if (helpMessage) { \ printf "\n%s:\n", substr($$0,5); \
printf "\033[36m%-23s\033[0m %s\n", \ } else if($$0 ~ /^[a-zA-Z0-9._-]+:/){ \
helpCommand, helpMessage; \ cmd = substr($$0, 1, index($$0, ":")-1); \
helpMessage = ""; \ if(help) printf " %-23s %s\n", cmd, help; help=""; \
} \ } else if($$0 ~ /^##/){ \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \ help = help ? help "\n " substr($$0,3) : substr($$0,3); \
helpCommand = substr($$0, 0, index($$0, ":")); \ } else if(help){ \
if (helpMessage) { \ print "\n " help "\n"; help=""; \
printf "\033[36m%-23s\033[0m %s\n", \ } \
helpCommand, helpMessage"\n"; \ }' $(MAKEFILE_LIST)
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"context"
"net/http" "net/http"
"os/exec" "os/exec"
"strings" "strings"
@ -10,6 +11,7 @@ import (
) )
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
@ -25,7 +27,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
}() }()
panic(http.ListenAndServe("localhost:3000", mux)) //nolint:gosec panic(http.ListenAndServe("localhost:3000", mux)) //nolint:gosec

View File

@ -22,6 +22,7 @@ import (
) )
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
fh := frontendsvs.NewDefaultServiceGoTSRPCProxy(frontend.New(backendsvs.NewDefaultServiceGoTSRPCClient("http://localhost:3000"))) fh := frontendsvs.NewDefaultServiceGoTSRPCProxy(frontend.New(backendsvs.NewDefaultServiceGoTSRPCClient("http://localhost:3000")))
bh := backendsvs.NewDefaultServiceGoTSRPCProxy(backend.New()) bh := backendsvs.NewDefaultServiceGoTSRPCProxy(backend.New())
@ -40,7 +41,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
call() call()
}() }()

View File

@ -1,9 +1,19 @@
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/foomo/go v0.0.3 h1:5pGzcPC78dImuBTT7nsZZnH+GIQUylbCtMkFEH26uZk=
github.com/foomo/go v0.0.3/go.mod h1:x6g64wiQusqaFElnh5rlk9unCgLKmfUWy0YFLejJxio=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@ -16,6 +26,8 @@ github.com/ugorji/go/codec v1.3.1-0.20250729181524-a9af3d3cd758 h1:coa7c9qOU6bkV
github.com/ugorji/go/codec v1.3.1-0.20250729181524-a9af3d3cd758/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= github.com/ugorji/go/codec v1.3.1-0.20250729181524-a9af3d3cd758/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774 h1:SUHFQHAaySqF0YHCmmm0EIFooFZpDPpi5KTom7YJ07c= github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774 h1:SUHFQHAaySqF0YHCmmm0EIFooFZpDPpi5KTom7YJ07c=
github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774/go.mod h1:8uNqM1i7pr0jO7gdvbNCgsSa8Ki2vMh7JCQxO9BlF90= github.com/valyala/gorpc v0.0.0-20160519171614-908281bef774/go.mod h1:8uNqM1i7pr0jO7gdvbNCgsSa8Ki2vMh7JCQxO9BlF90=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=

View File

@ -26,6 +26,7 @@ func init() {
} }
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
@ -41,7 +42,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
call() call()
}() }()

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"context"
"net/http" "net/http"
"os/exec" "os/exec"
"strings" "strings"
@ -10,6 +11,7 @@ import (
) )
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
@ -25,7 +27,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
}() }()
panic(http.ListenAndServe("localhost:3000", mux)) //nolint:gosec panic(http.ListenAndServe("localhost:3000", mux)) //nolint:gosec

View File

@ -14,6 +14,7 @@ import (
) )
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
@ -29,7 +30,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
call() call()
}() }()

View File

@ -8,11 +8,11 @@ import (
"time" "time"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/foomo/gotsrpc/v2/example/union/service" "github.com/foomo/gotsrpc/v2/example/union/service"
) )
func main() { func main() {
ctx := context.Background()
fs := http.FileServer(http.Dir("./client")) fs := http.FileServer(http.Dir("./client"))
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
@ -28,7 +28,7 @@ func main() {
go func() { go func() {
time.Sleep(time.Second) time.Sleep(time.Second)
_ = exec.Command("open", "http://127.0.0.1:3000").Run() _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run()
call() call()
}() }()