Documentation ¶
Overview ¶
Package beku provide library for managing Go packages in user's environment (GOPATH or vendor directory).
Index ¶
- Constants
- Variables
- func GetCompareURL(remoteURL, oldVer, newVer string) (url string)
- func IsIgnoredDir(name string) bool
- func IsTagVersion(version string) bool
- type Env
- func (env *Env) Exclude(importPaths []string)
- func (env *Env) Freeze() (err error)
- func (env *Env) GetLocalPackage(importPath string) (pkg *Package, err error)
- func (env *Env) GetPackageFromDB(importPath, remoteURL string) (int, *Package)
- func (env *Env) GetUnused(srcPath string) (err error)
- func (env *Env) IsExcluded(importPath string) bool
- func (env *Env) Load(file string) (err error)
- func (env *Env) Query(pkgs []string)
- func (env *Env) Remove(rmPkg string, recursive bool) (err error)
- func (env *Env) Rescan(firstTime bool) (ok bool, err error)
- func (env *Env) Save(file string) (err error)
- func (env *Env) Scan() (err error)
- func (env *Env) String() string
- func (env *Env) Sync(pkgName, importPath string) (err error)
- func (env *Env) SyncAll() (err error)
- func (env *Env) SyncMany(pkgs []string) (err error)
- type Package
- func (pkg *Package) CheckoutVersion(newVersion string) (err error)
- func (pkg *Package) CompareVersion(newPkg *Package) (err error)
- func (pkg *Package) FetchLatestVersion() (err error)
- func (pkg *Package) Freeze() (err error)
- func (pkg *Package) GetRecursiveImports(env *Env) (imports []string, err error)
- func (pkg *Package) GoClean() (err error)
- func (pkg *Package) GoInstall(envPath string) (err error)
- func (pkg *Package) Install() (err error)
- func (pkg *Package) IsEqual(other *Package) bool
- func (pkg *Package) IsNewer(older *Package) bool
- func (pkg *Package) Remove() (err error)
- func (pkg *Package) RemoveRequiredBy(importPath string) (ok bool)
- func (pkg *Package) Scan() (err error)
- func (pkg *Package) ScanDeps(env *Env) (err error)
- func (pkg *Package) String() string
- func (pkg *Package) Update(newPkg *Package) (err error)
- func (pkg *Package) UpdateMissingDep(newPkg *Package, addAsDep bool) (found bool)
Constants ¶
const ( // DefDBName define default database name, where the dependencies will // be saved and loaded. DefDBName = "beku.db" )
const (
VCSModeGit = "git"
)
Variables ¶
var ( ErrGOROOT = errors.New("GOROOT is not defined") // ErrVersion define an error when directory have VCS metadata (e.g. // `.git` directory) but did not have any tag or commit. ErrVersion = errors.New("no tag or commit found") // ErrRemote define an error when package remote URL is empty or // invalid. ErrRemote = errors.New("empty or invalid remote URL found") // ErrPackageName define an error if package name is empty or invalid. ErrPackageName = errors.New("empty or invalid package name") )
List of error messages.
Functions ¶
func GetCompareURL ¶
GetCompareURL return the URL that compare two versions of package from given remote URL. Remote URL can be in git format ("git@github.com:<username>/<reponame>") or in HTTP format.
On package that hosted on Github, the compare URL format is,
https://github.com/<username>/<reponame>/compare/<old-version>...<new-version>
func IsIgnoredDir ¶
IsIgnoredDir will return true if directory start with "_" or ".", or equal with "vendor" or "testdata"; otherwise it will return false.
func IsTagVersion ¶
IsTagVersion return true if "version" prefixed with "v" or contains at least one dot "." character.
Types ¶
type Env ¶
type Env struct { NoConfirm bool // contains filtered or unexported fields }
Env contains the environment of Go including GOROOT source directory, package root directory (prefix), list of packages, list of standard packages, and list of missing packages.
func NewEnvironment ¶
NewEnvironment will gather all information in user system.
func (*Env) Freeze ¶
Freeze all packages in database. Install all registered packages in database and remove non-registered from "src" and "pkg" directories.
func (*Env) GetLocalPackage ¶ added in v0.5.0
GetLocalPackage will return installed package from system.
func (*Env) GetPackageFromDB ¶
GetPackageFromDB will return index and package in database. If no package found, it will return -1 and nil.
func (*Env) GetUnused ¶
GetUnused will get all non-registered packages from "src" directory, without including all excluded packages.
func (*Env) IsExcluded ¶
IsExcluded will return true if import path is registered as one of excluded package; otherwise it will return false.
func (*Env) Query ¶
Query the package database. If package is not empty, it will only show the information about that package.
func (*Env) Remove ¶
Remove package from environment. If recursive is true, it will also remove their dependencies, as long as they are not required by other package.
func (*Env) Sync ¶
Sync will download and install a package including their dependencies. If the importPath is defined, it will be downloaded into that directory.
type Package ¶
type Package struct { ImportPath string FullPath string RemoteName string RemoteURL string RemoteBranch string Version string VersionNext string DepsMissing []string Deps []string RequiredBy []string // contains filtered or unexported fields }
Package define Go package information: path to package, version, whether is tag or not, and VCS mode.
func NewPackage ¶
NewPackage create a package set the package version, tag status, and dependencies.
func (*Package) CheckoutVersion ¶
CheckoutVersion will set the package version to new version.
func (*Package) CompareVersion ¶
CompareVersion will compare package version using current package as base.
func (*Package) FetchLatestVersion ¶ added in v0.5.0
FetchLatestVersion will try to update the package and get the latest version (tag or commit).
func (*Package) GetRecursiveImports ¶
GetRecursiveImports will get all import path recursively using `go list` and return it as slice of string without any duplication.
func (*Package) GoInstall ¶
GoInstall a package recursively ("./...").
Set PATH to let go install that require gcc work when invoked from non-interactive shell (e.g. buildbot).
func (*Package) Install ¶
Install a package. Clone package "src" directory, set to the latest tag if exist or to the latest commit, and scan dependencies.
func (*Package) IsEqual ¶
IsEqual will return true if current package have the same import path, remote name, remote URL, and version with other package; otherwise it will return false.
func (*Package) IsNewer ¶ added in v0.5.0
IsNewer will return true if current package is using tag and have newer version that other package. If current package is not using tag, it's always return true.
func (*Package) RemoveRequiredBy ¶
RemoveRequiredBy will remove package importPath from list of required-by. It will return true if importPath is removed from list, otherwise it will return false.
func (*Package) Scan ¶
Scan will set the package version, `isTag` status, and remote URL using metadata in package repository.
func (*Package) ScanDeps ¶
ScanDeps will scan package dependencies, removing standard packages, keep only external dependencies.
func (*Package) Update ¶
Update the current package to the new package. The new package may contain new remote or new version.
func (*Package) UpdateMissingDep ¶
UpdateMissingDep will remove missing package if it's already provided by new package import-path.
If "addAsDep" is true, it will also, (1) add new package as one of package dependencies of current package, and (2) add current package as required by new package.
It will return true if new package solve the missing deps on current package, otherwise it will return false.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
beku
Beku is a command line program to manage packages in user's environment (GOPATH or vendor) directory.
|
Beku is a command line program to manage packages in user's environment (GOPATH or vendor) directory. |
go
|
|
vcs
Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command.
|
Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command. |