# README
Just some random matchers
The package provides a matcher interface to match a given value of any types.
Prerequisites
Go >= 1.17
Install
go get go.nhat.io/matcher/v2
Usage
You could use it in a test or anywhere that needs a value matcher.
package mypackage
import (
"testing"
"go.nhat.io/matcher/v2"
"github.com/stretchr/testify/assert"
)
func TestValue(t *testing.T) {
m := matcher.Exact("foobar")
actual := "FOOBAR"
assert.True(t, m.Match(actual), "got: %s, want: %s", actual, m.Expected())
}
Donation
If this project help you reduce time to develop, you can give me a cup of coffee :)
Paypal donation
or scan this

# Functions
Exact matches two objects by their exact values.
Exactf matches two strings by the formatted expectation.
IsEmpty checks whether the value is empty.
IsNotEmpty checks whether the value is not empty.
JSON matches two json strings with <ignore-diff> support.
Len matches by the length of the value.
Match returns a matcher according to its type.
Regex matches two strings by using regex.
RegexPattern matches two strings by using regex.
# Structs
EmptyMatcher checks whether the value is empty.
ExactMatcher matches by exact string.
JSONMatcher matches by json with <ignore-diff> support.
LenMatcher matches by the length of the value.
NotEmptyMatcher checks whether the value is not empty.
RegexMatcher matches by regex.
# Interfaces
Matcher determines if the actual matches the expectation.
# Type aliases
Callback matches by calling a function.