inspect

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package inspect provides general-purpose string predicates and position scanners used across ctx packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(content, substr string) (bool, int)

Contains reports whether content contains the substring and returns its index.

Parameters:

  • content: String to search in
  • substr: Substring to find

Returns:

  • bool: True if substr is found
  • int: Index of substr (-1 if not found)

func ContainsEndComment

func ContainsEndComment(content string) (bool, int)

ContainsEndComment reports whether content contains a comment close marker.

Parameters:

  • content: String to search in

Returns:

  • bool: True if comment close marker is found
  • int: Index of marker (-1 if not found)

func ContainsNewLine

func ContainsNewLine(content string) (bool, int)

ContainsNewLine reports whether content contains a newline and returns its index.

Parameters:

  • content: String to search in

Returns:

  • bool: True if a newline is found
  • int: Index of newline (-1 if not found)

func EndsWithNewline

func EndsWithNewline(s string) bool

EndsWithNewline reports whether s ends with a newline (CRLF or LF).

Parameters:

  • s: String to check

Returns:

  • bool: True if s ends with a newline

func FindNewline

func FindNewline(s string) int

FindNewline returns the index of the first newline (CRLF or LF) in s.

Parameters:

  • s: String to search

Returns:

  • int: Index of the first newline (-1 if not found)

func SkipNewline

func SkipNewline(s string, pos int) int

SkipNewline advances pos past a newline (CRLF or LF) if present.

Parameters:

  • s: String to scan
  • pos: Current position in s

Returns:

  • int: New position (unchanged if no newline at pos)

func SkipWhitespace

func SkipWhitespace(s string, pos int) int

SkipWhitespace advances pos past any whitespace (space, tab, newline).

Parameters:

  • s: String to scan
  • pos: Current position in s

Returns:

  • int: New position after skipping whitespace

func StartsWithCtxMarker

func StartsWithCtxMarker(s string) bool

StartsWithCtxMarker reports whether s starts with a ctx marker comment.

Parameters:

  • s: String to check

Returns:

  • bool: True if s starts with CtxMarkerStart or CtxMarkerEnd

Types

This section is empty.

Jump to

Keyboard shortcuts

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