Skip to content

Reflect package for protobuf values #67169

@Rajan-226

Description

@Rajan-226

Go version

go 1.21

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN='/Users/rajan.sharma/go/bin'
GOCACHE='/Users/rajan.sharma/Library/Caches/go-build'
GOENV='/Users/rajan.sharma/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/rajan.sharma/go/pkg/mod'
GONOPROXY='github.com/razorpay/*'
GONOSUMDB='github.com/razorpay/*'
GOOS='darwin'
GOPATH='/Users/rajan.sharma/go'
GOPRIVATE='github.com/razorpay/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/rajan.sharma/go/src/github.com/razorpay/payments-upi/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/w3/_vyqyy610p934gd5vy_jnygr0000gq/T/go-build1777294655=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I want to compare two structpb.Value using reflect.DeepEqual.

It's giving false if I try to print one of the structpb.Value before comparing them.
https://go.dev/play/p/yedwyZQzAP1

It's working fine if we don't have a print statement before comparing both.
https://go.dev/play/p/x9WhvnjvoPJ

And if we print both structpb.Value, then also code gives equal on comparison.
https://go.dev/play/p/iBB6l8mBXcs

I'm aware proto.Equal is able to compare them regardless of printing. But wanted to understand if this is a bug that after using print statement, code is giving false for comparison.

What did you see happen?

https://go.dev/play/p/yedwyZQzAP1
true
false

What did you expect to see?

https://go.dev/play/p/yedwyZQzAP1
true
true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions