【Gin-v1.9.0源码阅读】deprecated.go

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
    "log"

    "github.com/gin-gonic/gin/binding"
)

// BindWith binds the passed struct pointer using the specified binding engine.
// BindWith使用指定的绑定引擎绑定传递的结构指针。
// See the binding package.
// 请参阅binding包。
func (c *Context) BindWith(obj any, b binding.Binding) error {
    // BindWith(\“interface{},binding.binding\”)错误将被弃用,请检查问题#662,
    // 如果您希望在发生任何错误时自动返回HTTP 400,请使用MustBindWith),或者如果您需要管理错误,请使用ShouldBindWith。
    log.Println(`BindWith(\"interface{}, binding.Binding\") error is going to
    be deprecated, please check issue #662 and either use MustBindWith() if you
    want HTTP 400 to be automatically returned if any error occur, or use
    ShouldBindWith() if you need to manage the error.`)
    return c.MustBindWith(obj, b)
}

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/129776063
今日推荐