Fix govet+staticcheck issues (#20263)

This is better: https://github.com/golang/go/issues/60529
This commit is contained in:
Klaus Post
2024-08-14 10:11:51 -07:00
committed by GitHub
parent 51b1f41518
commit 3ffeabdfcb
16 changed files with 49 additions and 37 deletions

View File

@@ -210,7 +210,7 @@ const (
func init() {
// Static check if we exceed 255 handler ids.
// Extend the type to uint16 when hit.
if handlerLast > 255 {
if uint32(handlerLast) > 255 {
panic(fmt.Sprintf("out of handler IDs. %d > %d", handlerLast, 255))
}
}
@@ -435,6 +435,7 @@ func recycleFunc[RT RoundTripper](newRT func() RT) (newFn func() RT, recycle fun
return func() RT { return pool.Get().(RT) },
func(r RT) {
if r != rZero {
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE!
pool.Put(r)
}
}
@@ -601,15 +602,18 @@ func GetCaller(ctx context.Context) *RemoteClient {
// GetSubroute returns caller information from contexts provided to handlers.
func GetSubroute(ctx context.Context) string {
//nolint:staticcheck // SA1029 Staticcheck is drunk.
val, _ := ctx.Value(ctxSubrouteKey{}).(string)
return val
}
func setCaller(ctx context.Context, cl *RemoteClient) context.Context {
//nolint:staticcheck // SA1029 Staticcheck is drunk.
return context.WithValue(ctx, ctxCallerKey{}, cl)
}
func setSubroute(ctx context.Context, s string) context.Context {
//nolint:staticcheck // SA1029 Staticcheck is drunk.
return context.WithValue(ctx, ctxSubrouteKey{}, s)
}
@@ -681,6 +685,7 @@ func (h *StreamTypeHandler[Payload, Req, Resp]) NewRequest() Req {
// These should be returned by the handler.
func (h *StreamTypeHandler[Payload, Req, Resp]) PutRequest(r Req) {
if r != h.nilReq {
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE! (and always a pointer)
h.reqPool.Put(r)
}
}
@@ -689,6 +694,7 @@ func (h *StreamTypeHandler[Payload, Req, Resp]) PutRequest(r Req) {
// These should be returned by the caller.
func (h *StreamTypeHandler[Payload, Req, Resp]) PutResponse(r Resp) {
if r != h.nilResp {
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE! (and always a pointer)
h.respPool.Put(r)
}
}

View File

@@ -598,6 +598,7 @@ func (p *ArrayOf[T]) newA(sz uint32) []T {
func (p *ArrayOf[T]) putA(v []T) {
var zero T // nil
for i, t := range v {
//nolint:staticcheck // SA6002 IT IS A GENERIC VALUE!
p.ePool.Put(t)
v[i] = zero
}