gomp

module
v1.3.5-0...-7564f37 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT

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.

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

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