是否有针对Go的MarshallUrlQuery的实现?

是否有针对Go的MarshallUrlQuery的实现?,go,marshalling,Go,Marshalling,给定这样的Go结构: type Color struct { Red int32 `url:"red"` Green int32 `url:"green"` Blue int32 `url:"blue"` Alpha int32 `url:"alpha,omitempty"` } 如果能够将其转换为URL查询,那就太好了,如: c := Color{ Red: 25

给定这样的Go结构:

type Color struct {
    Red   int32 `url:"red"`
    Green int32 `url:"green"`
    Blue  int32 `url:"blue"`
    Alpha int32 `url:"alpha,omitempty"`
}
如果能够将其转换为URL查询,那就太好了,如:

c := Color{
    Red:   255,
    Green: 127,
}

v, err := MarshalURLQuery(c)

fmt.Printf("%s", string(b))
其中v是一个
url.Values
实例,产生“
red=255&green=127&blue=0
”。Go肯定已经提供了类似的服务。如何在不重新发明轮子的情况下在Go中执行此操作?

是,使用
编码器:

主程序包
进口(
“fmt”
“日志”
“网络/网址”
“github.com/gorilla/schema”
)
类型Person结构{
名称字符串`schema:“名称”`
Lastname字符串`schema:“Lastname”`
}
func main(){
person:=&person{Name:“John”,Lastname:“Doe”}
编码器:=schema.NewEncoder()
v2:=url.Values{}
如果错误:=encoder.Encode(person,v2);错误!=nil{
log.Fatal(错误)
}
fmt.Println(v2.Encode())
}
输出:

lastname=Doe&name=John

我按要求编辑了问题。是否有一个申请审查的流程,以便重新提出问题?