package ztest
import "zgo.at/zvalidate/internal/ztest"
Index ¶
- func Diff(have, want string, opt ...DiffOpt) string
- func DiffMatch(have, want string, opt ...DiffOpt) string
- type DiffOpt
Functions ¶
func Diff ¶
Diff two strings and format as a unified diff.
func DiffMatch ¶
DiffMatch formats a unified diff, but accepts various patterns in the want string:
%(YEAR) current year in UTC %(MONTH) current month in UTC %(DAY) current day in UTC %(UUID) UUID format (any version). %(ANY) any text: .+? %(ANY 5) any text of exactly 5 characters: .{5}? %(ANY 5,) any text of at least 5 characters: .{5,}? %(ANY 5,10) any text between 5 and 10 characters: .{5,10}? %(ANY 10) any text at most 10 characters: .{,10}? %(NUMBER) any number; also allows length like ANY. %(..) any regular expression, but \ is not allowed.
Types ¶
type DiffOpt ¶
type DiffOpt int
const ( // Normalize whitespace: remove all whitespace at the start and end of every // line. DiffNormalizeWhitespace DiffOpt = iota + 1 // Treat arguments are JSON: format them before diffing. DiffJSON // Instead of using "-" and "+" before every line use "- have" and "+want", // which is a bit clearer. DiffVerbose )
Source Files ¶
diff.go
- Version
- v0.0.0-20241009015312-efd45e4f063d (latest)
- Published
- Oct 9, 2024
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 3 weeks ago –
Tools for package owners.