lint by golangci-lint (#3080)

This commit is contained in:
fatedier
2022-08-29 01:02:53 +08:00
committed by GitHub
parent f4e4fbea62
commit 9d077b02cf
122 changed files with 947 additions and 1331 deletions

View File

@@ -5,6 +5,7 @@ import (
"net"
"net/http"
"strconv"
"time"
)
type Server struct {
@@ -44,7 +45,7 @@ func WithBindPort(port int) Option {
}
}
func WithTlsConfig(tlsConfig *tls.Config) Option {
func WithTLSConfig(tlsConfig *tls.Config) Option {
return func(s *Server) *Server {
s.tlsConfig = tlsConfig
return s
@@ -61,7 +62,7 @@ func WithHandler(h http.Handler) Option {
func WithResponse(resp []byte) Option {
return func(s *Server) *Server {
s.handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write(resp)
_, _ = w.Write(resp)
})
return s
}
@@ -74,16 +75,21 @@ func (s *Server) Run() error {
addr := net.JoinHostPort(s.bindAddr, strconv.Itoa(s.bindPort))
hs := &http.Server{
Addr: addr,
Handler: s.handler,
TLSConfig: s.tlsConfig,
Addr: addr,
Handler: s.handler,
TLSConfig: s.tlsConfig,
ReadHeaderTimeout: time.Minute,
}
s.hs = hs
if s.tlsConfig == nil {
go hs.Serve(s.l)
go func() {
_ = hs.Serve(s.l)
}()
} else {
go hs.ServeTLS(s.l, "", "")
go func() {
_ = hs.ServeTLS(s.l, "", "")
}()
}
return nil
}

View File

@@ -127,7 +127,7 @@ func (s *Server) handle(c net.Conn) {
if len(s.respContent) > 0 {
buf = s.respContent
}
rpc.WriteBytes(c, buf)
_, _ = rpc.WriteBytes(c, buf)
}
}