mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-09 23:22:28 +08:00
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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user