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

v0 source pure

v0 - Unaudited: This is an initial version that has not yet been formally audited. A fully audited version will be pu...

Readme 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

  • 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.

Overview

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.

Functions 3

func Construct

1func Construct(pkgpath, name string) string
source

Construct a qualified identifier.

Example
1fqName := fqname.Construct("gno.land/r/demo/foo20", "Token")
2fmt.Println("Fully Qualified Name:", fqName)
3// Output: gno.land/r/demo/foo20.Token

func Parse

1func Parse(fqname string) (pkgpath, name string)
source

Parse splits a fully qualified identifier into its package path and name components. It handles cases with and without slashes in the package path.

Example
1pkgpath, name := fqname.Parse("gno.land/p/nt/avl/v0.Tree")
2ufmt.Sprintf("Package: %s, Name: %s\n", id.Package, id.Name)
3// Output: Package: gno.land/p/nt/avl/v0, Name: Tree

Imports 1

  • strings stdlib

Source Files 4