Golang go/ast.PackageExports() function example

package go/ast

PackageExports trims the AST for a Go package in place such that only exported nodes remain. The pkg.Files list is not changed, so that file names and top-level package comments don't get lost.

PackageExports returns true if there are exported declarations; it returns false otherwise.

Golang go/ast.PackageExports() function usage example

 var astFile *ast.File
 var filename string

 astPkg := ast.Package{
 Name : "test",
 Files : map[string]*ast.File {
 filename : astFile,
 },
 }

 ast.PackageExports(&astPkg)

Reference :

http://golang.org/pkg/go/ast/#PackageExports

Advertisement