Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferToDiff

func BufferToDiff(buff bytes.Buffer,
	colorLeft bool, dumbterm bool, minimal bool) string

func ColorDiff

func ColorDiff(
	dmp *diffmatchpatch.DiffMatchPatch,
	diffs []diffmatchpatch.Diff,
	parseType types.ParseType,
	dumbterm bool,
	minimal bool) string

ColorDiff converts (DiffMatchPatch, []Diff) into colored text report

func Fail

func Fail(msg string, params ...interface{})

func Info

func Info(msg string, params ...interface{})

func LineAtPosition

func LineAtPosition(records []LineOffset, pos uint32) int

Return the line number identified. Use -1 as sentinel for "not found" TODO: if we care about speed, we can do a bisection search of the well-ordered {start, end, line} structures

func LocalFileTrees

func LocalFileTrees(
	cmd string,
	switches []string,
	options types.Options,
	langName string,
	canonical bool) (string, []byte, []byte)

func Max

func Max[T constraints.Ordered](a, b T) T

func Min

func Min[T constraints.Ordered](a, b T) T

func RevisionToCurrentTree

func RevisionToCurrentTree(
	filename string,
	cmd string,
	switches []string,
	options types.Options,
	langName string,
	canonical bool) ([]byte, []byte)

func SemanticChanges

func SemanticChanges(
	dmp *diffmatchpatch.DiffMatchPatch,
	diffs []diffmatchpatch.Diff,
	filename string,
	headTree []byte,
	headTreeString string,
	parseType types.ParseType,
	dumbterm bool,
	minimal bool) string

func VerifyHash

func VerifyHash(filename string, digest string) bool

Types

type LineOffset

type LineOffset struct {
	Start uint32
	End   uint32
	Line  string
}

func MakeOffsetsFromByteArray

func MakeOffsetsFromByteArray(text []byte) []LineOffset

We assume that lines are sensibly split on LF, not CR or CRLF Also assume that bytes encode text as UTF-8 not any odd encoding

func MakeOffsetsFromString

func MakeOffsetsFromString(text string) []LineOffset

We assume that lines are sensibly split on LF, not CR or CRLF

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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