An open API service indexing awesome lists of open source software.

https://github.com/shomali11/proper

A string map decorator
https://github.com/shomali11/proper

map parameter parameters properties property string

Last synced: 5 months ago
JSON representation

A string map decorator

Awesome Lists containing this project

README

          

# proper [![Build Status](https://travis-ci.com/shomali11/proper.svg?branch=master)](https://travis-ci.com/shomali11/proper) [![Go Report Card](https://goreportcard.com/badge/github.com/shomali11/proper)](https://goreportcard.com/report/github.com/shomali11/proper) [![GoDoc](https://godoc.org/github.com/shomali11/proper?status.svg)](https://godoc.org/github.com/shomali11/proper) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A `map[string]string` decorator offering a collection of helpful functions to extract the values in different types

## Features

* 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

# Examples

```go
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
}
```