Golang go/build.ImportMode type examples

package go/build

An ImportMode controls the behavior of the Import method.

Golang go/build.ImportMode type usage examples

Example 1:

 // If ImportMode = 1, Import stops after locating the directory
 // that should contain the sources for a package.  It does not
 // read any files in the directory.

 pkg, err := build.Default.ImportDir(rp.RootPath, build.ImportMode(1))

Example 2:

 otherPkg, err := build.Default.ImportDir(dirName, build.ImportMode(0))

Reference :

http://golang.org/pkg/go/build/#ImportMode

Advertisement