Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompilePackage ¶
Compiles package to binary, outputting it to outDir root dir, respecting 'importPath' directory structure so that 'go tool compile' command knows where to find it.
outDir is the root directory where the file is gonna be written to.
NOTE on outDir:
This function will use outDir as -I param, may be changed in the future.
pkgPath is the directory where to find all of the .go source files from the package.
importPath is the module-aware path to find this package, used to create directory structure inside of outDir.
GOOS and GOARCH is the targeted operative system and platform architecture.
Returns path to object file generated.
Types ¶
type Resolver ¶
func (*Resolver) ResolveDeps ¶
func (r *Resolver) ResolveDeps(ctxt *build.Context, modDir, targetPkg string, modFile *modfile.File) (pkgsToCompile []*build.Package, zipModFound []string, err error)
ctxt is the build.Context struct that is going to be used for resolving packages
modDir is the root directory of the module that is being processed, should be an absolute path
targetPkg is an optional path parameter that is relative to modDir, specifying a main package that is required to be resolved, should be empty string if no main package is gonna be build
modFile is the parsed go.mod file from the targeted module modDir
Returns: ¶
pkgsToCompile is a slice that contains all of the packages that the targeted module provides in source code format, including targetPkg if specified. They are sorted in a way such that the 'go tool compile' can compile them correctly with no dependency errors
zipModFound is a slice that contains paths to zip modules, where you can find libraries in object code format
err is non-nil only if:
- Dependencies cannot be resolved (missing packages, build constraints not satisfied, etc)
- if specified targetPkg, and targetPkg is not a main package or targetPkg is not a valid relative path to modDir
- OS I/O error
- Circular dependency between packages
- Any package imports a main package