google/go-querystring

GitHub: google/go-querystring

一个轻量级 Go 库,通过结构体标签将 Go 结构体类型安全地编码为 URL 查询字符串。

Stars: 2144 | Forks: 189

# go-querystring [![Go 参考](https://pkg.go.dev/badge/github.com/google/go-querystring/query.svg)](https://pkg.go.dev/github.com/google/go-querystring/query) [![测试状态](https://static.pigsec.cn/wp-content/uploads/repos/cas/6b/6b52945adbf8d9e421fe243515ae54cfbd3da263f16b1eabda37cdc0b797b8eb.svg)](https://github.com/google/go-querystring/actions?query=workflow%3Atests) [![测试覆盖率](https://codecov.io/gh/google/go-querystring/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-querystring) go-querystring 是一个用于将 struct 编码为 URL 查询参数的 Go 库。 ## 用法 ``` import "github.com/google/go-querystring/query" ``` go-querystring 旨在帮助您在使用代表 URL 查询参数的 struct 构建 URL 时提供便利。例如,您可以这样做来强制执行参数的类型安全,就像在 [go-github][] 库中所做的那样。 query 包导出了一个单独的 `Values()` 函数。一个简单的示例: ``` type Options struct { Query string `url:"q"` ShowAll bool `url:"all"` Page int `url:"page"` } opt := Options{ "foo", true, 2 } v, _ := query.Values(opt) fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" ``` 有关支持的类型和格式化选项的完整文档,请参阅 [package godocs][]。 ## 替代方案 如果您正在寻找一个既能编码又能解码查询字符串的库,您可以考虑以下替代方案: - https://github.com/gorilla/schema - https://github.com/pasztorpisti/qs - https://github.com/hetiansu5/urlquery - https://github.com/ggicci/httpin(仅解码)
标签:EVTX分析, Go, Ruby工具, SOC Prime, Syscall, URL处理, Web开发, 序列化, 开发工具, 日志审计