Add StructUtil for provide more rich functions (#79)

* add support json tag attribute for StructToMap function

* add the structutil to provide more rich functions and fixed #77
This commit is contained in:
zm authored and GitHub committed 2023-03-13 19:28:37 +08:00
1 parent 1755dd249b
commit 924589d2da
9 files changed
+263 -64

No files matched your search

+5 -2
View File
@@ -123,14 +123,17 @@ func ExampleHttpClient_DecodeResponse() {
func ExampleStructToUrlValues() {
type TodoQuery struct {
Id int `json:"id"`
Id int `json:"id,omitempty"`
Name string `json:"name"`
}
todoQuery := TodoQuery{
Id: 1,
Name: "Test",
}
todoValues := StructToUrlValues(todoQuery)
todoValues, err := StructToUrlValues(todoQuery)
if err != nil {
return
}
fmt.Println(todoValues.Get("id"))
fmt.Println(todoValues.Get("name"))