bingo

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FakeRootModFileName is a name for fake go module that we have to maintain, until https://github.com/bwplotka/bingo/issues/20 is fixed.
	FakeRootModFileName = "go.mod"

	NoReplaceCommand = "bingo:no_replace_fetch"
)

Variables

This section is empty.

Functions

func GenHelpers added in v0.2.0

func GenHelpers(relModDir, version string, pkgs []PackageRenderable) error

GenHelpers generates helpers to allows reliable binaries use. Regenerate if needed. It is expected to have at least one mod file. TODO(bwplotka): Allow installing those optionally?

func ModIndirectModules added in v0.3.0

func ModIndirectModules(modFile string) (mods []module.Version, err error)

ModIndirectModules return the all indirect mod from any module file.

func NameFromModFile

func NameFromModFile(modFile string) (name string, oneOfMany bool)

NameFromModFile returns binary name from module file path.

func ParseModFileOrReader added in v0.3.0

func ParseModFileOrReader(modFile string, r io.Reader) (*modfile.File, error)

ParseModFileOrReader parses any module file or reader allowing to read it's content.

func RemoveHelpers added in v0.2.0

func RemoveHelpers(modDir string) error

RemoveHelpers deletes helpers from mod directory.

func SortRenderables added in v0.3.0

func SortRenderables(pkgs []PackageRenderable)

Types

type ModFile added in v0.3.0

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

ModFile represents bingo tool .mod file.

func CreateFromExistingOrNew added in v0.3.0

func CreateFromExistingOrNew(ctx context.Context, r *runner.Runner, logger *log.Logger, existingFile, modFile string) (*ModFile, error)

CreateFromExistingOrNew creates and opens new bingo enhanced module file. If existing file exists and is not malformed it copies this as the source, otherwise completely new is created. It's a caller responsibility to Close the file when not using anymore.

func OpenModFile added in v0.3.0

func OpenModFile(modFile string) (_ *ModFile, err error)

OpenModFile opens bingo mod file. It also adds meta if missing and trims all require direct module imports except first within the parsed syntax. It's a caller responsibility to Close the file when not using anymore.

func (*ModFile) AutoReplaceDisabled added in v0.3.0

func (mf *ModFile) AutoReplaceDisabled() bool

func (*ModFile) Close added in v0.3.0

func (mf *ModFile) Close() error

Close flushes changes and closes file.

func (*ModFile) DirectPackage added in v0.3.0

func (mf *ModFile) DirectPackage() *Package

func (*ModFile) FileName added in v0.3.0

func (mf *ModFile) FileName() string

func (*ModFile) Flush added in v0.3.0

func (mf *ModFile) Flush() error

Flush saves all changes made to parsed syntax and reloads the parsed file.

func (*ModFile) Reload added in v0.3.0

func (mf *ModFile) Reload() (err error)

func (*ModFile) SetDirectRequire added in v0.3.0

func (mf *ModFile) SetDirectRequire(target Package) (err error)

SetDirectRequire removes all require statements and set to the given one. It supports package level versioning. It's caller responsibility to Flush all changes.

func (*ModFile) SetReplace added in v0.3.0

func (mf *ModFile) SetReplace(target ...*modfile.Replace) (err error)

SetReplace removes all replace statements and set to the given ones. It's caller responsibility to Flush all changes.

type Package added in v0.3.0

type Package struct {
	Module module.Version

	// RelPath is a path that together with Module.Path composes a package path, like "/pkg/makefile".
	// Empty if the module is a full package path.
	// If Module.Path is empty and RelPath specified, it means that we don't know what is a module what is the package path.
	RelPath string

	// BuildEnvs are environment variables to be used during go build process.
	BuildEnvs envars.EnvSlice
	// BuildFlags are flags to be used during go build process.
	BuildFlags []string
}

A Package (for clients, a bingo.Package) is defined by a module path, package relative path and version pair. These are stored in their plain (unescaped) form.

func ModDirectPackage

func ModDirectPackage(modFile string) (pkg Package, err error)

ModDirectPackage return the first direct package from bingo enhanced module file. The package suffix (if any) is encoded in the line comment, in the same line as module and version.

func (Package) Path added in v0.3.0

func (m Package) Path() string

Path returns a full package path.

func (Package) String added in v0.3.0

func (m Package) String() string

String returns a representation of the Package suitable for `go` tools and logging. (Module.Path/RelPath@Module.Version, or Module.Path/RelPath if Version is empty).

type PackageRenderable added in v0.3.0

type PackageRenderable struct {
	Name        string
	ModPath     string
	PackagePath string
	EnvVarName  string
	Versions    []PackageVersionRenderable

	BuildFlags   []string
	BuildEnvVars []string
}

PackageRenderable is used in variables.go. Modify with care.

func ListPinnedMainPackages added in v0.2.2

func ListPinnedMainPackages(logger *log.Logger, modDir string, remMalformed bool) (pkgs []PackageRenderable, _ error)

ListPinnedMainPackages lists all bingo pinned binaries (Go main packages) in the same order as seen in the filesystem.

func (PackageRenderable) ToPackages added in v0.3.0

func (p PackageRenderable) ToPackages() []Package

type PackageVersionRenderable added in v0.3.0

type PackageVersionRenderable struct {
	Version string
	ModFile string
}

PackageVersionRenderable is used in variables.go. Modify with care.

Jump to

Keyboard shortcuts

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