v0 source pure
v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...
View source
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
Parsetreats everything after the dot following the last slash as the name, so nested selectors likePkg.Type.Methodround-trip as a single name.RenderLinkonly linksgno.land-rooted paths; foreign domains (e.g.github.com/...) are returned unmodified except for the dot-joined slug.RenderLinkmarkdown-escapes theslug, but NOTpkgPath: a]or)in an untrustedpkgPathbreaks out of the link. Pass validated package paths, or sanitize withgno.land/p/nt/markdown/sanitize/v0before rendering untrusted input.
v0 - Unaudited: This is an initial version 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.
Package fqname provides utilities for handling fully qualified identifiers in Gno, typically a package path followed by a dot and a symbol name.
Package fqname provides utilities for handling fully qualified identifiers in Gno. A fully qualified identifier typically includes a package path followed by a dot (.) and then the name of a variable, function, type, or other package-level declaration.
3
func Parse
Parse splits a fully qualified identifier into its package path and name components. It handles cases with and without slashes in the package path.
func RenderLink
RenderLink creates a formatted link for a fully qualified identifier. If the package path starts with "gno.land", it converts it to a markdown link. If the domain is different or missing, it returns the input as is.
1
- strings stdlib