In Development Package, API may change between versions.

import "github.com/egdaemon/eg/runtime/x/wasi/eggolang"

func AutoCompile

func AutoCompile() eg.OpFn

shorthand for New().AutoCompile()

Example

package main

import (
	"context"
	"log"

	"github.com/egdaemon/eg/runtime/wasi/eg"
	"github.com/egdaemon/eg/runtime/x/wasi/eggolang"
)

func main() {
	// go build ./... for every module in the working directory.
	err := eg.Perform(
		context.Background(),
		eggolang.AutoCompile(),
	)
	if err != nil {
		log.Fatalln(err)
	}
}

func AutoInstall

func AutoInstall() eg.OpFn

shorthand for New().AutoInstall()

Example

package main

import (
	"context"
	"log"

	"github.com/egdaemon/eg/runtime/wasi/eg"
	"github.com/egdaemon/eg/runtime/x/wasi/eggolang"
)

func main() {
	// go install ./... for every module in the working directory.
	err := eg.Perform(
		context.Background(),
		eggolang.AutoInstall(),
	)
	if err != nil {
		log.Fatalln(err)
	}
}

func AutoTest

func AutoTest() eg.OpFn

shorthand for New().AutoTest()

Example

package main

import (
	"context"
	"log"

	"github.com/egdaemon/eg/runtime/wasi/eg"
	"github.com/egdaemon/eg/runtime/x/wasi/egcoverage"
	"github.com/egdaemon/eg/runtime/x/wasi/eggolang"
)

func main() {
	// run the tests for every module in the working directory with the defaults.
	err := eg.Perform(
		context.Background(),
		eggolang.AutoTest(),
		egcoverage.Report(eggolang.Coverage()...),
	)
	if err != nil {
		log.Fatalln(err)
	}
}

func CacheBuildDirectory

func CacheBuildDirectory() string

func CacheDirectory

func CacheDirectory(dirs ...string) string

func CacheModuleDirectory

func CacheModuleDirectory() string

func Coverage

func Coverage() coverage.Options

Coverage is the coverage of the profiles AutoTest wrote, with paths relative to the workspace. it is recorded with egcoverage.Report.

func Env

func Env() []string

attempt to build the golang environment that sets up the golang environment for caching.

Example

package main

import (
	"fmt"
	"os"

	_eg "github.com/egdaemon/eg"
	"github.com/egdaemon/eg/internal/envx"
	"github.com/egdaemon/eg/runtime/x/wasi/eggolang"
)

func main() {
	os.Setenv("CACHE_DIRECTORY", "/cache")
	os.Setenv(_eg.EnvComputeCacheDirectory, "/cache")

	// the process environment is inherited, the cache directories are set last so they take precedence.
	effective := envx.NewEnvironFromStrings(eggolang.Env()...)

	fmt.Println("GOCACHE", effective.String("", "GOCACHE"))
	fmt.Println("GOMODCACHE", effective.String("", "GOMODCACHE"))

}

Output

GOCACHE /cache/.eg/golang/build
GOMODCACHE /cache/.eg/golang/mod

func Runtime

func Runtime() shell.Command

Create a shell runtime that properly sets up the golang environment for caching.

⬤