Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/foxcapades/goop

Options for Go's base types.
https://github.com/foxcapades/goop

Last synced: 5 days ago
JSON representation

Options for Go's base types.

Awesome Lists containing this project

README

        

= Go Options
:source-highlighter: pygments

image:https://www.travis-ci.org/Foxcapades/goop.svg?branch=master["Build Status", link="https://www.travis-ci.org/Foxcapades/goop"]
image:https://img.shields.io/github/v/tag/Foxcapades/goop?label=version[caption="Latest Tag"]
image:https://goreportcard.com/badge/github.com/Foxcapades/goop[caption="Go Report Card", link="https://goreportcard.com/report/github.com/Foxcapades/goop"]
image:https://codecov.io/gh/Foxcapades/goop/branch/master/graph/badge.svg[caption="Coverage Report", link="https://codecov.io/gh/Foxcapades/goop"]
image:https://img.shields.io/github/license/Foxcapades/goop[GitHub]

Option types for Go's basic builtin types.

'''

.cmd/example/main.go
[source,go]
----
func main() {
fmt.Println(option.NewBool(true).
ForceMapToInt(func(b bool) int {
if b {
return 5
}
return 10
}).
ForceMapToString(strconv.Itoa).
ForceMapToUntyped(func(s string) interface{} { return NewTest(s) }).
MapToNillableString(func(t interface{}) *string { return nil }).
Or("15"))
}
----