Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/foxcapades/goop
- Owner: Foxcapades
- License: mit
- Created: 2020-05-17T16:14:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T10:01:19.000Z (about 3 years ago)
- Last Synced: 2024-10-17T01:19:08.142Z (20 days ago)
- Language: Go
- Size: 183 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.adoc
- License: license
Awesome Lists containing this project
README
= Go Options
:source-highlighter: pygmentsimage: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"))
}
----