Standard library / go/types
go/types.RelativeTo()
Creates a qualifier that omits the package name for the specified package. Expected stdout: '"" "demo/q"\n'.
Formal Syntax & Structure
go syntaxgo
func RelativeTo(pkg *Package) QualifierParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pkg | *Package | Package containing the symbol; nil for package-independent objects. |
Return Value
Qualifier
Creates a qualifier that omits the package name for the specified package.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { p := types.NewPackage("demo/p", "p") q := types.RelativeTo(p) fmt.Printf("%q %q\n", q(p), q(types.NewPackage("demo/q", "q")))}