func expectThat(
	x interface{},
	m oglematchers.Matcher,
	depth int,
	errorParts []interface{}) (passed bool) {
	matcherErr := m.Matches(x)
	if matcherErr == nil {
		passed = true
		return
	}
	var r FailureRecord
	var ok bool
	if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok {
		panic("expectThat: runtime.Caller")
	}
	r.FileName = path.Base(r.FileName)
	relativeClause := ""
	if matcherErr.Error() != "" {
		relativeClause = fmt.Sprintf(", %s", matcherErr.Error())
	}
	r.Error = fmt.Sprintf(
		"Expected: %s\nActual:   %v%s",
		m.Description(),
		x,
		relativeClause)
	if len(errorParts) != 0 {
		v := reflect.ValueOf(errorParts[0])
		if v.Kind() != reflect.String {
			panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind()))
		}
		r.Error = fmt.Sprintf(
			"%s\n%s",
			r.Error,
			fmt.Sprintf(v.String(), errorParts[1:]...))
	}
	AddFailureRecord(r)
	return
}
The generalized form of ExpectThat. depth is the distance on the stack
between the caller's frame and the user's frame. Returns passed iff the
match succeeded.
package ogletest
import (
	"fmt"
	"path"
	"reflect"
	"runtime"
	"github.com/jacobsa/oglematchers"
)
func ExpectThat(
	x interface{},
	m oglematchers.Matcher,
	errorParts ...interface{}) {
	expectThat(x, m, 1, errorParts)
}