From 7c769484763e45e7badbbd931e74af7e2542c73b Mon Sep 17 00:00:00 2001 From: eatmoreapple Date: Mon, 19 Aug 2024 10:14:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20go1.23=20cookie=20e?= =?UTF-8?q?ntry=20=E6=94=B9=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cookie_entry_go1.23.go | 26 ++++++++++++++++++++++++++ cookie_entry_pre_go1.23.go | 27 +++++++++++++++++++++++++++ cookiejar.go | 21 --------------------- 3 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 cookie_entry_go1.23.go create mode 100644 cookie_entry_pre_go1.23.go diff --git a/cookie_entry_go1.23.go b/cookie_entry_go1.23.go new file mode 100644 index 0000000..4203a33 --- /dev/null +++ b/cookie_entry_go1.23.go @@ -0,0 +1,26 @@ +//go:build !(go1.20 || go1.21 || go1.22) + +package openwechat + +import "time" + +type entry struct { + Name string + Value string + Quoted bool + Domain string + Path string + SameSite string + Secure bool + HttpOnly bool + Persistent bool + HostOnly bool + Expires time.Time + Creation time.Time + LastAccess time.Time + + // seqNum is a sequence number so that Cookies returns cookies in a + // deterministic order, even for cookies that have equal Path length and + // equal Creation time. This simplifies testing. + seqNum uint64 // nolint:unused +} diff --git a/cookie_entry_pre_go1.23.go b/cookie_entry_pre_go1.23.go new file mode 100644 index 0000000..f64e6d9 --- /dev/null +++ b/cookie_entry_pre_go1.23.go @@ -0,0 +1,27 @@ +//go:build go1.20 || go1.21 || go1.22 + +// 小于go1.20的版本会在编译时报错 + +package openwechat + +import "time" + +type entry struct { + Name string + Value string + Domain string + Path string + SameSite string + Secure bool + HttpOnly bool + Persistent bool + HostOnly bool + Expires time.Time + Creation time.Time + LastAccess time.Time + + // seqNum is a sequence number so that Jar returns cookies in a + // deterministic order, even for cookies that have equal Path length and + // equal Creation time. This simplifies testing. + seqNum uint64 // nolint:unused +} diff --git a/cookiejar.go b/cookiejar.go index cb69b53..7cf799f 100644 --- a/cookiejar.go +++ b/cookiejar.go @@ -4,7 +4,6 @@ import ( "net/http" "net/http/cookiejar" "sync" - "time" "unsafe" ) @@ -39,26 +38,6 @@ func NewJar() *Jar { return fromCookieJar(jar) } -type entry struct { - Name string - Value string - Domain string - Path string - SameSite string - Secure bool - HttpOnly bool - Persistent bool - HostOnly bool - Expires time.Time - Creation time.Time - LastAccess time.Time - - // seqNum is a sequence number so that Jar returns cookies in a - // deterministic order, even for cookies that have equal Path length and - // equal Creation time. This simplifies testing. - seqNum uint64 // nolint:unused -} - // CookieGroup is a group of cookies type CookieGroup []*http.Cookie