A package to encode your structures in URL
ā ļø Make sure that Go is installed on your computer.
$ go get github.com/QuentinPerez/go-encodeUrl
Now, the package is ready to use.
import "github.com/QuentinPerez/go-encodeUrl"
type ID struct {
Name string `url:"name,ifStringIsNotEmpty"`
// ^^ ^^^
// variable name | function
DisplayName string `url:"display-name,ifStringIsNotEmpty"`
}
func main() {
values, errs := encurl.Translate(&ID{"NotEmpty", ""})
if errs != nil {
fmt.Printf("errors %v", errs)
return
}
fmt.Printf("https://example.com/?%v\n", values.Encode()) // https://example.com/?name=NotEmpty
}
ifStringIsNotEmpty
ifBoolIsFalse
ifBoolIsTrue
itoa
itoaIfNotNil
Feel free to contribute šš»