gotool

package
v0.0.0-...-3c1f4a5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package gotool provides access to various helpful command line go tools, like go list etc.

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Debug is a global flag, which is only used by the command line program to track errors down.

Functions

func Build

func Build(opts Options) error

Build just issues the go build command.

func BuildWasm

func BuildWasm(mod Module, outFile string) error

BuildWasm builds an idiomatic wasm go module. The wasm main entry point must be defined at cmd/wasm. The output file is forwarded.

func Env

func Env(name string) (string, error)

Env requests the given parameter name.

func Generate

func Generate(dir string) (string, error)

Generate invokes go generate ./... in the given directory.

func ModTidy

func ModTidy(dir string) (string, error)

ModTidy invokes go mod tidy in the given directory. It will clean up deps and download their source. See also https://golang.org/ref/mod#go-mod-tidy.

func Version

func Version() (string, error)

Version returns the go version.

Types

type LDFLAGS

type LDFLAGS struct {
	// X is to inject variables at compilation/linking time.
	X []string
}

LDFLAGS represent the go linker flags.

func (*LDFLAGS) String

func (f *LDFLAGS) String() string

String returns the linker flags.

type Module

type Module struct {
	Path    string // Path is the module import path or the module name
	Main    bool   // Main tells whether this module is the actual main module
	Dir     string // Dir is the local folder, where the actual source code resides
	Version string // Version is usually something like v1.2.3 or v0.0.0-20201210172659-1ccebcf04a20
	Replace struct {
		Dir string // Dir is the actual local replacement directory
	}
}

A Module describes the anatomy of Go Module.

func ModList

func ModList(moduleDir string) ([]Module, error)

ModList returns all local folders to each correct dependency version. The first returned directory is the main directory.

type Options

type Options struct {
	GOOS       string
	GOARCH     string
	WorkingDir string
	Output     string
	Packages   []string
	Env        []string
	LDFLAGS    LDFLAGS
}

Options represent the various build options for the go build command.

Jump to

Keyboard shortcuts

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