Skip to content

Commit

Permalink
fix: 修复 go1.23 cookie entry 改动的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple committed Aug 19, 2024
1 parent 2b6fdcd commit 7c76948
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
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

0 comments on commit 7c76948

Please sign in to comment.