Standard library / go/types
go/types.Package.SetImports()
Sets the list of directly imported packages. Expected stdout: 'q\n'.
Formal Syntax & Structure
go syntaxgo
func (pkg *Package) SetImports(list []*Package)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| list | []*Package | Input to the operation as described above. |
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { p := types.NewPackage("p", "p") q := types.NewPackage("q", "q") p.SetImports([]*types.Package{q}) fmt.Println(p.Imports()[0].Path())}