pathutil

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package pathutil provides path-related utilities for the ccg CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasPathPrefix

func HasPathPrefix(pathValue, prefix string) bool

HasPathPrefix reports whether path is the same as prefix or is nested under it. Both inputs are normalized to slash-separated clean relative paths. @intent compare include path scopes after normalization so callers can test path containment reliably.

func IsRegexPattern

func IsRegexPattern(pat string) bool

IsRegexPattern detects whether a pattern uses regex syntax rather than glob. Checks for anchors ($) and escape sequences (\.) that are regex-specific. @intent glob과 정규표현식 패턴을 구분해 적절한 매칭 엔진을 선택한다.

func LoadIncludePathsFromConfig

func LoadIncludePathsFromConfig(dir string) ([]string, error)

func MatchExcludes

func MatchExcludes(patterns []string, relPath string) bool

MatchExcludes reports whether relPath matches any of the given exclude patterns.

Pattern forms:

  • Path prefix: "vendor" or "internal/legacy" — excludes everything under that path.
  • Filename glob: "*.pb.go" — matches files by name anywhere in the tree. Patterns without "/" are applied against the base file name only.
  • Full-path glob: "internal/gen/*.go" — matched against the full slash-separated relPath.

relPath should be relative to the project root. OS-specific separators are normalized to forward slashes before matching. @intent 설정과 CLI에서 받은 제외 패턴을 상대 경로에 일관되게 적용한다. @domainRule 슬래시가 없는 패턴은 파일 basename에만 매칭한다.

func MatchIncludePaths

func MatchIncludePaths(relPath string, includePaths []string) bool

MatchIncludePaths reports whether relPath falls inside or is an ancestor of any configured include path. @intent let walkers prune directories that lie outside user-selected include scopes while still descending into ancestors.

func ShouldSkipDir

func ShouldSkipDir(name string) bool

ShouldSkipDir는 디렉토리 이름이 기본 제외 대상인지 반환한다. .git, vendor, node_modules, 그리고 "."으로 시작하는 숨김 디렉토리를 제외한다. @intent 공통적으로 분석 대상에서 빼야 하는 디렉터리를 빠르게 걸러낸다. @domainRule 숨김 디렉터리는 현재 디렉터리 표기 "."를 제외하고 모두 스킵한다.

func ValidateNamespacePath added in v0.10.0

func ValidateNamespacePath(namespace, filePath string) error

ValidateNamespacePath rejects namespace and file inputs that could escape the namespace root. @intent block path traversal against namespace-scoped filesystem reads. @domainRule namespace must be a single safe segment (no "/", "\\", "..", ".", or absolute path); filePath, when set, must be relative and free of parent-references. @param filePath relative path inside the namespace; "" validates the namespace name alone.

Types

This section is empty.

Jump to

Keyboard shortcuts

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