gosum

package
v0.0.0-...-6fd8692 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHashMismatch is returned when a hash is added to a go.sum file that does
	// not match the existing hash.
	ErrHashMismatch = errors.New("gosum: hash mismatch")

	// ErrGoSumMustHaveThreeFields is returned when a go.sum file invalidly has
	// more than 3 fields per line.
	ErrGoSumMustHaveThreeFields = errors.New(
		"gosum: go.sum must have 3 fields per line",
	)
)

Functions

func CompareKeys

func CompareKeys(this, other GoSumKey) int

CompareKeys compares two GoSumKeys.

Performs lexicographical ordering of module paths, then semver comparison of versions, and finally lexicographical ordering of paths.

func Diff

func Diff(sum GoSum, ancestor GoSum) (GoSum, GoSum, GoSum)

Diff returns the difference between the sum and ancestor go.sum files.

Returns the added, modified, and removed hashes.

Types

type GoSum

type GoSum map[GoSumKey]GoSumHash

GoSum represents a go.sum file.

func Merge

func Merge(current GoSum, other GoSum, ancestor GoSum) (GoSum, error)

Merge merges two go.sum files together. The current go.sum file is the one that is being modified, the other go.sum file is the one that is being merged in, and the ancestor go.sum file is the common ancestor of the two go.sum files.

If there are inconsistent hashes between the current and other go.sum files, an error is returned.

func NewGoSum

func NewGoSum(r io.Reader) (GoSum, error)

NewGoSum creates a new GoSum from the given byte slice.

func (GoSum) Add

func (g GoSum) Add(key GoSumKey, hash GoSumHash) error

Add implements a hash-safe way to add a key-value pair to a GoSum map.

func (GoSum) String

func (g GoSum) String() string

String returns a string representation of the GoSum map. The format of the string is "<module path> <version> <hash>\n" for each key-value pair in the map. If the key has a non-empty path, it is appended to the version with a "/" separator. The key-value pairs are concatenated in alphabetical order.

type GoSumHash

type GoSumHash string

GoSumHash represents a hash in a go.sum file.

type GoSumKey

type GoSumKey struct {
	ModulePath string
	Version    string
	Path       string
}

GoSumKey represents a key in a go.sum file. All sums should be uniquely identified by a GoSumKey.

Jump to

Keyboard shortcuts

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