aboutsummaryrefslogtreecommitdiff
path: root/lib/http/example_server_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-09-14 00:59:40 +0700
committerShulhan <ms@kilabit.info>2023-09-14 00:59:40 +0700
commitb89afa24feaee375e914a69b23c2036733991f3e (patch)
treefd2c0270a7d7ad644526b77cba409c3956de4820 /lib/http/example_server_test.go
parenta352f66260b7172e9553351d44d67c54d48efe7a (diff)
downloadpakakeh.go-b89afa24feaee375e914a69b23c2036733991f3e.tar.xz
all: fix variable shadowing as reported by shadow tool
The shadow tool [1] report a variable where its name is declared twice or more, in different scope. [1] https://pkg.go.dev/golang.org/x/tools@v0.13.0/go/analysis/passes/shadow
Diffstat (limited to 'lib/http/example_server_test.go')
-rw-r--r--lib/http/example_server_test.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/http/example_server_test.go b/lib/http/example_server_test.go
index aad952aa..2cf897c0 100644
--- a/lib/http/example_server_test.go
+++ b/lib/http/example_server_test.go
@@ -16,28 +16,34 @@ func ExampleServer_customHTTPStatusCode() {
type CustomResponse struct {
Status int `json:"status"`
}
- exp := CustomResponse{
- Status: http.StatusBadRequest,
- }
- opts := &ServerOptions{
- Address: "127.0.0.1:8123",
- }
+ var (
+ exp = CustomResponse{
+ Status: http.StatusBadRequest,
+ }
+
+ opts = &ServerOptions{
+ Address: "127.0.0.1:8123",
+ }
+
+ srv *Server
+ err error
+ )
- testServer, err := NewServer(opts)
+ srv, err = NewServer(opts)
if err != nil {
log.Fatal(err)
}
go func() {
- err = testServer.Start()
+ err = srv.Start()
if err != nil {
log.Println(err)
}
}()
defer func() {
- _ = testServer.Stop(5 * time.Second)
+ _ = srv.Stop(5 * time.Second)
}()
epCustom := &Endpoint{
@@ -52,7 +58,7 @@ func ExampleServer_customHTTPStatusCode() {
},
}
- err = testServer.registerPost(epCustom)
+ err = srv.registerPost(epCustom)
if err != nil {
log.Fatal(err)
}