Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 go1.23 cookie entry 改动的问题 #525

Merged
merged 1 commit into from
Aug 19, 2024
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
26 changes: 26 additions & 0 deletions cookie_entry_go1.23.go
Original file line number Diff line number Diff line change
@@ -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
}
27 changes: 27 additions & 0 deletions cookie_entry_pre_go1.23.go
Original file line number Diff line number Diff line change
@@ -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
}
21 changes: 0 additions & 21 deletions cookiejar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"net/http"
"net/http/cookiejar"
"sync"
"time"
"unsafe"
)

Expand Down Expand Up @@ -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

Expand Down
Loading