Skip to content

TestClientOptions 中DeepEqual(DelayPolicyFunc)是比较什么 #1162

@lhpqaq

Description

@lhpqaq

Describe the Question

hertz/pkg/app/client/option_test.goTestClientOptions在 go1.22 中不能通过,请问最后一个assert是在比较什么,是比较函数签名还是函数的功能呢?
如果是后者,改成下面这样在 go1.16 中仍然可以通过:

func TestClientOptions(t *testing.T) {
	opt := config.NewClientOptions([]config.ClientOption{
		...
		WithRetryConfig(
			...
			retry.WithDelayPolicy(retry.CombineDelay(retry.FixedDelayPolicy, retry.BackOffDelayPolicy, retry.RandomDelayPolicy)),
		),
		WithWriteTimeout(time.Second),
		WithConnStateObserve(nil, time.Second),
	})

	...
	assert.DeepEqual(t, fmt.Sprint(retry.CombineDelay(retry.RandomDelayPolicy, retry.RandomDelayPolicy, retry.RandomDelayPolicy)), fmt.Sprint(opt.RetryConfig.DelayPolicy))
}

如果是前者,本意是否是fmt.Sprintf("%T", func)呢,我会提交一个PR修改这里。
Reproducible Code

Please construct a minimum complete and reproducible example for us to get the same error. And tell us how to reproduce it like how you send a request or send what request.

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

go1.16
image

go1.22
image

Hertz version:

latest

Environment:

ubuntu go1.16 (在ubuntu的go1.22中同样无法通过)

GO111MODULE=""
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/home/lhp/.cache/go-build"
GOENV="/home/lhp/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/lhp/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/lhp/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/lhp/hertz/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1206607522=/tmp/go-build -gno-record-gcc-switches"

macOS go1.22

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/lhp/Library/Caches/go-build'
GOENV='/Users/lhp/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/lhp/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/lhp/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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/wl/5ch60dzs2j97y3zzqgt6dw240000gn/T/go-build3768073719=/tmp/go-build -gno-record-gcc-switches -fno-common'

Additional context

Add any other context about the question here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions