path

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

CRC: crc-PathSyntax.md Spec: protocol.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Path

type Path struct {
	Segments     []Segment
	URLParams    url.Values // ?create=Type&prop=value parameters
	HasStandard  bool       // starts with @name
	StandardName string     // the @name without @
	Raw          string     // original path string
}

Path represents a parsed variable path.

func Parse

func Parse(pathStr string) (*Path, error)

Parse splits a path string into segments and parameters. Examples:

  • "name" -> property access
  • "father.name" -> property.property
  • "@customers.2.name" -> standard.index.property
  • "getName()" -> method call
  • ".." -> parent traversal
  • "path?create=Type" -> path with URL params

func (*Path) GetStandardVariable

func (p *Path) GetStandardVariable() (string, bool)

GetStandardVariable returns the @name (without @) if present.

func (*Path) GetURLParams

func (p *Path) GetURLParams() url.Values

GetURLParams returns the parsed URL parameters.

func (*Path) HasURLParams

func (p *Path) HasURLParams() bool

HasURLParams returns true if the path has URL parameters.

func (*Path) IsEmpty

func (p *Path) IsEmpty() bool

IsEmpty returns true if the path has no segments.

func (*Path) Len

func (p *Path) Len() int

Len returns the number of segments.

func (*Path) String

func (p *Path) String() string

String reconstructs the path string.

type Segment

type Segment struct {
	Type  SegmentType
	Value string // property name, method name, or @name
	Index int    // for SegmentIndex (1-based)
}

Segment represents a single path segment.

func (*Segment) GetArrayIndex

func (s *Segment) GetArrayIndex() (int, bool)

GetArrayIndex returns the 1-based index if this is an index segment.

func (*Segment) GetMethodCall

func (s *Segment) GetMethodCall() (string, bool)

GetMethodCall returns the method name if this is a method call segment.

func (*Segment) GetPropertyAccess

func (s *Segment) GetPropertyAccess() (string, bool)

GetPropertyAccess returns the property name if this is a simple property segment.

func (*Segment) IsParentTraversal

func (s *Segment) IsParentTraversal() bool

IsParentTraversal returns true if this is a parent traversal segment.

type SegmentType

type SegmentType int

SegmentType identifies the type of path segment.

const (
	SegmentProperty SegmentType = iota // Simple property: name
	SegmentIndex                       // Array index: 1, 2 (1-based)
	SegmentParent                      // Parent traversal: ..
	SegmentMethod                      // Method call: getName()
	SegmentStandard                    // Standard variable: @name
)

Jump to

Keyboard shortcuts

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