Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

/p/nt/fqname/v0

Directory · 4 Files
README.md Open

v0 - Unaudited This is an initial version of this package that has not yet been formally audited. A fully audited version will be published as a subsequent release. Use in production at your own risk.

fqname - Fully qualified identifiers

Parse, construct, and link fully qualified Gno identifiers of the form <pkgpath>.<name> (e.g. gno.land/p/nt/avl/v0.Tree).

Usage

 1import "gno.land/p/nt/fqname/v0"
 2
 3// Split a fully qualified name
 4pkgpath, name := fqname.Parse("gno.land/p/nt/avl/v0.Tree")
 5// pkgpath == "gno.land/p/nt/avl/v0", name == "Tree"
 6
 7// Rebuild one from its parts
 8id := fqname.Construct("gno.land/r/demo/foo20", "Token")
 9// id == "gno.land/r/demo/foo20.Token"
10
11// Render as a Markdown link (gno.land paths become clickable)
12link := fqname.RenderLink("gno.land/r/demo/foo20", "Token")
13// link == "[gno.land/r/demo/foo20](/r/demo/foo20).Token"

API

 1// Parse splits a fully qualified identifier into (pkgpath, name).
 2// If no name is present (no dot after the last slash), name is "".
 3func Parse(fqname string) (pkgpath, name string)
 4
 5// Construct joins pkgpath and name with a dot. If name is empty, returns pkgpath.
 6func Construct(pkgpath, name string) string
 7
 8// RenderLink formats a fully qualified identifier as Markdown.
 9// Paths starting with "gno.land" are turned into a link to the package;
10// other paths are returned as plain text. The slug is dot-appended and
11// markdown-escaped.
12func RenderLink(pkgPath, slug string) string

Notes

  • Parse treats everything after the dot following the last slash as the name, so nested selectors like Pkg.Type.Method round-trip as a single name.
  • RenderLink only links gno.land-rooted paths; foreign domains (e.g. github.com/...) are returned unmodified except for the dot-joined slug.
  • RenderLink markdown-escapes the slug, but NOT pkgPath: a ] or ) in an untrusted pkgPath breaks out of the link. Pass validated package paths, or sanitize with gno.land/p/nt/markdown/sanitize/v0 before rendering untrusted input.