summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorharryzcy <harry@harryzheng.com>2023-07-13 22:00:31 -0500
committerGitHub <noreply@github.com>2023-07-14 11:00:31 +0800
commitc5e187c389b35b9e080a3187b93a775a3c81e585 (patch)
tree7c65ee5aaf56b6f53a96742286d98119dba5b13b /modules
parentb81c01305714ceca818ccb91d19dada6469e658c (diff)
downloadgitea-c5e187c389b35b9e080a3187b93a775a3c81e585.tar.gz
gitea-c5e187c389b35b9e080a3187b93a775a3c81e585.zip
Upgrade go dependencies (#25819)
Diffstat (limited to 'modules')
-rw-r--r--modules/cache/cache_twoqueue.go12
-rw-r--r--modules/doctor/misc.go4
-rw-r--r--modules/highlight/highlight.go6
-rw-r--r--modules/markup/orgmode/orgmode.go2
-rw-r--r--modules/regexplru/regexplru.go6
5 files changed, 15 insertions, 15 deletions
diff --git a/modules/cache/cache_twoqueue.go b/modules/cache/cache_twoqueue.go
index 184db25573..f9de2563ec 100644
--- a/modules/cache/cache_twoqueue.go
+++ b/modules/cache/cache_twoqueue.go
@@ -11,13 +11,13 @@ import (
"code.gitea.io/gitea/modules/json"
mc "gitea.com/go-chi/cache"
- lru "github.com/hashicorp/golang-lru"
+ lru "github.com/hashicorp/golang-lru/v2"
)
// TwoQueueCache represents a LRU 2Q cache adapter implementation
type TwoQueueCache struct {
lock sync.Mutex
- cache *lru.TwoQueueCache
+ cache *lru.TwoQueueCache[string, any]
interval int
}
@@ -146,7 +146,7 @@ func (c *TwoQueueCache) Flush() error {
return nil
}
-func (c *TwoQueueCache) checkAndInvalidate(key any) {
+func (c *TwoQueueCache) checkAndInvalidate(key string) {
c.lock.Lock()
defer c.lock.Unlock()
cached, ok := c.cache.Peek(key)
@@ -155,7 +155,7 @@ func (c *TwoQueueCache) checkAndInvalidate(key any) {
}
item, ok := cached.(*MemoryItem)
if !ok || item.hasExpired() {
- c.cache.Remove(item)
+ c.cache.Remove(key)
}
}
@@ -187,9 +187,9 @@ func (c *TwoQueueCache) StartAndGC(opts mc.Options) error {
GhostRatio: lru.Default2QGhostEntries,
}
_ = json.Unmarshal([]byte(opts.AdapterConfig), cfg)
- c.cache, err = lru.New2QParams(cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
+ c.cache, err = lru.New2QParams[string, any](cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
} else {
- c.cache, err = lru.New2Q(size)
+ c.cache, err = lru.New2Q[string, any](size)
}
c.interval = opts.Interval
if c.interval > 0 {
diff --git a/modules/doctor/misc.go b/modules/doctor/misc.go
index f20b5b26d5..e01c3e109b 100644
--- a/modules/doctor/misc.go
+++ b/modules/doctor/misc.go
@@ -22,7 +22,7 @@ import (
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
- lru "github.com/hashicorp/golang-lru"
+ lru "github.com/hashicorp/golang-lru/v2"
"xorm.io/builder"
)
@@ -130,7 +130,7 @@ func checkEnablePushOptions(ctx context.Context, logger log.Logger, autofix bool
func checkDaemonExport(ctx context.Context, logger log.Logger, autofix bool) error {
numRepos := 0
numNeedUpdate := 0
- cache, err := lru.New(512)
+ cache, err := lru.New[int64, any](512)
if err != nil {
logger.Critical("Unable to create cache: %v", err)
return err
diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go
index fac682b8a8..a67217e864 100644
--- a/modules/highlight/highlight.go
+++ b/modules/highlight/highlight.go
@@ -23,7 +23,7 @@ import (
"github.com/alecthomas/chroma/v2/formatters/html"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/styles"
- lru "github.com/hashicorp/golang-lru"
+ lru "github.com/hashicorp/golang-lru/v2"
)
// don't index files larger than this many bytes for performance purposes
@@ -35,7 +35,7 @@ var (
once sync.Once
- cache *lru.TwoQueueCache
+ cache *lru.TwoQueueCache[string, any]
githubStyles = styles.Get("github")
)
@@ -46,7 +46,7 @@ func NewContext() {
highlightMapping = setting.GetHighlightMapping()
// The size 512 is simply a conservative rule of thumb
- c, err := lru.New2Q(512)
+ c, err := lru.New2Q[string, any](512)
if err != nil {
panic(fmt.Sprintf("failed to initialize LRU cache for highlighter: %s", err))
}
diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go
index 5a8485e571..a6dac12039 100644
--- a/modules/markup/orgmode/orgmode.go
+++ b/modules/markup/orgmode/orgmode.go
@@ -51,7 +51,7 @@ func (Renderer) SanitizerRules() []setting.MarkupSanitizerRule {
// Render renders orgmode rawbytes to HTML
func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error {
htmlWriter := org.NewHTMLWriter()
- htmlWriter.HighlightCodeBlock = func(source, lang string, inline bool) string {
+ htmlWriter.HighlightCodeBlock = func(source, lang string, inline bool, params map[string]string) string {
defer func() {
if err := recover(); err != nil {
log.Error("Panic in HighlightCodeBlock: %v\n%s", err, log.Stack(2))
diff --git a/modules/regexplru/regexplru.go b/modules/regexplru/regexplru.go
index dd3c5df82d..8f66dcf3f7 100644
--- a/modules/regexplru/regexplru.go
+++ b/modules/regexplru/regexplru.go
@@ -8,14 +8,14 @@ import (
"code.gitea.io/gitea/modules/log"
- lru "github.com/hashicorp/golang-lru"
+ lru "github.com/hashicorp/golang-lru/v2"
)
-var lruCache *lru.Cache
+var lruCache *lru.Cache[string, any]
func init() {
var err error
- lruCache, err = lru.New(1000)
+ lruCache, err = lru.New[string, any](1000)
if err != nil {
log.Fatal("failed to new LRU cache, err: %v", err)
}