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) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pkg | *Package | Package containing the symbol; nil for package-independent objects. |
| name | string | Name 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")) }