mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fix: lint errors
This commit is contained in:
parent
7e1298b21b
commit
00dfc6e1f2
@ -118,6 +118,8 @@ linters:
|
||||
#- 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]
|
||||
settings:
|
||||
gomoddirectives:
|
||||
replace-local: true
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- ifElseChain
|
||||
|
||||
62
Makefile
62
Makefile
@ -29,7 +29,7 @@ endif
|
||||
.husky:
|
||||
@git config core.hooksPath .husky
|
||||
|
||||
## === Tasks ===
|
||||
### Tasks
|
||||
|
||||
.PHONY: check
|
||||
## Run lint & test
|
||||
@ -38,22 +38,22 @@ check: tidy examples lint test
|
||||
.PHONY: tidy
|
||||
## Run go mod tidy
|
||||
tidy:
|
||||
@go mod tidy
|
||||
@find . -name go.mod -execdir go mod tidy \;
|
||||
|
||||
.PHONY: lint
|
||||
## Run linter
|
||||
lint:
|
||||
@golangci-lint run
|
||||
@find . -name go.mod -execdir golangci-lint run \;
|
||||
|
||||
.PHONY: lint.fix
|
||||
## Run linter and fix
|
||||
lint.fix:
|
||||
@golangci-lint run --fix
|
||||
@find . -name go.mod -execdir golangci-lint run --fix \;
|
||||
|
||||
.PHONY: test
|
||||
## Run go 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
|
||||
## Build binary
|
||||
@ -77,13 +77,6 @@ install:
|
||||
install.debug:
|
||||
@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
|
||||
define examples
|
||||
.PHONY: example.$(1)
|
||||
@ -105,10 +98,8 @@ example.$(1).lint:
|
||||
endef
|
||||
$(foreach p,$(EXAMPLES),$(eval $(call examples,$(p))))
|
||||
|
||||
## === Examples ===
|
||||
|
||||
.PHONY: examples
|
||||
## Build examples
|
||||
## Generate examples
|
||||
examples:
|
||||
@for name in example/*/; do\
|
||||
if [ $$name != "example/node_modules/" ]; then \
|
||||
@ -118,36 +109,23 @@ examples:
|
||||
done
|
||||
.PHONY: examples
|
||||
|
||||
## === Utils ===
|
||||
### Utils
|
||||
|
||||
.PHONY: help
|
||||
## Show help text
|
||||
help:
|
||||
@echo "gotsrpc\n"
|
||||
@echo "Usage:\n make [task]"
|
||||
@awk '{ \
|
||||
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
|
||||
helpCommand = substr($$0, index($$0, ":") + 2); \
|
||||
if (helpMessage) { \
|
||||
printf "\033[36m%-23s\033[0m %s\n", \
|
||||
helpCommand, helpMessage; \
|
||||
helpMessage = ""; \
|
||||
} \
|
||||
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
|
||||
helpCommand = substr($$0, 0, index($$0, ":")); \
|
||||
if (helpMessage) { \
|
||||
printf "\033[36m%-23s\033[0m %s\n", \
|
||||
helpCommand, helpMessage"\n"; \
|
||||
helpMessage = ""; \
|
||||
} \
|
||||
if($$0 ~ /^### /){ \
|
||||
if(help) printf "%-23s %s\n\n", cmd, help; help=""; \
|
||||
printf "\n%s:\n", substr($$0,5); \
|
||||
} else if($$0 ~ /^[a-zA-Z0-9._-]+:/){ \
|
||||
cmd = substr($$0, 1, index($$0, ":")-1); \
|
||||
if(help) printf " %-23s %s\n", cmd, help; help=""; \
|
||||
} else if($$0 ~ /^##/){ \
|
||||
if (helpMessage) { \
|
||||
helpMessage = helpMessage"\n "substr($$0, 3); \
|
||||
} else { \
|
||||
helpMessage = substr($$0, 3); \
|
||||
help = help ? help "\n " substr($$0,3) : substr($$0,3); \
|
||||
} else if(help){ \
|
||||
print "\n " help "\n"; help=""; \
|
||||
} \
|
||||
} else { \
|
||||
if (helpMessage) { \
|
||||
print "\n "helpMessage"\n" \
|
||||
} \
|
||||
helpMessage = ""; \
|
||||
} \
|
||||
}' \
|
||||
$(MAKEFILE_LIST)
|
||||
}' $(MAKEFILE_LIST)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
|
||||
|
||||
@ -25,7 +27,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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
|
||||
|
||||
@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
fh := frontendsvs.NewDefaultServiceGoTSRPCProxy(frontend.New(backendsvs.NewDefaultServiceGoTSRPCClient("http://localhost:3000")))
|
||||
bh := backendsvs.NewDefaultServiceGoTSRPCProxy(backend.New())
|
||||
@ -40,7 +41,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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()
|
||||
}()
|
||||
|
||||
|
||||
@ -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/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/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
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/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/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
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/valyala/gorpc v0.0.0-20160519171614-908281bef774 h1:SUHFQHAaySqF0YHCmmm0EIFooFZpDPpi5KTom7YJ07c=
|
||||
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/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
|
||||
@ -26,6 +26,7 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
|
||||
|
||||
@ -41,7 +42,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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()
|
||||
}()
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"strings"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
|
||||
|
||||
@ -25,7 +27,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
|
||||
|
||||
@ -29,7 +30,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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()
|
||||
}()
|
||||
|
||||
|
||||
@ -8,11 +8,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"github.com/foomo/gotsrpc/v2/example/union/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
fs := http.FileServer(http.Dir("./client"))
|
||||
ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{})
|
||||
|
||||
@ -28,7 +28,7 @@ func main() {
|
||||
|
||||
go func() {
|
||||
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()
|
||||
}()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user