- Notifications
You must be signed in to change notification settings - Fork182
go-querystring is Go library for encoding structs into URL query strings.
License
google/go-querystring
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
go-querystring is a Go library for encoding structs into URL query parameters.
import"github.com/google/go-querystring/query"
go-querystring is designed to assist in scenarios where you want to construct aURL using a struct that represents the URL query parameters. You might do thisto enforce the type safety of your parameters, for example, as is done in thego-github library.
The query package exports a singleValues()
function. A simple example:
typeOptionsstruct {Querystring`url:"q"`ShowAllbool`url:"all"`Pageint`url:"page"`}opt:=Options{"foo",true,2 }v,_:=query.Values(opt)fmt.Print(v.Encode())// will output: "q=foo&all=true&page=2"
See thepackage godocs for complete documentation on supported types andformatting options.
If you are looking for a library that can both encode and decode query strings,you might consider one of these alternatives:
About
go-querystring is Go library for encoding structs into URL query strings.
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.