bingo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 17 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"

	NoDirectiveCommand = "bingo:no_directive_fetch"

	PackageRenderablesPrintHeader = "Name\tBinary Name\tPackage @ Version\tBuild EnvVars\tBuild Flags\n" +
		"----\t-----------\t-----------------\t-------------\t-----------\n"
)

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 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)

func SumFilePath added in v0.7.0

func SumFilePath(modFilePath string) string

Types

type ModFile added in v0.3.0

type ModFile struct {
	*mod.File
	// contains filtered or unexported fields
}

ModFile is a wrapper over module file with bingo specific data.

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) DirectPackage added in v0.3.0

func (mf *ModFile) DirectPackage() *Package

func (*ModFile) IsDirectivesAutoFetchDisabled added in v0.5.0

func (mf *ModFile) IsDirectivesAutoFetchDisabled() bool

func (*ModFile) Reload added in v0.3.0

func (mf *ModFile) Reload() 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.

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 (PackageRenderable) ToPackages added in v0.3.0

func (p PackageRenderable) ToPackages() []Package

type PackageRenderables added in v0.4.2

type PackageRenderables []PackageRenderable

func ListPinnedMainPackages added in v0.2.2

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

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

func (PackageRenderables) PrintTab added in v0.4.2

func (pkgs PackageRenderables) PrintTab(target string, w io.Writer) error

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