Overview
A package to encode your structures in URL
Installation
⚠ Make sure that Go is installed on your computer.
$ go get github.com/QuentinPerez/go-encodeUrl
Now, the package is ready to use.
Examples
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
}
Functions
ifStringIsNotEmpty
ifBoolIsFalse
ifBoolIsTrue
itoa
itoaIfNotNil
Development
Feel free to contribute 😃🍻
License
MIT