• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

query/H11-Jan-2017-

.gitignoreH A D11-Jan-20177

CONTRIBUTING.mdH A D11-Jan-20173.1 KiB

LICENSEH A D11-Jan-20171.4 KiB

README.mdH A D11-Jan-20171.2 KiB

README.md

1# go-querystring #
2
3go-querystring is Go library for encoding structs into URL query parameters.
4
5
6**Documentation:** <http://godoc.org/github.com/google/go-querystring/query>
7**Build Status:** [![Build Status](https://drone.io/github.com/google/go-querystring/status.png)](https://drone.io/github.com/google/go-querystring/latest)
8
9## Usage ##
10
11```go
12import "github.com/google/go-querystring/query"
13```
14
15go-querystring is designed to assist in scenarios where you want to construct a
16URL using a struct that represents the URL query parameters.  You might do this
17to enforce the type safety of your parameters, for example, as is done in the
18[go-github][] library.
19
20The query package exports a single `Values()` function.  A simple example:
21
22```go
23type Options struct {
24  Query   string `url:"q"`
25  ShowAll bool   `url:"all"`
26  Page    int    `url:"page"`
27}
28
29opt := Options{ "foo", true, 2 }
30v, _ := query.Values(opt)
31fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2"
32```
33
34[go-github]: https://github.com/google/go-github/commit/994f6f8405f052a117d2d0b500054341048fbb08
35
36## License ##
37
38This library is distributed under the BSD-style license found in the [LICENSE](./LICENSE)
39file.
40