goenv

package module
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

README

GoEnv

The virtual enviroments manager for Go!.

Installation

Get Binaries

See to RELEASES PAGE and get your binary file for various operational systems and architecturies.

NOTE: If gets alone binary, extract it (if archived) and PUT the directory into your PATH enviroment variable.

Check your $PATH enviroment variable:

export PATH=/dir/of/my/goenv_binary:$PATH
Build

Get sources:

go get -u github.com/moisespsena-go/goenv/goenv

Check your $PATH enviroment variable:

export PATH=$GOPATH/bin:$PATH
Add shortcut commands and Auto Completion
goenv setup | tee -a ~/.bashrc
source ~/.bashrc

Usage

The help command
goenv -h

Output:

The virtual enviroments manager for Go!

Usage:
  goenv [command]

Available Commands:
  activate    Activate the virtualenv with NAME.
  backup      Create backup .tar.gz file for the virtualenv with have NAME.
  completion  Generates bash completion scripts
  db          Returns the current database path.
  help        Help about any command
  init        Init new virtual enviroment.
  ls          List all virtual enviroments on current database.
  path        Print env path
  restore     Restore backup.tar.gz file to the virtualenv with have NAME.
  rm          Remove the virtualenv with have NAME.
  setup       Generate sources for custom prompt commands.
  update      Update activation scripts.
  version     Show program version
  versions    Manage golang binary versions

Flags:
  -d, --db string   Database directory (default is $HOME/.goenv). (default "~/.goenv")
  -h, --help        help for goenv

Use "goenv [command] --help" for more information about a command.
Init new enviroment
goenv init env1
List enviroments
goenv ls
Activate repository:
eval $(goenv activate env1)

or (see to Database section)

source $(goenv db)/env1/activate
Deactivate it
goenv-deactivate
Remove repository:

Move to trash directory (DB_DIR/.trash, see to Database section):

goenv rm env1

Remove permanently:

goenv rm -p env1
Database

Get database path:

goenv db
Custom database path
With command paramenter

For use custom database path, set the -d flag:

goenv -d ~/custom-db args...

Examples:

goenv -d ~/custom-db init env2
goenv -d ~/custom-db ls
With enviroment variable

Set the enviroment variable:

export GOENVDB=~/custom-db

or

GOENVDB=~/custom-db goenv args...

Thank's!

By Moises P. Sena.

Documentation

Index

Constants

View Source
const VERSIONS_BASENAME = ".goversions"

Variables

This section is empty.

Functions

func IsDir

func IsDir(pth ...string) (bool, error)

func IsFile

func IsFile(pth ...string) (bool, error)

func MkdirAll

func MkdirAll(pth ...string) error

func PathGlobCompile added in v1.1.2

func PathGlobCompile(s string) (g glob.Glob, err error)

func TimeString

func TimeString(t time.Time) string

Types

type BackupFile

type BackupFile struct {
	Reader *tar.Reader
	// contains filtered or unexported fields
}

func NewBackupReader

func NewBackupReader(reader io.Reader, archive bool) (bkp *BackupFile, err error)

func (*BackupFile) Each

func (b *BackupFile) Each(cb func(header *tar.Header, reader *tar.Reader) error) error

func (*BackupFile) EachRoot

func (b *BackupFile) EachRoot(rootName string, cb func(header *tar.Header, reader *tar.Reader) error) error

func (*BackupFile) Extract

func (b *BackupFile) Extract(rootName, target string, options ExtractOptions) error

func (*BackupFile) GetRootName

func (b *BackupFile) GetRootName() (name string, err error)

type BackupOptions

type BackupOptions struct {
	Target        string
	DefaultBackup bool
	Writer        io.Writer
	Patterns      Patterns
}

type ExtractOptions

type ExtractOptions int
const (
	Verbose ExtractOptions = 1 << iota
	Trial
)

func (ExtractOptions) IsTrial

func (o ExtractOptions) IsTrial() bool

func (ExtractOptions) IsVerbose

func (o ExtractOptions) IsVerbose() bool

type GoBinVersion

type GoBinVersion struct {
	Version string
	OsInfo  string
}

func NewGoBinVersion

func NewGoBinVersion(binName string) (*GoBinVersion, error)

type GoEnv

type GoEnv struct {
	DbDir string
}

func NewGoEnv

func NewGoEnv(dbDir string, check bool) (env *GoEnv, err error)

func (*GoEnv) ActivateCode

func (env *GoEnv) ActivateCode(name string) (string, error)

func (*GoEnv) Backup

func (env *GoEnv) Backup(name string, options *BackupOptions) (string, error)

func (*GoEnv) CreateActivate

func (env *GoEnv) CreateActivate(pth, goRoot string) error

func (*GoEnv) GetCheck

func (env *GoEnv) GetCheck(name string) (pth string, err error)

func (*GoEnv) GetPath

func (env *GoEnv) GetPath(name string, require bool) (pth string, err error)

func (*GoEnv) Init

func (env *GoEnv) Init(name, goroot string) (err error)

func (*GoEnv) Ls

func (env *GoEnv) Ls() (names []string, err error)

func (*GoEnv) Restore

func (env *GoEnv) Restore(options *RestoreOptions) (string, error)

func (*GoEnv) Rm

func (env *GoEnv) Rm(name string, delete bool) (string, error)

func (*GoEnv) SetGoVersion

func (env *GoEnv) SetGoVersion(envName, goRoot string) error

func (*GoEnv) TempDir

func (env *GoEnv) TempDir() (pth string, err error)

type GoEnvCmd

type GoEnvCmd struct {
	Env *GoEnv
}

func NewGoEnvCmd

func NewGoEnvCmd(dbDir string, check bool) (envCmd *GoEnvCmd, err error)

func (*GoEnvCmd) ActivateCode

func (cmd *GoEnvCmd) ActivateCode(name string) error

func (*GoEnvCmd) Backup

func (env *GoEnvCmd) Backup(name string, options *BackupOptions) error

func (*GoEnvCmd) Init

func (cmd *GoEnvCmd) Init(names ...string) (err error)

func (*GoEnvCmd) Ls

func (cmd *GoEnvCmd) Ls() error

func (*GoEnvCmd) Restore

func (env *GoEnvCmd) Restore(options *RestoreOptions) error

func (*GoEnvCmd) Rm

func (cmd *GoEnvCmd) Rm(name string, delete bool) error

func (*GoEnvCmd) Setup

func (cmd *GoEnvCmd) Setup() error

func (*GoEnvCmd) Update

func (cmd *GoEnvCmd) Update(envs []string) error

func (*GoEnvCmd) UpdateAll

func (cmd *GoEnvCmd) UpdateAll() error

type GoVersion

type GoVersion struct {
	ID        string
	Name      string
	UpdatedAt time.Time

	Installed  bool
	Root       string
	System     bool
	BinVersion *GoBinVersion
	// contains filtered or unexported fields
}

func GetSystemGoVersion

func GetSystemGoVersion() (*GoVersion, error)

func NewGoVersion

func NewGoVersion(goroot string) (v *GoVersion, err error)

func (*GoVersion) DownloadPath

func (v *GoVersion) DownloadPath() string

func (*GoVersion) DownloadUrl

func (v *GoVersion) DownloadUrl() string

func (*GoVersion) Downloadable

func (v *GoVersion) Downloadable(client *http.Client) (bool, error)

type GoVersions

type GoVersions struct {
	Env *GoEnv
}

func NewGoVersions

func NewGoVersions(env *GoEnv) *GoVersions

func (*GoVersions) Available

func (v *GoVersions) Available(desc bool, terms ...string) ([]*GoVersion, error)

func (*GoVersions) Dir

func (v *GoVersions) Dir() string

func (*GoVersions) DirExists

func (v *GoVersions) DirExists() (pth string, exists bool, err error)

func (*GoVersions) Download

func (v *GoVersions) Download(names ...string) (versions []*GoVersion, err error)

func (*GoVersions) Install

func (vs *GoVersions) Install(names ...string) (versions []*GoVersion, err error)

func (*GoVersions) Ls

func (v *GoVersions) Ls() (vs []*GoVersion, err error)

func (*GoVersions) Set

func (v *GoVersions) Set(versionName, envName string) (err error)
type Header struct {
	Comment string    // comment
	Extra   []byte    // "extra data"
	ModTime time.Time // modification time
	Name    string    // file name
	OS      byte      // operating system type
}

The gzip file stores a header giving metadata about the compressed file. That header is exposed as the fields of the Writer and Reader structs.

type Patterns added in v1.1.2

type Patterns struct {
	// contains filtered or unexported fields
}

func (*Patterns) Append added in v1.1.2

func (e *Patterns) Append(values ...string) (err error)

func (*Patterns) ExcludeFunc added in v1.1.2

func (e *Patterns) ExcludeFunc() ValidFunc

func (*Patterns) ValidFunc added in v1.1.2

func (e *Patterns) ValidFunc() ValidFunc

func (*Patterns) Values added in v1.1.2

func (e *Patterns) Values() []glob.Glob

type RestoreOptions

type RestoreOptions struct {
	Source    string
	OverWrite bool
	Update    bool
	Reader    io.ReadSeeker
	Name      string
	Archive   bool
	Verbose   bool
	Trial     bool
}

type ValidFunc added in v1.1.2

type ValidFunc func(pth string, info os.FileInfo) bool

func Exclude added in v1.1.2

func Exclude(values ...string) (ValidFunc, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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