searxng-mcp-go/internal/searxng/truncate.go
opencode-agent[bot] 334c5da42b
refactor: extract answer types into internal/searxng/answer subpackage (#457)
* Created `internal/searxng/answer/` subpackage with 4 new files (answer.go, typed.go, deduplicate.go, truncate.go), updated response.go/deduplicate.go/truncate.go/types.go/constants.go to use thin wrappers, removed typedanswer.go, updated AGENTS.md/CONTEXT.md, and verified via build, test, lint gates.

Co-authored-by: xlionjuan <[email protected]>

* Merged main, added 4 test files, all gates pass.

Co-authored-by: xlionjuan <[email protected]>

* Added `t.Parallel()`, fixed error msgs, wsl lint.

Co-authored-by: xlionjuan <[email protected]>

---------

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: xlionjuan <[email protected]>
2026-07-06 00:01:32 +08:00

15 lines
619 B
Go

package searxng
import "searxng-mcp-go/internal/searxng/answer"
// TruncateRunes returns s truncated to at most maxRunes runes. The rune-safe
// implementation lives in the answer subpackage so the answer deduplication
// logic can use it without circular imports.
//
// This function is the single source of truth for rune-safe truncation. It is
// used both by the internal deduplication prefix match (searxng package) and
// by the CLI text formatter (root package) for content-length bounding per
// MaxContentRunes.
func TruncateRunes(s string, maxRunes int) string {
return answer.TruncateRunes(s, maxRunes)
}