builder

package
v0.0.0-...-e76ccbf Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

package builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder can be used in testing to create a temporary go module or gopath, src, namespace and package directory, and populate it with source files.

func New

func New(env vos.Env, namespace string, gomod bool) (*Builder, error)

New creates a new temporary location, either for a go module or for a gopath root. See NewGoModule or NewGoRoot for the details. Remember to defer the Cleanup() method to delete the temporary files.

func NewGoModule

func NewGoModule(env vos.Env, namespace string) (*Builder, error)

NewGoModule creates a new go module root in the system temporary location, creates the root dir and the go.mod file. Remember to defer the Cleanup() method to delete the temporary files.

func NewGoRoot

func NewGoRoot(env vos.Env, namespace string) (*Builder, error)

NewGoRoot creates a new gopath in the system temporary location, creates the src dir and the namespace dir. The gopath is appended to the beginning of the existing gopath, so existing imports will still work. Remember to defer the Cleanup() method to delete the temporary files.

func (*Builder) Cleanup

func (b *Builder) Cleanup()

Cleanup deletes all temporary files.

func (*Builder) File

func (b *Builder) File(packageName, filename, contents string) error

File creates a new source file in the package.

func (*Builder) Package

func (b *Builder) Package(packageName string, files map[string]string) (packagePath string, packageDir string, err error)

Package creates a new package and populates with source files.

func (*Builder) Root

func (b *Builder) Root() string

Root returns the temporary gopath root dir.

Jump to

Keyboard shortcuts

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