From 6e428cad5b7a8012fa44d4ca7b3bf7134f50ba7a Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Sun, 30 Mar 2025 15:14:46 +0200 Subject: [PATCH 1/2] Add Go 1.23 and 1.24 to the CI matrix --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6718a2e..e09280f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 From 9fb0b523c6283b91ff1f435ced0181bdb602b3e1 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Sun, 30 Mar 2025 17:19:46 +0200 Subject: [PATCH 2/2] Fix tests for Go >= 1.23 --- dumper_test.go | 24 +---------------- dumper_test_http.go | 24 +++++++++++++++++ dumper_test_http_122.go | 26 ++++++++++++++++++- dumper_test_http_123.go | 57 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 24 deletions(-) create mode 100644 dumper_test_http_123.go diff --git a/dumper_test.go b/dumper_test.go index 52bd7d1..a00139d 100644 --- a/dumper_test.go +++ b/dumper_test.go @@ -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) diff --git a/dumper_test_http.go b/dumper_test_http.go index d9cd303..5d73ef3 100644 --- a/dumper_test_http.go +++ b/dumper_test_http.go @@ -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 diff --git a/dumper_test_http_122.go b/dumper_test_http_122.go index 0afe2ab..7813451 100644 --- a/dumper_test_http_122.go +++ b/dumper_test_http_122.go @@ -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 diff --git a/dumper_test_http_123.go b/dumper_test_http_123.go new file mode 100644 index 0000000..9e89317 --- /dev/null +++ b/dumper_test_http_123.go @@ -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 +}`