import (
"fmt"
"log"
"net/url"
"github.com/vingarcia/urlvaluescanner"
)
func main() {
uv := url.Values{
"name": []string{"some name"},
"type": []string{"type1", "type2"},
"age": []string{"42"},
}
var dto struct {
Name string `schema:"name"`
Types []string `schema:"type,required"`
Age int `schema:"age"`
}
err := urlvaluescanner.Unmarshal(uv, &dto)
if err != nil {
log.Fatalf("error decoding url values: %s", err)
}
fmt.Printf("%+v\n", dto) // {Name:some name Types:[type1 type2] Age:42}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
VinGarcia/urlvaluescanner
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published