Standard library / go/types

go/types.Id()

Returns the identifier used to distinguish exported and package-specific unexported names. Expected stdout: 'X demo/p.x\n'.

Formal Syntax & Structure

go syntaxgo
func Id(pkg *Package, name string) string

Parameters & Attributes

NameTypeDescription
pkg*PackagePackage containing the symbol; nil for package-independent objects.
namestringName of the symbol or package.

Return Value

string

Returns the identifier used to distinguish exported and package-specific unexported names.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() { p := types.NewPackage("demo/p", "p"); fmt.Println(types.Id(p, "X"), types.Id(p, "x")) }
Go Reference