8000 Upgrade dependencies by Danielius1922 · Pull Request #606 · plgd-dev/go-coap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Upgrade dependencies #606

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- run: go version

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the action version and approve the upgrade.

The upgrade from golangci-lint-action@v6 to v8 is a good practice to stay current with the latest features and security updates.


🌐 Web query:

What is the latest stable version of golangci/golangci-lint-action on GitHub?

💡 Result:

The latest stable version of the golangci/golangci-lint-action GitHub Action is v6.2.0, released on May 28, 2025. (newreleases.io)

This release introduces support for Linux ARM64 in public preview and updates the build tag syntax.

For detailed information on this release, you can refer to the release notes. (newreleases.io)

To use this version in your GitHub Actions workflow, specify it as follows:

- name: Golangci-lint
  uses: golangci/golangci-lint-action@v6.2.0
  with:
    version: v1.60

Ensure that the version input matches the desired version of golangci-lint you intend to use.

Citations:


Invalid golangci-lint Action version
The workflow is currently using golangci/golangci-lint-action@v8, but no v8 release exists. The latest stable release is v6.2.0 (released May 28, 2025).

Please update the workflow:

• File: .github/workflows/golangci-lint.yml
Line: 28

Suggested change:

- uses: golangci/golangci-lint-action@v8
+ uses: golangci/golangci-lint-action@v6.2.0
  with:
    version: v1.60
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: golangci/golangci-lint-action@v8
uses: golangci/golangci-lint-action@v6.2.0
with:
version: v1.60
🤖 Prompt for AI Agents
In .github/workflows/golangci-lint.yml at line 28, the golangci-lint GitHub
Action version is incorrectly set to v8, which does not exist. Update the action
version to the latest stable release v6.2.0 by changing the uses line to
golangci/golangci-lint-action@v6.2.0. Also, ensure the 'version' input parameter
matches the golangci-lint tool version you want to use.

with:
version: latest
args: --timeout=5m
126 changes: 65 additions & 61 deletions .golangci.yml
8000 10000
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
linters-settings:
gocyclo:
min-complexity: 15
govet:
enable:
- nilness
- shadow

version: "2"
run:
go: "1.20"
# issues:
# fix: true
linters:
enable:
- asasalint # Check for pass []any as any in variadic func(...any)
Expand All @@ -22,26 +19,21 @@ linters:
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
- errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`.
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exportloopref # checks for pointers to enclosing loop variables
# - exportloopref # checks for pointers to enclosing loop variables
- forcetypeassert # finds forced type assertions
- gci # Gci control golang package import order and make it always deterministic.
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid.
- gocognit # Computes and checks the cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # The most opinionated Go source code linter
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godox # Tool for detection of FIXME, TODO and other comment keywords
# - goerr113 # Golang linter to check the errors handling expressions
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
- goheader # Checks is file header matches to pattern
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
# - gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
- goprintffuncname # Checks that printf-like functions are named with `f` at the end
- gosec # Inspects source code for security problems
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- grouper # An analyzer to analyze expression groups
- importas # Enforces consistent import aliases
Expand All @@ -66,12 +58,9 @@ linters:
- sloglint # Ensure consistent code style when using log/slog
- spancheck # Checks for mistakes with OpenTelemetry/Census spans
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- stylecheck # Stylecheck is a replacement for golint
- tagliatelle # Checks the struct tags.
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- testifylint # Checks usage of github.com/stretchr/testify.
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unconvert # Remove unnecessary type conversions
- unparam # Reports unused function parameters
- unused # Checks Go code for unused constants, variables, functions and types
Expand All @@ -90,7 +79,6 @@ linters:
- gochecknoglobals # Checks that no globals are present in Go code
- gochecknoinits # Checks that no init functions are present in Go code
- godot # Check if comments end in a period
- gomnd # An analyzer to detect magic numbers.
- inamedparam # Reports interfaces with unnamed method parameters.
- interfacebloat # A linter that checks the number of methods inside an interface
- ireturn # Accept Interfaces, Return Concrete Types
Expand All @@ -110,45 +98,61 @@ linters:
- varnamelen # checks that the length of a variable's name matches its scope
- wrapcheck # Checks that errors returned from external packages are wrapped
- wsl # Whitespace Linter - Forces you to use empty lines!

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- dupword
- forcetypeassert
- gosec
- gocyclo
- gocognit
- nakedret

- path: ^test/.*\.go
linters:
- dupl
- forcetypeassert
- gosec
- gocyclo
- gocognit

- path: example_test\.go
text: "exitAfterDefer"
linters:
- gocritic

- path: .*/client/conn.go
linters:
- godox

- path: .*.go
text: "replace with standard maps package"
linters:
- godox

# # Fix found issues (if it's supported by the linter).
# fix: true

run:
go: "1.20"
settings:
gocyclo:
min-complexity: 15
govet:
enable:
- nilness
- shadow
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
# Log a warning if an exclusion rule is unused.
# Default: false
warn-unused: true
rules:
- linters:
- dupl
- dupword
- forcetypeassert
- gocognit
- gocyclo
- gosec
- nakedret
path: _test\.go
- linters:
- dupl
- forcetypeassert
- gocognit
- gocyclo
- gosec
path: ^test/.*\.go
- linters:
- gocritic
path: example_test\.go
text: exitAfterDefer
- linters:
- godox
path: .*/client/conn.go
- linters:
- godox
path: .*.go
text: replace with standard maps package
# Which file paths to exclude: they will be analyzed, but issues from them won't be reported.
6D47 # "/" will be replaced by the current OS file path separator to properly work on Windows.
# Default: []
paths:
- examples
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
6 changes: 2 additions & 4 deletions examples/dtls/cid/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/plgd-dev/go-coap/v3/mux"
"github.com/plgd-dev/go-coap/v3/options"
udpClient "github.com/plgd-dev/go-coap/v3/udp/client"
"go.uber.org/atomic"
)

func handleA(w mux.ResponseWriter, r *mux.Message) {
Expand Down Expand Up @@ -45,8 +44,7 @@ func handleB(w mux.ResponseWriter, r *mux.Message) {
// NOTE: this utility is for example purposes only. Context should be handled
// properly in meaningful scenarios.
type wrappedListener struct {
l net.Listener
closed atomic.Bool
l net.Listener
}

// AcceptWithContext disregards the passed context and calls the underlying
Expand Down Expand Up @@ -87,6 +85,6 @@ func main() {
if err != nil {
log.Fatalf("Error establishing DTLS listener: %v", err)
}
s := server.New(options.WithMux(m), options.WithInactivityMonitor(10*time.Second, func(cc *udpClient.Conn) {}))
s := server.New(options.WithMux(m), options.WithInactivityMonitor(10*time.Second, func(*udpClient.Conn) {}))
s.Serve(wrapListener(l))
}
1 change: 0 additions & 1 deletion examples/dtls/pki/cert_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func LoadCertPool(caBytes []byte) (*x509.CertPool, error) {
for _, certBytes := range rootCertificate.Certificate {
cert, err := x509.ParseCertificate(certBytes)
if err != nil {
certPool = nil
return nil, err
}
certPool.AddCert(cert)
Expand Down
7 changes: 3 additions & 4 deletions examples/mcast/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,14 @@ func main() {
err = req.SetupGet("/oic/res", token) /* msg.Option{
ID: msg.URIQuery,
Value: []byte("rt=oic.wk.d"),
}*/
if err != nil {
}*/if err != nil {
panic(fmt.Errorf("cannot create discover request: %w", err))
}
req.SetMessageID(message.GetMID())
req.SetType(message.NonConfirmable)
defer messagePool.ReleaseMessage(req)

err = s.DiscoveryRequest(req, "224.0.1.187:5683", func(cc *client.Conn, resp *pool.Message) {
err = s.DiscoveryRequest(req, "224.0.1.187:5683", func(cc *client.Conn, _ *pool.Message) {
_, loaded := duplicit.LoadOrStore(cc.RemoteAddr().String(), true)
if loaded {
atomic.AddUint32(&numDuplicit, 1)
Expand All @@ -125,7 +124,7 @@ func main() {

previousNum := uint32(0)
if previousDuplicit != nil {
previousDuplicit.Range(func(key, value interface{}) bool {
previousDuplicit.Range(func(key, _ interface{}) bool {
_, ok := duplicit.Load(key)
if !ok {
fmt.Printf("device %v is lost\n", key)
Expand Down
2 changes: 1 addition & 1 deletion examples/mcast/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {

for i := range ifaces {
iface := ifaces[i]
err := l.JoinGroup(&iface, a)
err = l.JoinGroup(&iface, a)
if err != nil {
log.Printf("cannot JoinGroup(%v, %v): %v", iface, a, err)
}
Expand Down
11 changes: 5 additions & 6 deletions examples/options/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (

piondtls "github.com/pion/dtls/v3"
coap "github.com/plgd-dev/go-coap/v3"
dtlsServer "github.com/plgd-dev/go-coap/v3/dtls/server"
"github.com/plgd-dev/go-coap/v3/message"
"github.com/plgd-dev/go-coap/v3/message/codes"
"github.com/plgd-dev/go-coap/v3/mux"
"github.com/plgd-dev/go-coap/v3/options"

dtlsServer "github.com/plgd-dev/go-coap/v3/dtls/server"
tcpServer "github.com/plgd-dev/go-coap/v3/tcp/server"
udpClient "github.com/plgd-dev/go-coap/v3/udp/client"
)
Expand Down Expand Up @@ -50,11 +49,11 @@ func handleOnNewConn(cc *udpClient.Conn) {
if !ok {
log.Fatalf("cannot get connection state")
}
clientId := state.IdentityHint
cc.SetContextValue("clientId", clientId)
clientID := state.IdentityHint
cc.SetContextValue("clientId", clientID)
cc.AddOnClose(func() {
clientId := state.IdentityHint
log.Printf("closed connection clientId: %s", clientId)
clientID := state.IdentityHint
log.Printf("closed connection clientId: %s", clientID)
})
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func loggingMiddleware(next mux.Handler) mux.Handler {
})
}

func handleA(w mux.ResponseWriter, r *mux.Message) {
func handleA(w mux.ResponseWriter, _ *mux.Message) {
err := w.SetResponse(codes.Content, message.TextPlain, bytes.NewReader([]byte("hello world")))
if err != nil {
log.Printf("cannot set response: %v", err)
Expand Down
23 changes: 16 additions & 7 deletions go.mod
CEB7
Original file line numberDiff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ go 1.20

require (
github.com/dsnet/golib/memfile v1.0.0
github.com/pion/dtls/v3 v3.0.2
github.com/pion/dtls/v3 v3.0.6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify security vulnerabilities in updated dependencies.

Please verify that the updated dependency versions don't contain known security vulnerabilities.

Also applies to: 10-12, 17-17, 20-21


🌐 Web query:

Are there any known security vulnerabilities in github.com/pion/dtls/v3 v3.0.6, golang.org/x/net v0.35.0, golang.org/x/crypto v0.33.0, or golang.org/x/sys v0.30.0?

💡 Result:

Security Vulnerabilities in Specific Go Packages and Versions

1. github.com/pion/dtls/v3 v3.0.6

  • There are no publicly documented vulnerabilities specific to v3.0.6 as of now in the GitHub security advisories or recent release notes[1][2][3].
  • Previous research uncovered vulnerabilities in older versions, including a padding oracle vulnerability and potential issues with processing unencrypted data post-handshake[5][10]. However, these are not confirmed in the v3.0.6 or v3.x series, and the most prominent CVE (CVE-2022-29189) was fixed in v2.1.4[4].
  • The Pion team aspires to a formal security review but does not list any current open vulnerabilities for v3.0.6[1][3].

Summary: No known, unpatched vulnerabilities in v3.0.6.


2. golang.org/x/net v0.35.0

  • Multiple vulnerabilities have been found in versions below 0.38.0:
    • CVE-2024-45338: Denial of Service due to non-linear parsing in the html package, impacting v0.35.0[7].
    • CVE-2025-22872: Cross-site scripting (XSS) vulnerability due to the tokenizer incorrectly treating tags as self-closing in certain contexts, also affecting v0.35.0[9].

Summary: v0.35.0 is affected by at least two publicly disclosed vulnerabilities. Upgrade is recommended.


3. golang.org/x/crypto v0.33.0

  • CVE-2025-22869: SSH servers using the package are vulnerable to a Denial of Service (DoS) attack via slow or incomplete key exchange. This impacts all versions prior to v0.35.0, including v0.33.0[6].

Summary: v0.33.0 is vulnerable to DoS attacks and should be upgraded.


4. golang.org/x/sys v0.30.0

  • No reported or documented vulnerabilities specific to v0.30.0 or close releases were found in search results[8].

Summary: No known vulnerabilities in v0.30.0 as of now.


Summary Table

Package Version Vulnerabilities Present? Details / References
github.com/pion/dtls/v3 v3.0.6 No known current vulnerabilities [1][2][3]
golang.org/x/net v0.35.0 Yes CVE-2024-45338[7], CVE-2025-22872[9]
golang.org/x/crypto v0.33.0 Yes CVE-2025-22869[6]
golang.org/x/sys v0.30.0 No [8]

Recommendations

  • Upgrade both golang.org/x/net and golang.org/x/crypto to the latest versions available to address well-documented security flaws.
  • Monitor Pion DTLS for future advisories, but v3.0.6 has no open, critical CVEs at this time.
  • No immediate action needed for golang.org/x/sys v0.30.0, but keep it updated as part of normal maintenance.

If your project is security sensitive, consider a full security review and always track dependency advisories for updates.

Citations:


Address security vulnerabilities in Go dependencies

The following versions in go.mod are affected by known CVEs and should be upgraded:

  • go.mod (lines 10–12): golang.org/x/net v0.35.0
    CVE-2024-45338 (DoS via non-linear HTML parsing)
    CVE-2025-22872 (XSS in HTML tokenizer)
    → Upgrade to ≥ v0.38.0

  • go.mod (line 17): golang.org/x/crypto v0.33.0
    CVE-2025-22869 (SSH DoS via slow/incomplete key exchange)
    → Upgrade to ≥ v0.35.0

No action needed for:

  • github.com/pion/dtls/v3 v3.0.6 (no known vulnerabilities)
  • golang.org/x/sys v0.30.0 (no known vulnerabilities)

Please bump these two dependencies in go.mod and verify there are no downstream breaking changes.

🤖 Prompt for AI Agents
In go.mod around lines 10 to 12 and line 17, the dependencies golang.org/x/net
v0.35.0 and golang.org/x/crypto v0.33.0 have known security vulnerabilities.
Upgrade golang.org/x/net to version 0.38.0 or higher and golang.org/x/crypto to
version 0.35.0 or higher to address these CVEs. Confirm that these upgrades do
not introduce breaking changes in downstream code.

github.com/stretchr/testify v1.9.0
go.uber.org/atomic v1.11.0
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
golang.org/x/net v0.28.0
golang.org/x/sync v0.8.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
golang.org/x/net v0.35.0
golang.org/x/sync v0.11.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/logging v0.2.3 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/sys v0.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// pin versions to keep go1.20 support
replace (
golang.org/x/crypto => golang.org/x/crypto v0.33.0
golang.org/x/exp => golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
golang.org/x/net => golang.org/x/net v0.35.0
golang.org/x/sync => golang.org/x/sync v0.11.0
golang.org/x/sys => golang.org/x/sys v0.30.0
)
Comment on lines +25 to +32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Question the necessity of the replace directive.

The replace directive pins the exact same versions that are already specified in the require section. This appears redundant unless there are specific transitive dependency conflicts.

Please verify if this replace directive is actually necessary by checking if any transitive dependencies pull in incompatible versions:


🏁 Script executed:

#!/bin/bash
# Description: Check if replace directives are necessary by examining transitive dependencies

echo "Checking for version conflicts in transitive dependencies..."

# Check what versions would be selected without replace directives
go mod graph | grep -E "(golang.org/x/crypto|golang.org/x/exp|golang.org/x/net|golang.org/x/sync|golang.org/x/sys)" | head -20

echo -e "\nChecking go mod why for each replaced module..."
go mod why golang.org/x/crypto
go mod why golang.org/x/exp  
go mod why golang.org/x/net
go mod why golang.org/x/sync
go mod why golang.org/x/sys

Length of output: 2968


Drop redundant replace directives in go.mod

All of the golang.org/x/{crypto,exp,net,sync,sys} modules are only pulled in indirectly, and the Go resolver already selects the same highest versions you’ve pinned (no transitive dependency is requesting a newer release). You can safely remove the entire replace block (lines 25–32) to simplify your module:

  • go.mod: delete lines 25–32 (the replace (…) section)

If you still intend to proactively guard against future upgrades that might bump these beyond Go 1.20, consider documenting that goal instead of mirroring the current require versions here.

🤖 Prompt for AI Agents
In go.mod around lines 25 to 32, the replace directive pins versions of
golang.org/x/{crypto,exp,net,sync,sys} that are identical to those already
specified in the require section, making it redundant. Remove the entire replace
block from lines 25 to 32 to simplify the module, as the Go module resolver
already selects these versions correctly without conflicts. If you want to guard
against future upgrades, add a comment instead of duplicating the version pins.

28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dsnet/golib/memfile v1.0.0 h1:J9pUspY2bDCbF9o+YGwcf3uG6MdyITfh/Fk3/CaEiFs=
github.com/dsnet/golib/memfile v1.0.0/go.mod h1:tXGNW9q3RwvWt1VV2qrRKlSSz0npnh12yftCSCy2T64=
github.com/pion/dtls/v3 v3.0.2 h1:425DEeJ/jfuTTghhUDW0GtYZYIwwMtnKKJNMcWccTX0=
github.com/pion/dtls/v3 v3.0.2/go.mod h1:dfIXcFkKoujDQ+jtd8M6RgqKK3DuaUilm3YatAbGp5k=
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -14,16 +14,16 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
4 changes: 2 additions & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewCache[K comparable, D any]() *Cache[K, D] {

func (c *Cache[K, D]) LoadOrStore(key K, e *Element[D]) (actual *Element[D], loaded bool) {
now := time.Now()
c.Map.ReplaceWithFunc(key, func(oldValue *Element[D], oldLoaded bool) (newValue *Element[D], deleteValue bool) {
c.ReplaceWithFunc(key, func(oldValue *Element[D], oldLoaded bool) (newValue *Element[D], deleteValue bool) {
if oldLoaded {
if !oldValue.IsExpired(now) {
actual = oldValue
Expand All @@ -77,7 +77,7 @@ func (c *Cache[K, D]) Load(key K) (actual *Element[D]) {
func (c *Cache[K, D]) CheckEx 5AC0 pirations(now time.Time) {
c.Range(func(key K, value *Element[D]) bool {
if value.IsExpired(now) {
c.Map.Delete(key)
c.Delete(key)
value.onExpire(value.Data())
}
return true
Expand Down
Loading
0