Standard library / go/types

go/types.NewPackage()

Creates an initially incomplete package descriptor with the given path and name. Expected stdout: 'demo/p false\n'.

Formal Syntax & Structure

go syntaxgo
func NewPackage(path, name string) *Package

Parameters & Attributes

NameTypeDescription
pathstringPackage import path.
namestringName of the symbol or package.

Return Value

*Package

Creates an initially incomplete package descriptor with the given path and name.

Working Example

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