Closed akupila closed 7 months ago
Hi @akupila, sorry to hear about your struggle. This is working as intended. The documentation on Diff
says:
Do not depend on this output being stable. If you need the ability to programmatically interpret the difference, consider using a custom Reporter.
The output of Diff
has in the past and will continue to change because it is intended to evolve to be more and more humanly readable. Codifying it's output in something like an example test would mean that the test is brittle and breaks whenever Diff
's output changes again. The instability of the output was done to deliberately make it harder to accidentally assume that the output was stable.
Oh, i didn't notice that in the docs, but it makes sense. Thanks for this, I'll use a custom Reporter 👍
Thanks also for all the work you've put into go-cmp 🙂
I ran into an issue when using
cmp.Diff
output in an example test. The test would sometimes fail, sometimes not. The output looked the same, so it was a bit tricky to find what was happening.Turns out
cmp.Diff
can sometimes prefix the output with a space (0x20
) and sometimes with NBSP (0xC2 0xA0
):I'm not able to make the behavior change when using
-count
, but a subsequent run can produce different values in what appears to be random:Go env
``` $ go env GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/Users/akupila/Library/Caches/go-build' GOENV='/Users/akupila/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/akupila/go/pkg/mod' GONOPROXY='github.com/GetStream' GONOSUMDB='github.com/GetStream' GOOS='darwin' GOPATH='/Users/akupila/go' GOPRIVATE='github.com/GetStream' GOPROXY='https://proxy.golang.org,direct' GOROOT='/nix/store/1fxz1flmv4a4m5pvjmmzxlaznjzybjcp-go-1.21.3/share/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/nix/store/1fxz1flmv4a4m5pvjmmzxlaznjzybjcp-go-1.21.3/share/go/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/akupila/scratch/cmpdiff/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/v9/8tv8ybjx47g9j_gdrfndk8xr0000gn/T/go-build2610279179=/tmp/go-build -gno-record-gcc-switches -fno-common' ```