fakegopath

package module
v0.0.0-...-09e1db7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: Apache-2.0 Imports: 9 Imported by: 1

README

fakegopath

Package fakegopath creates a separate go tree in a temporary directory

Documentation

Overview

Package fakegopath provides utilities to create temporary go source trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SourceFile

type SourceFile struct {
	Src     string
	Dest    string
	Content []byte
}

type Temporary

type Temporary struct {
	Path string // The path that is appended.
	Orig string // The original GOPATH
	Pkg  string // The pkg directory
	Src  string // The src directory
	Bin  string // The bin directory
	// contains filtered or unexported fields
}

Temporary is a temporary go source tree. The path is optionally appended to go.build.Default.GOPATH.

func NewTemporary

func NewTemporary(dir string, updateGoPath bool) (*Temporary, error)

NewTemporary creates a temporary under the specified directory. If updateGoPath is true, go.build.Default.GOPATH will have this path prefixed to it.

func NewTemporaryWithFiles

func NewTemporaryWithFiles(prefix string, files []SourceFile) (*Temporary, error)

NewTemporaryWithFiles creates a temporary go source tree after copying/creating files. prefix is used to create a temporary directory in which the source tree is created.

func (*Temporary) Copy

func (t *Temporary) Copy(files []SourceFile) error

CopyFiles copies all source files in files using t.CopyFile or t.WriteFile as needed.

func (*Temporary) CopyFile

func (t *Temporary) CopyFile(dest, src string) error

CopyFile is equivalent to WriteFile with the contents of src.

func (*Temporary) GenerateFile

func (t *Temporary) GenerateFile(file string, tpl *template.Template, args interface{}) error

GenerateFile is equivalent to calling WriteFile with the results of tpl.Execute(..., args)

func (*Temporary) KeepTempDir

func (t *Temporary) KeepTempDir(keep bool)

func (*Temporary) Reset

func (t *Temporary) Reset()

Reset resets the original GOPATH and deletes the temporary directory.

func (*Temporary) WriteFile

func (t *Temporary) WriteFile(file string, contents io.Reader) error

WriteFile writes contents to file, where file is a path relative to the src directory. Any intermediate directories are created if needed.

Jump to

Keyboard shortcuts

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