Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foxcapades/gomp
Ordered maps for Go
https://github.com/foxcapades/gomp
golang golang-library maps ordered typesafety
Last synced: 9 days ago
JSON representation
Ordered maps for Go
- Host: GitHub
- URL: https://github.com/foxcapades/gomp
- Owner: Foxcapades
- License: mit
- Created: 2020-05-24T01:19:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-22T10:09:40.000Z (about 1 year ago)
- Last Synced: 2024-10-17T01:18:55.526Z (20 days ago)
- Topics: golang, golang-library, maps, ordered, typesafety
- Language: Go
- Homepage:
- Size: 815 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.adoc
- License: license
Awesome Lists containing this project
README
= Go Ordered Maps
image:https://travis-ci.org/Foxcapades/gomp.svg?branch=master["Build Status", link="https://travis-ci.org/Foxcapades/gomp"]
image:https://img.shields.io/github/v/tag/Foxcapades/gomp?label=version[Latest Tag, link="https://github.com/Foxcapades/gomp/tags"]
image:https://goreportcard.com/badge/github.com/Foxcapades/gomp[caption="Go Report Card", link="https://goreportcard.com/report/github.com/Foxcapades/gomp"]
image:https://codecov.io/gh/Foxcapades/gomp/branch/master/graph/badge.svg[caption="Unit test coverage", link=https://codecov.io/gh/Foxcapades/gomp]Typed ordered maps for go.
Generated for all of Go's base types. Generator included for adding custom
types..Example
[source, go]
----
func main() {
// Create a new ordered map of interface->interface presized to 10
foo := omap.NewMapAny(10)// Puts hi->bye into the map
foo.Put("hi", "bye").
// Puts nothing into the map (because val is nil)
PutIfNotNil("teeth", nil).
// Appends fire->water to the map because key fire does not yet exist
ReplaceOrPut("fire", "water").
// Replaces the value at key "hi" with "hello"
ReplaceIfExists("hi", "hello").
// Iterates over all entries in the map with the given func
ForEach(func(k, v interface{}) {
fmt.Println(k, v)
})enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
_ = enc.Encode(foo)
}
----.Output
[source, sh-session]
----
$ go run example/main.go
hi hello
fire water
[
{
"key": "hi",
"value": "hello"
},
{
"key": "fire",
"value": "water"
}
]
----== Generator
.Generator Usage
[source, sh-session]
----
./gomp-gen path/to/config.yml
----== About
Gomp?::
Gomp is a Norwegian word for Muggle.