encurl

package module
v0.0.0-...-645a9db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 9 Imported by: 11

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEncodeFunc

func AddEncodeFunc(fnct ...Func) (errs []error)

func PrintAllFunctions

func PrintAllFunctions(out io.Writer)

func Translate

func Translate(obj interface{}, overload ...OverloadFunc) (url.Values, []error)

Types

type Func

type Func func(obj interface{}) (string, bool, error)

type OverloadFunc

type OverloadFunc func(fieldName string, fieldTag reflect.StructTag) (fieldTagOverloaded reflect.StructTag)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL