1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Use Go 1.21 and update dependencies (#26878)

To make sure Gitea's next release's lifecycle could have active Golang
support.

And min/max are builtin now.
This commit is contained in:
wxiaoguang
2023-09-03 18:34:57 +08:00
committed by GitHub
parent 7477c93d62
commit fc039167d2
5 changed files with 81 additions and 79 deletions

View File

@@ -11,7 +11,6 @@ import (
"code.gitea.io/gitea/modules/highlight"
"code.gitea.io/gitea/modules/indexer/code/internal"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
)
// Result a search result to display
@@ -77,8 +76,8 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Res
if index < result.EndIndex &&
result.StartIndex < index+len(line) &&
result.StartIndex < result.EndIndex {
openActiveIndex := util.Max(result.StartIndex-index, 0)
closeActiveIndex := util.Min(result.EndIndex-index, len(line))
openActiveIndex := max(result.StartIndex-index, 0)
closeActiveIndex := min(result.EndIndex-index, len(line))
err = writeStrings(&formattedLinesBuffer,
line[:openActiveIndex],
line[openActiveIndex:closeActiveIndex],

View File

@@ -60,22 +60,6 @@ func OptionalBoolParse(s string) OptionalBool {
return OptionalBoolOf(b)
}
// Max max of two ints
func Max(a, b int) int {
if a < b {
return b
}
return a
}
// Min min of two ints
func Min(a, b int) int {
if a > b {
return b
}
return a
}
// IsEmptyString checks if the provided string is empty
func IsEmptyString(s string) bool {
return len(strings.TrimSpace(s)) == 0