diff options
| author | Shulhan <ms@kilabit.info> | 2026-04-05 03:50:32 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-04-05 03:52:47 +0700 |
| commit | 778fd16011ec1d39c41b62372dc65f045183266e (patch) | |
| tree | a6f6f26930c00d8ac3dd7bfa1fb476bd65454833 /lib/bytes/bytes.go | |
| parent | 6fba7b9ce3bcaf4225e5ab774a15ef7364ed1420 (diff) | |
| download | pakakeh.go-778fd16011ec1d39c41b62372dc65f045183266e.tar.xz | |
all: apply go fix
Diffstat (limited to 'lib/bytes/bytes.go')
| -rw-r--r-- | lib/bytes/bytes.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/bytes/bytes.go b/lib/bytes/bytes.go index f0f55555..b79fd7cb 100644 --- a/lib/bytes/bytes.go +++ b/lib/bytes/bytes.go @@ -342,14 +342,8 @@ func SkipAfterToken(text, token []byte, startAt int, checkEsc bool) (int, bool) func SnippetByIndexes(s []byte, indexes []int, sniplen int) (snippets [][]byte) { var start, end int for _, idx := range indexes { - start = idx - sniplen - if start < 0 { - start = 0 - } - end = idx + sniplen - if end > len(s) { - end = len(s) - } + start = max(idx-sniplen, 0) + end = min(idx+sniplen, len(s)) snippets = append(snippets, s[start:end]) } |
