Documentation
¶
Overview ¶
Code for handling go packages.
Index ¶
- Constants
- Variables
- type GoFile
- type GoPackage
- type GoPackageContainer
- func (this *GoPackageContainer) AddFile(gf *GoFile, packageName string)
- func (this *GoPackageContainer) AddNewPackage(packName string) (pack *GoPackage)
- func (this *GoPackageContainer) AddPackage(pack *GoPackage) *GoPackage
- func (this *GoPackageContainer) Get(name string) (pack *GoPackage, exists bool)
- func (this *GoPackageContainer) GetMain(filename string, merge bool) (pack *GoPackage, exists bool)
- func (this *GoPackageContainer) GetMainCount() int
- func (this *GoPackageContainer) GetMainFilenames() (names []string)
- func (this *GoPackageContainer) GetMainPackages(merge bool) (pack []*GoPackage)
- func (this *GoPackageContainer) GetPackageCount() int
- func (this *GoPackageContainer) GetPackageNames() (packNames []string)
Constants ¶
const ( UNKNOWN_PACKAGE = iota // could be in the local path or somewhere else LOCAL_PACKAGE // this is imported with "./name" REMOTE_PACKAGE // unused right now )
Variables ¶
var DefaultOutputFileName string
Functions ¶
This section is empty.
Types ¶
type GoFile ¶
type GoFile struct { Filename string // file name with relative path Pack *GoPackage // the package this file belongs to HasMain bool // main function found (only true for main package) IsCGOFile bool // imports "C" IsTestFile bool // files with "_test.go" suffix TestFunctions *vector.Vector // vector of all test functions (name only) BenchmarkFunctions *vector.Vector // vector of all benchmark functions (name only) }
type GoPackage ¶
type GoPackage struct { Name string // name of the package Path string // possible relative path to the package Type int // local, remote or unknown (default) Files *vector.Vector // a list of files for this package Depends *vector.Vector // a list of other local packages this one depends on Compiled bool // true = finished compiling InProgress bool // true = currently trying to compile dependencies (needed to find recursive dependencies) HasErrors bool // true = compiler returned an error OutputFile string // filename (and maybe path) of the output files without extensions }
func (*GoPackage) Clone ¶
Creates a clone of a package. Entries in files and depends are the same but with new vectors.
func (*GoPackage) HasTestFiles ¶
func (*GoPackage) Merge ¶
Merge a different package to this package. Will add dependencies and files, but keep all other things as they are.
func (*GoPackage) NeedsLocalSearchPath ¶
type GoPackageContainer ¶
type GoPackageContainer struct {
// contains filtered or unexported fields
}
func NewGoPackageContainer ¶
func NewGoPackageContainer() *GoPackageContainer
func (*GoPackageContainer) AddFile ¶
func (this *GoPackageContainer) AddFile(gf *GoFile, packageName string)
Adds a GoFile to the list of packages. This will also create a new package if there is none yet. After this operation gf.Pack points to the package this file was added to.
func (*GoPackageContainer) AddNewPackage ¶
func (this *GoPackageContainer) AddNewPackage(packName string) (pack *GoPackage)
Creates an empty GoPackage and adds it to the container.
func (*GoPackageContainer) AddPackage ¶
func (this *GoPackageContainer) AddPackage(pack *GoPackage) *GoPackage
Will add a package to the list of packages. If there is already a package with the same name the new package will be merged to the old one. The returned package is the one that should be used after adding it.
func (*GoPackageContainer) Get ¶
func (this *GoPackageContainer) Get(name string) (pack *GoPackage, exists bool)
Returns a GoPackage for a given package name, or (nil, false) if none was found.
func (*GoPackageContainer) GetMain ¶
func (this *GoPackageContainer) GetMain(filename string, merge bool) (pack *GoPackage, exists bool)
Will return the main package for a certain filename. That file must include a main function. If "merge" is true the returned package is a merge of the package with the main function file and all other files without main function that are in the main package. The returned package may be a copy of the one inside the container. Writing to it might not change values in the original package.
func (*GoPackageContainer) GetMainCount ¶
func (this *GoPackageContainer) GetMainCount() int
func (*GoPackageContainer) GetMainFilenames ¶
func (this *GoPackageContainer) GetMainFilenames() (names []string)
func (*GoPackageContainer) GetMainPackages ¶
func (this *GoPackageContainer) GetMainPackages(merge bool) (pack []*GoPackage)
This method will return an array of packages, one for every file that has a main function in it. If merge is true the packages will be merged with other files of the main package that don't have a main function in it. The returned packages may be copies of the one inside the container. Writing to them might not change values in the original packages.
func (*GoPackageContainer) GetPackageCount ¶
func (this *GoPackageContainer) GetPackageCount() int
func (*GoPackageContainer) GetPackageNames ¶
func (this *GoPackageContainer) GetPackageNames() (packNames []string)