lib

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoTidy

func GoTidy(files []ModFileContent)

func PrintError

func PrintError(message string)

Prints a formatted error

func PrintErrorCommand

func PrintErrorCommand(message string)

Prints a formatted command

func PrintErrorPanic

func PrintErrorPanic(message string)

Prints a formatted error and exit with non-zero status code

func PrintGoModFile

func PrintGoModFile(file GoModFile) string

Prints a go.mod file from the struct representation of the go.mod file

func PrintHeader

func PrintHeader(message string)

Prints a formatted header

func PrintInfo

func PrintInfo(message string)

Prints a formatted info message

Types

type Dependency

type Dependency struct {
	ModuleName string  `@String`
	Version    string  `(@Version | @"latest")`
	Comment    *string `("//" @String)?`
}

A struct that represents a go.mod dependency

type Exclude

type Exclude struct {
	Dependency Dependency `@@`
}

type GoModFile

type GoModFile struct {
	Module     string      `"module" @String`
	Statements []Statement `@@*`

	GoVersion    *string
	Requirements []Dependency
	Replacements []Replacement
	Excludes     []Exclude
}

The root level object that represents a go.mod file

func Parse

func Parse(source string) (*GoModFile, error)

Will parse the given string into GoModFile struct

func (*GoModFile) Flatten

func (gmf *GoModFile) Flatten()

type ModFileContent

type ModFileContent struct {
	Content []byte
	Path    string
	Error   error
}

func GoLatest

func GoLatest(rootPath string, pattern *regexp.Regexp) []ModFileContent

This function will run go-latest logic against the provided root path and compiled regex pattern

type Replacement

type Replacement struct {
	FromModule string     `@String Version? "=>"`
	ToModule   Dependency `@@`
}

A struct that represents a replace directive

type Statement

type Statement struct {
	GoVersion    *string       `( "go" @String )`
	Requirements []Dependency  `| (("require" "(" @@* ")") | ("require" @@))`
	Replacements []Replacement `| (("replace" "(" @@* ")") | ("replace" @@))`
	Excludes     []Exclude     `| (("exclude" "(" @@* ")") | ("exclude" @@))`
}

Jump to

Keyboard shortcuts

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