chore: fix warnings (#3990)

master^2
Kevin Wan 8 months ago committed by GitHub
parent 159ecb7386
commit e9e55125a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,7 +12,7 @@ import (
type DepositServer struct{}
// Deposit handles the deposit requests.
func (*DepositServer) Deposit(ctx context.Context, req *DepositRequest) (*DepositResponse, error) {
func (*DepositServer) Deposit(_ context.Context, req *DepositRequest) (*DepositResponse, error) {
if req.GetAmount() < 0 {
return nil, status.Errorf(codes.InvalidArgument, "cannot deposit %v", req.GetAmount())
}

@ -435,7 +435,7 @@ type mockedRouter struct {
func (m mockedRouter) ServeHTTP(_ http.ResponseWriter, _ *http.Request) {
}
func (m mockedRouter) Handle(_, _ string, handler http.Handler) error {
func (m mockedRouter) Handle(_, _ string, _ http.Handler) error {
return errors.New("foo")
}

@ -60,7 +60,8 @@ func executeCallbacks(w http.ResponseWriter, r *http.Request, next http.Handler,
}
}
func handleVerificationFailure(w http.ResponseWriter, r *http.Request, next http.Handler, strict bool, code int) {
func handleVerificationFailure(w http.ResponseWriter, r *http.Request, next http.Handler,
strict bool, _ int) {
if strict {
w.WriteHeader(http.StatusForbidden)
} else {

@ -327,7 +327,7 @@ func buildRequest(rs requestSettings) (*http.Request, error) {
query,
bodySign,
}, "\n")
rs.signature = codec.HmacBase64([]byte(key), contentOfSign)
rs.signature = codec.HmacBase64(key, contentOfSign)
}
var mode string

@ -224,7 +224,7 @@ func (m flushableResponseWriter) Write(p []byte) (int, error) {
return m.writer.Write(p)
}
func (m flushableResponseWriter) WriteHeader(statusCode int) {
func (m flushableResponseWriter) WriteHeader(_ int) {
panic("implement me")
}
@ -240,6 +240,6 @@ func (t *halfWriter) Write(p []byte) (n int, err error) {
type badWriter struct {
}
func (b *badWriter) Write(p []byte) (n int, err error) {
func (b *badWriter) Write(_ []byte) (n int, err error) {
return 0, io.ErrClosedPipe
}

@ -164,7 +164,7 @@ type mockedReadCloser struct {
errMsg string
}
func (m mockedReadCloser) Read(p []byte) (n int, err error) {
func (m mockedReadCloser) Read(_ []byte) (n int, err error) {
return 0, errors.New(m.errMsg)
}

@ -175,6 +175,6 @@ func (m mockedReader) Close() error {
return nil
}
func (m mockedReader) Read(p []byte) (n int, err error) {
func (m mockedReader) Read(_ []byte) (n int, err error) {
return 0, errors.New("dummy")
}

@ -1,6 +1,9 @@
package httpx
import "net/http"
import (
"errors"
"net/http"
)
const xForwardedFor = "X-Forwarded-For"
@ -11,7 +14,7 @@ func GetFormValues(r *http.Request) (map[string]any, error) {
}
if err := r.ParseMultipartForm(maxMemory); err != nil {
if err != http.ErrNotMultipart {
if !errors.Is(err, http.ErrNotMultipart) {
return nil, err
}
}

@ -142,7 +142,7 @@ func (m mockClientConn) GetOrBuildProducer(builder balancer.ProducerBuilder) (
return builder.Build(m)
}
func (m mockClientConn) UpdateAddresses(addresses []resolver.Address) {
func (m mockClientConn) UpdateAddresses(_ []resolver.Address) {
}
func (m mockClientConn) Connect() {

@ -420,10 +420,10 @@ func (m *mockedClientStream) Context() context.Context {
return context.Background()
}
func (m *mockedClientStream) SendMsg(v any) error {
func (m *mockedClientStream) SendMsg(_ any) error {
return m.err
}
func (m *mockedClientStream) RecvMsg(v any) error {
func (m *mockedClientStream) RecvMsg(_ any) error {
return m.err
}

@ -46,17 +46,17 @@ func (l *Logger) Fatalln(args ...any) {
}
// Info ignores the grpc info logs.
func (l *Logger) Info(args ...any) {
func (l *Logger) Info(_ ...any) {
// ignore builtin grpc info
}
// Infoln ignores the grpc info logs.
func (l *Logger) Infoln(args ...any) {
func (l *Logger) Infoln(_ ...any) {
// ignore builtin grpc info
}
// Infof ignores the grpc info logs.
func (l *Logger) Infof(format string, args ...any) {
func (l *Logger) Infof(_ string, _ ...any) {
// ignore builtin grpc info
}
@ -66,16 +66,16 @@ func (l *Logger) V(v int) bool {
}
// Warning ignores the grpc warning logs.
func (l *Logger) Warning(args ...any) {
func (l *Logger) Warning(_ ...any) {
// ignore builtin grpc warning
}
// Warningf ignores the grpc warning logs.
func (l *Logger) Warningf(format string, args ...any) {
func (l *Logger) Warningf(_ string, _ ...any) {
// ignore builtin grpc warning
}
// Warningln ignores the grpc warning logs.
func (l *Logger) Warningln(args ...any) {
func (l *Logger) Warningln(_ ...any) {
// ignore builtin grpc warning
}

@ -169,25 +169,25 @@ type mockedStream struct {
ctx context.Context
}
func (m mockedStream) SetHeader(md metadata.MD) error {
func (m mockedStream) SetHeader(_ metadata.MD) error {
return nil
}
func (m mockedStream) SendHeader(md metadata.MD) error {
func (m mockedStream) SendHeader(_ metadata.MD) error {
return nil
}
func (m mockedStream) SetTrailer(md metadata.MD) {
func (m mockedStream) SetTrailer(_ metadata.MD) {
}
func (m mockedStream) Context() context.Context {
return m.ctx
}
func (m mockedStream) SendMsg(v any) error {
func (m mockedStream) SendMsg(_ any) error {
return nil
}
func (m mockedStream) RecvMsg(v any) error {
func (m mockedStream) RecvMsg(_ any) error {
return nil
}

@ -309,15 +309,15 @@ type mockedServerStream struct {
err error
}
func (m *mockedServerStream) SetHeader(md metadata.MD) error {
func (m *mockedServerStream) SetHeader(_ metadata.MD) error {
panic("implement me")
}
func (m *mockedServerStream) SendHeader(md metadata.MD) error {
func (m *mockedServerStream) SendHeader(_ metadata.MD) error {
panic("implement me")
}
func (m *mockedServerStream) SetTrailer(md metadata.MD) {
func (m *mockedServerStream) SetTrailer(_ metadata.MD) {
panic("implement me")
}
@ -329,10 +329,10 @@ func (m *mockedServerStream) Context() context.Context {
return m.ctx
}
func (m *mockedServerStream) SendMsg(v any) error {
func (m *mockedServerStream) SendMsg(_ any) error {
return m.err
}
func (m *mockedServerStream) RecvMsg(v any) error {
func (m *mockedServerStream) RecvMsg(_ any) error {
return m.err
}

@ -46,5 +46,5 @@ type nopResolver struct {
func (r *nopResolver) Close() {
}
func (r *nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
func (r *nopResolver) ResolveNow(_ resolver.ResolveNowOptions) {
}

@ -28,15 +28,15 @@ func (m *mockedClientConn) UpdateState(state resolver.State) error {
return m.err
}
func (m *mockedClientConn) ReportError(err error) {
func (m *mockedClientConn) ReportError(_ error) {
}
func (m *mockedClientConn) NewAddress(addresses []resolver.Address) {
func (m *mockedClientConn) NewAddress(_ []resolver.Address) {
}
func (m *mockedClientConn) NewServiceConfig(serviceConfig string) {
func (m *mockedClientConn) NewServiceConfig(_ string) {
}
func (m *mockedClientConn) ParseServiceConfig(serviceConfigJSON string) *serviceconfig.ParseResult {
func (m *mockedClientConn) ParseServiceConfig(_ string) *serviceconfig.ParseResult {
return nil
}

@ -1,8 +1,6 @@
package resolver
import (
"github.com/zeromicro/go-zero/zrpc/resolver/internal"
)
import "github.com/zeromicro/go-zero/zrpc/resolver/internal"
// Register registers schemes defined zrpc.
// Keep it in a separated package to let third party register manually.

Loading…
Cancel
Save