A map[string]string
decorator offering a collection of helpful functions to extract the values in different types
- Retrieve data from a string map, in String, Integer, Float and Boolean types.
- Return a default value in case of missing keys or invalid types
package main
import (
"fmt"
"github.com/shomali11/proper"
)
func main() {
parameters := make(map[string]string)
parameters["boolean"] = "true"
parameters["float"] = "1.2"
parameters["integer"] = "11"
parameters["string"] = "value"
properties := proper.NewProperties(parameters)
fmt.Println(properties.BooleanParam("boolean", false)) // true
fmt.Println(properties.FloatParam("float", 0)) // 1.2
fmt.Println(properties.IntegerParam("integer", 0)) // 11
fmt.Println(properties.StringParam("string", "")) // value
}