Skip to content

Commit

Permalink
fix set empty tagname
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed May 22, 2024
1 parent 1ef4223 commit ae7027b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions encoding/form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ var (
decoder = form.NewDecoder()
)

// This variable can be replaced with -ldflags like below:
// go build "-ldflags=-X github.com/go-kratos/kratos/v2/encoding/form.tagName=form"
var tagName = "json"
var (
defaultTagName = "json"

// This variable can be replaced with -ldflags like below:
// go build "-ldflags=-X github.com/go-kratos/kratos/v2/encoding/form.tagName=form"
tagName = defaultTagName
)

func init() {
if tagName == "" {
tagName = defaultTagName
}
decoder.SetTagName(tagName)
encoder.SetTagName(tagName)
encoding.RegisterCodec(codec{encoder: encoder, decoder: decoder})
Expand Down

0 comments on commit ae7027b

Please sign in to comment.