Skip to content

Commit

Permalink
golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ne-sachirou committed Nov 7, 2023
1 parent 017a2bd commit 4f952b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cmd/example-grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ func main() {
srv := grpc.NewServer(opts...)
reflection.Register(srv)

gracefulgrpc.ListenAndServe(ctx, ":4317", srv, graceful.GracefulShutdownTimeout(time.Second))
if err := gracefulgrpc.ListenAndServe(
ctx,
":4317",
srv,
graceful.GracefulShutdownTimeout(time.Second),
); err != nil {
panic(err)
}
}
16 changes: 14 additions & 2 deletions cmd/example-http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

import (
"context"
"fmt"
"net/http"
"time"

Expand All @@ -14,7 +15,18 @@ func main() {
ctx := context.Background()

mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello, World!")) })
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if _, err := w.Write([]byte("Hello, World!")); err != nil {
fmt.Printf("failed to write response: %v\n", err)
}
})

gracefulhttp.ListenAndServe(ctx, ":8000", mux, graceful.GracefulShutdownTimeout(time.Second))
if err := gracefulhttp.ListenAndServe(
ctx,
":8000",
mux,
graceful.GracefulShutdownTimeout(time.Second),
); err != nil {
panic(err)
}
}

0 comments on commit 4f952b9

Please sign in to comment.