Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
- '1.20'
- '1.21'
- '1.22'
- '1.23'
- '1.24'
name: Go ${{ matrix.go }} test
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 1 addition & 23 deletions dumper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,29 +398,7 @@ func (ts *DumperSuite) TestPrivateFields(c *C) {
}`)

UnregisterCustomDumper(http.Request{})
c.Assert(Sdump(http.Request{}), DumpEquals, `http.Request{
Method: "",
URL: nil, // &url.URL
Proto: "",
ProtoMajor: 0,
ProtoMinor: 0,
Header: nil, // map[string][]string
Body: nil,
GetBody: nil, // func() (io.ReadCloser, error)
ContentLength: 0, // int64
TransferEncoding: nil, // []string
Close: false,
Host: "",
Form: nil, // map[string][]string
PostForm: nil, // map[string][]string
MultipartForm: nil, // &multipart.Form
Trailer: nil, // map[string][]string
RemoteAddr: "",
RequestURI: "",
TLS: nil, // &tls.ConnectionState
Cancel: nil, // <-chan struct {}
Response: nil, // &http.Response
}`)
c.Assert(Sdump(http.Request{}), DumpEquals, httpRequestExceptedDump)

RegisterCustomDumper(http.Request{}, DumpStructWithPrivateFields)
c.Assert(Sdump(http.Request{}), DumpEquals, httpRequestExceptedDumpWithPrivateFields)
Expand Down
24 changes: 24 additions & 0 deletions dumper_test_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

package dumper

const httpRequestExceptedDump = `http.Request{
Method: "",
URL: nil, // &url.URL
Proto: "",
ProtoMajor: 0,
ProtoMinor: 0,
Header: nil, // map[string][]string
Body: nil,
GetBody: nil, // func() (io.ReadCloser, error)
ContentLength: 0, // int64
TransferEncoding: nil, // []string
Close: false,
Host: "",
Form: nil, // map[string][]string
PostForm: nil, // map[string][]string
MultipartForm: nil, // &multipart.Form
Trailer: nil, // map[string][]string
RemoteAddr: "",
RequestURI: "",
TLS: nil, // &tls.ConnectionState
Cancel: nil, // <-chan struct {}
Response: nil, // &http.Response
}`

const httpRequestExceptedDumpWithPrivateFields = `http.Request{
Method: "",
URL: nil, // &url.URL
Expand Down
26 changes: 25 additions & 1 deletion dumper_test_http_122.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
//go:build go1.22
//go:build go1.22 && !go1.23

package dumper

const httpRequestExceptedDump = `http.Request{
Method: "",
URL: nil, // &url.URL
Proto: "",
ProtoMajor: 0,
ProtoMinor: 0,
Header: nil, // map[string][]string
Body: nil,
GetBody: nil, // func() (io.ReadCloser, error)
ContentLength: 0, // int64
TransferEncoding: nil, // []string
Close: false,
Host: "",
Form: nil, // map[string][]string
PostForm: nil, // map[string][]string
MultipartForm: nil, // &multipart.Form
Trailer: nil, // map[string][]string
RemoteAddr: "",
RequestURI: "",
TLS: nil, // &tls.ConnectionState
Cancel: nil, // <-chan struct {}
Response: nil, // &http.Response
}`

const httpRequestExceptedDumpWithPrivateFields = `http.Request{
Method: "",
URL: nil, // &url.URL
Expand Down
57 changes: 57 additions & 0 deletions dumper_test_http_123.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//go:build go1.23

package dumper

const httpRequestExceptedDump = `http.Request{
Method: "",
URL: nil, // &url.URL
Proto: "",
ProtoMajor: 0,
ProtoMinor: 0,
Header: nil, // map[string][]string
Body: nil,
GetBody: nil, // func() (io.ReadCloser, error)
ContentLength: 0, // int64
TransferEncoding: nil, // []string
Close: false,
Host: "",
Form: nil, // map[string][]string
PostForm: nil, // map[string][]string
MultipartForm: nil, // &multipart.Form
Trailer: nil, // map[string][]string
RemoteAddr: "",
RequestURI: "",
TLS: nil, // &tls.ConnectionState
Cancel: nil, // <-chan struct {}
Response: nil, // &http.Response
Pattern: "",
}`

const httpRequestExceptedDumpWithPrivateFields = `http.Request{
Method: "",
URL: nil, // &url.URL
Proto: "",
ProtoMajor: 0,
ProtoMinor: 0,
Header: nil, // map[string][]string
Body: nil,
GetBody: nil, // func() (io.ReadCloser, error)
ContentLength: 0, // int64
TransferEncoding: nil, // []string
Close: false,
Host: "",
Form: nil, // map[string][]string
PostForm: nil, // map[string][]string
MultipartForm: nil, // &multipart.Form
Trailer: nil, // map[string][]string
RemoteAddr: "",
RequestURI: "",
TLS: nil, // &tls.ConnectionState
Cancel: nil, // <-chan struct {}
Response: nil, // &http.Response
Pattern: "",
ctx: nil,
pat: nil, // &http.pattern
matches: nil, // []string
otherValues: nil, // map[string]string
}`