goutil

package
v0.0.0-...-063aa45 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModEnvVar = "GO111MODULE"
)

Variables

View Source
var (
	NilPkgName    = "_"
	NilFset       = token.NewFileSet()
	NilPkgSrc     = "\n\npackage " + NilPkgName + "\n"
	NilAstFile, _ = parser.ParseFile(NilFset, "", NilPkgSrc, 0)
	NilTokenFile  = NilFset.File(NilAstFile.Pos())
)
View Source
var (
	VersionTag string         = build.Default.ReleaseTags[len(build.Default.ReleaseTags)-1]
	Version    ReleaseVersion = func() ReleaseVersion {
		s := strings.TrimPrefix(VersionTag, "go")
		l := strings.SplitN(s, ".", 2)
		v := ReleaseVersion{}
		v.Major, _ = strconv.Atoi(l[0])
		v.Minor, _ = strconv.Atoi(l[1])
		return v
	}()
)

Functions

func BuildContext

func BuildContext(mx *mg.Ctx) *build.Context

func BuildContextWithoutCallbacks

func BuildContextWithoutCallbacks(mx *mg.Ctx) *build.Context

func Dedent

func Dedent(s string) string

Dedent un-indents tab-indented lines is s.

func DedentCompletion

func DedentCompletion(s string) string

DedentCompletion Dedents s then trims preceding and succeeding empty lines.

func HasImportPath

func HasImportPath(root, dir string) (importPath string, ok bool)

HasImportPath reports whether dir is lexically a subdirectory of root. If so, it sets importPath to a slash-separated path that can be joined to root to produce a path equivalent to dir.

HasImportPath is an implementation of go/build.Context.HasSubdir

func IsLetter

func IsLetter(ch rune) bool

func IsPkgDir

func IsPkgDir(dir string) bool

func ModEnabled

func ModEnabled(mx *mg.Ctx, srcDir string) bool

ModEnabled returns true of Go modules are enabled in srcDir

func ModFileNd

func ModFileNd(mx *mg.Ctx, srcDir string) *vfs.Node

func NodeEnclosesPos

func NodeEnclosesPos(node ast.Node, pos token.Pos) bool

func PathList

func PathList(p string) []string

Types

type ParsedFile

type ParsedFile struct {
	Fset      *token.FileSet
	AstFile   *ast.File
	TokenFile *token.File
	Error     error
	ErrorList scanner.ErrorList
}

func ParseFile

func ParseFile(mx *mg.Ctx, fn string, src []byte) *ParsedFile

func ParseFileWithMode

func ParseFileWithMode(mx *mg.Ctx, fn string, src []byte, mode parser.Mode) *ParsedFile

type PosEnd

type PosEnd struct {
	P token.Pos
	E token.Pos
}

func (PosEnd) End

func (pe PosEnd) End() token.Pos

func (PosEnd) Pos

func (pe PosEnd) Pos() token.Pos

type ReleaseVersion

type ReleaseVersion struct {
	Major int
	Minor int
}

type SrcDirKey

type SrcDirKey struct {
	GOROOT, GOPATH, SrcDir string
}

func MakeSrcDirKey

func MakeSrcDirKey(bctx *build.Context, srcDir string) SrcDirKey

Jump to

Keyboard shortcuts

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