Help us shape the future of Go! Take the 2026 Go Developer Survey

uri

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package uri implements the Synapse repo:// identifier grammar (SYN-11).

Index

Constants

View Source
const (
	Scheme = "repo"

	// PropKey is the node property holding the canonical repo:// URI.
	PropKey = "repo_uri"
)
View Source
const (
	KindFile      = "file"
	KindPackage   = "package"
	KindModule    = "module"
	KindFunc      = "func"
	KindMethod    = "method"
	KindType      = "type"
	KindImport    = "import"
	KindSymbol    = "symbol"
	KindOperation = "operation"
	KindSchema    = "schema"
	KindField     = "field"
	KindService   = "service"
	KindDoc       = "doc"
	KindHeading   = "heading"
)

Kind tokens as they appear in the URI fragment.

Variables

View Source
var (
	ErrInvalid  = errors.New("uri: invalid repo:// URI")
	ErrConflict = errors.New("uri: conflict")
)

Functions

func Assign

func Assign(repo, filePath, nodeKind, name, legacyID string) (canonical string, ok bool, err error)

Assign builds a URI for a node from repo, path, and Node.Kind / name / props. Global unresolved symbols (kind symbol with empty path or id prefix symbol: without path) skip.

func Build

func Build(repo, filePath, kindToken, symbol string) (string, error)

Build constructs a canonical repo:// URI string.

func FromLegacy

func FromLegacy(repo, legacyID string) (canonical string, ok bool, err error)

FromLegacy builds a repo:// URI from a Phase-1 node id and repo name. Global symbol ids return ok=false without error (no URI assigned).

func KindToken

func KindToken(nodeKind string) (string, error)

KindToken maps a graph Node.Kind string to the URI fragment token.

func NodeKind

func NodeKind(kindToken string) (string, error)

NodeKind maps a URI kind token back to Node.Kind.

func Normalize

func Normalize(raw string) (string, error)

Normalize returns the canonical string form of raw.

func NormalizePath

func NormalizePath(p string) (string, error)

NormalizePath makes a repo-relative slash path (no leading/trailing slash except empty).

func NormalizeRepo

func NormalizeRepo(repo string) (string, error)

NormalizeRepo validates and lowercases? — keep case as given but trim. Repo names are case-sensitive as provided; only charset is restricted.

func RewriteRepo

func RewriteRepo(raw, from, to string) (string, error)

RewriteRepo remaps the repo segment of a repo:// URI from `from` to `to`. Non-repo:// strings are returned unchanged. A repo:// value that fails to parse is an error.

func Validate

func Validate(raw string) error

Validate reports whether raw is a valid repo:// URI.

Types

type LegacyParts

type LegacyParts struct {
	KindToken string
	Path      string
	Symbol    string
	// GlobalSymbol is true for unresolved targets like "symbol:Name" with no path.
	GlobalSymbol bool
}

LegacyParts holds components derived from a Phase-1 Node.ID.

func ParseLegacyID

func ParseLegacyID(id string) (LegacyParts, error)

ParseLegacyID parses Phase-1 ids such as "func:path#Name" or "file:path".

type URI

type URI struct {
	Repo   string
	Path   string // slash-separated, no leading slash
	Kind   string // URI kind token (func, method, file, …)
	Symbol string // empty for KindFile
}

URI is a parsed, normalized repo:// identifier.

func New

func New(repo, filePath, kindToken, symbol string) (URI, error)

New validates and returns a normalized URI.

func Parse

func Parse(raw string) (URI, error)

Parse parses and normalizes a repo:// URI.

func (URI) String

func (u URI) String() string

String returns the canonical encoded form.

Jump to

Keyboard shortcuts

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