Documentation

Overview

    Package opt provides common go-cmp.Options for use with assert.DeepEqual.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func DurationWithThreshold

    func DurationWithThreshold(threshold time.Duration) gocmp.Option

      DurationWithThreshold returns a gocmp.Comparer for comparing time.Duration. The Comparer returns true if the difference between the two Duration values is within the threshold and neither value is zero.

      func PathDebug

      func PathDebug(path gocmp.Path) bool

        PathDebug is a gocmp.FilerPath filter that always returns false. It prints each path it receives. It can be used to debug path matching problems.

        func PathField

        func PathField(structType interface{}, field string) func(gocmp.Path) bool

          PathField is a gocmp.FilerPath filter that matches a struct field by name. PathField will match every instance of the field in a recursive or nested structure.

          func PathString

          func PathString(specs ...string) func(path gocmp.Path) bool

            PathString is a gocmp.FilterPath filter that returns true when path.String() matches any of the specs.

            The path spec is a dot separated string where each segment is a field name. Slices, Arrays, and Maps are always matched against every element in the sequence. gocmp.Indirect, gocmp.Transform, and gocmp.TypeAssertion are always ignored.

            Note: this path filter is not type safe. Incorrect paths will be silently ignored. Consider using a type safe path filter for more complex paths.

            func TimeWithThreshold

            func TimeWithThreshold(threshold time.Duration) gocmp.Option

              TimeWithThreshold returns a gocmp.Comparer for comparing time.Time. The Comparer returns true if the difference between the two Time values is within the threshold and neither value is zero.

              Types

              This section is empty.

              Source Files