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) *PackageParameters & Attributes
| Name | Type | Description |
|---|---|---|
| path | string | Package import path. |
| name | string | Name 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()) }