goenv

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package goenv returns environment variables that are used in various parts of the compiler. You can query it manually with the `tinygo env` subcommand.

Index

Constants

This section is empty.

Variables

View Source
var Keys = []string{
	"GOOS",
	"GOARCH",
	"GOROOT",
	"GOPATH",
	"GOCACHE",
	"CGO_ENABLED",
	"TINYGOROOT",
}

Keys is a slice of all available environment variable keys.

View Source
var TINYGOROOT string

TINYGOROOT is the path to the final location for checking tinygo files. If unset (by a -X ldflag), then sourceDir() will fallback to the original build directory.

Functions

func ClangResourceDir added in v0.31.0

func ClangResourceDir(libclang bool) string

ClangResourceDir returns the clang resource dir if available. This is the -resource-dir flag. If it isn't available, an empty string is returned and -resource-dir should be left unset. The libclang flag must be set if the resource dir is read for use by libclang. In that case, the resource dir is always returned (even when linking dynamically against LLVM) because libclang always needs this directory.

func Compare added in v0.34.0

func Compare(a, b string) int

Compare compares two Go version strings. The result will be 0 if a == b, -1 if a < b, and +1 if a > b. If either a or b is not a valid Go version, it is treated as "go0.0" and compared lexicographically. See Parse for more information.

func Get

func Get(name string) string

Get returns a single environment variable, possibly calculating it on-demand. The empty string is returned for unknown environment variables.

func GetGorootVersion added in v0.14.0

func GetGorootVersion() (major, minor int, err error)

GetGorootVersion returns the major and minor version for a given GOROOT path. If the goroot cannot be determined, (0, 0) is returned.

func GorootVersionString added in v0.14.0

func GorootVersionString() (string, error)

GorootVersionString returns the version string as reported by the Go toolchain. It is usually of the form `go1.x.y` but can have some variations (for beta releases, for example).

func Parse added in v0.34.0

func Parse(version string) (major, minor, patch int, err error)

Parse parses the Go version (like "go1.3.2") in the parameter and return the major, minor, and patch version: 1, 3, and 2 in this example. If there is an error, (0, 0, 0) and an error will be returned.

func Version added in v0.14.0

func Version() string

Return TinyGo version, either in the form 0.30.0 or as a development version (like 0.30.0-dev-abcd012).

Types

This section is empty.

Jump to

Keyboard shortcuts

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