Skip to content
/ urlconv Public

Small helper for mapping url.Values into a struct.

License

Notifications You must be signed in to change notification settings

Job79/urlconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package urlconv is a small helper that maps url.Values into a given struct.

Example:

type MyStruct struct {
	Name string `url:"name"`
	Age  int    `url:"age"`
}

values := url.Values{
	"name": []string{"John"},
	"age":  []string{"42"},
}

var s MyStruct
urlconv.Unmarshal(values, &s)
fmt.Println(s.Name, s.Age)
// Output: John 42

The struct tag "url" is used to map the url.Values to the struct and is required. Only public structs and fields can be mapped.

The following types are supported:

  • string
  • int
  • float64
  • []string
  • bool
  • time.Time

About

Small helper for mapping url.Values into a struct.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages