godata

package
v0.0.0-...-7deb90a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2010 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Code for handling go packages.

Index

Constants

View Source
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

View Source
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)
}

func (*GoFile) ParseFile

func (this *GoFile) ParseFile(packs *GoPackageContainer) (err os.Error)

Parses the content of a .go file and searches for package name, imports and main function.

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 NewGoPackage

func NewGoPackage(name string) *GoPackage

Creates a new goPackage.

func (*GoPackage) Clone

func (this *GoPackage) Clone() *GoPackage

Creates a clone of a package. Entries in files and depends are the same but with new vectors.

func (*GoPackage) HasTestFiles

func (this *GoPackage) HasTestFiles() bool

func (*GoPackage) Merge

func (this *GoPackage) Merge(pack *GoPackage)

Merge a different package to this package. Will add dependencies and files, but keep all other things as they are.

func (*GoPackage) NeedsLocalSearchPath

func (this *GoPackage) NeedsLocalSearchPath() bool

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL