goop

module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: MIT

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"))
}
----

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

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