parser

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVersion

func ParseVersion(ver string) (ref string, err error)

ParseVersion retrieves a reference out of a version.

func SanitizeDependency

func SanitizeDependency(content string) string

func StripVersionFromDependency

func StripVersionFromDependency(content string) (res string, err error)

StripVersionFromDependency removes the version that might exist as the last fields in the `require` path for such dependency.

For instance, having in `go.mod`:

require github.com/my/mod/v2 v2.0.0

This method would take:

github.com/my/mod/v2

And return

github.com/my/mod

If the last piece is a proper semver version, erroring otherwise.

Types

type Line

type Line struct {
	Dependency                  string
	Reference                   string
	RelativeDirectoryDependency string
}

Line represents the contents of a line without any parsing applied to the fields beside filtering out unwanted content.

func ParseLine

func ParseLine(content string) (line Line, err error)

ParseLine parses a single dependency line, returning the struct that represents its contents, with the version already interpreted as a reference.

	gopkg.in/gorethink/gorethink.v4 v4.1.0+incompatible // indirect
     |                             | |    | |         |  |         |
     *-+---------------------------* *-+--* *+--------*  *-----+---*
       |                               |     |                 |
       |                               |     excluded from parsing
       |                               |
       |                             reference (e.g., git tag)
       |
       dependency name (where to ask for go source code)

In case of a replace directive being used, only the target is taken into considration.

Jump to

Keyboard shortcuts

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