mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Embed noCopy struct into structs, which mustn't be copied
This should help `go vet` detecting invalid structs' copyings. See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
This commit is contained in:
@@ -39,6 +39,8 @@ type Args struct {
|
||||
args []argsKV
|
||||
bufKV argsKV
|
||||
buf []byte
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
type argsKV struct {
|
||||
|
||||
@@ -201,6 +201,8 @@ type Client struct {
|
||||
mLock sync.Mutex
|
||||
m map[string]*HostClient
|
||||
ms map[string]*HostClient
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// Get appends url contents to dst and returns it as body.
|
||||
@@ -511,6 +513,8 @@ type HostClient struct {
|
||||
|
||||
readerPool sync.Pool
|
||||
writerPool sync.Pool
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
type clientConn struct {
|
||||
|
||||
@@ -55,6 +55,8 @@ type Cookie struct {
|
||||
|
||||
bufKV argsKV
|
||||
buf []byte
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// CopyTo copies src cookie to c.
|
||||
|
||||
@@ -33,6 +33,8 @@ type ResponseHeader struct {
|
||||
bufKV argsKV
|
||||
|
||||
cookies []argsKV
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// RequestHeader represents HTTP request header.
|
||||
@@ -68,6 +70,8 @@ type RequestHeader struct {
|
||||
cookies []argsKV
|
||||
|
||||
rawHeaders []byte
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// SetContentRange sets 'Content-Range: bytes startPos-endPos/contentLength'
|
||||
|
||||
@@ -37,6 +37,8 @@ type Request struct {
|
||||
// Group bool members in order to reduce Request object size.
|
||||
parsedURI bool
|
||||
parsedPostArgs bool
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// Response represents HTTP response.
|
||||
@@ -62,6 +64,8 @@ type Response struct {
|
||||
// Response.Write() skips writing body if set to true.
|
||||
// Use it for writing HEAD responses.
|
||||
SkipBody bool
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// SetRequestURI sets RequestURI.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package fasthttp
|
||||
|
||||
// Embed this type into a struct, which mustn't be copied,
|
||||
// so `go vet` gives a warning if this struct is copied.
|
||||
//
|
||||
// See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
|
||||
type noCopy struct {}
|
||||
func (*noCopy) Lock() {}
|
||||
@@ -270,6 +270,8 @@ type Server struct {
|
||||
writerPool sync.Pool
|
||||
hijackConnPool sync.Pool
|
||||
bytePool sync.Pool
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// TimeoutHandler creates RequestHandler, which returns StatusRequestTimeout
|
||||
@@ -374,6 +376,8 @@ type RequestCtx struct {
|
||||
timeoutTimer *time.Timer
|
||||
|
||||
hijackHandler HijackHandler
|
||||
|
||||
noCopy
|
||||
}
|
||||
|
||||
// HijackHandler must process the hijacked connection c.
|
||||
|
||||
Reference in New Issue
Block a user