stringutil

package
v0.61.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package stringutil provides common string utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseRepeatedErrorWrappers added in v0.61.0

func CollapseRepeatedErrorWrappers(s string) string

CollapseRepeatedErrorWrappers removes consecutive duplicate wrapper segments from a wrapped Go error chain rendered as "outer: middle: inner".

Third-party transports sometimes wrap an error with the same message twice (mcp-go's streamable_http wraps a send failure as "failed to send request" at two nesting levels), so a user-facing error reads

transport error: failed to send request: failed to send request: Post "…"

": " is not only a Go wrapping boundary — it also occurs inside quoted URLs, JSON, captured stderr and validation text. Deleting an adjacent repeat there would silently destroy real content. So a segment is dropped ONLY when all of the following hold:

  • it is byte-identical to the segment immediately before it, and
  • it is not the last segment (the root cause is never merged away), and
  • it looks like a wrapper phrase rather than a payload — see isWrapperPhrase.

A chain with no adjacent wrapper repeats is returned unchanged.

func ContainsIgnoreCase

func ContainsIgnoreCase(s, substr string) bool

ContainsIgnoreCase checks if s contains substr, ignoring case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL