Skip to content

kasegao/go-orderedmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ordered Map for golang

Python's OrderedDict for Golang.

Install

go install github.com/kasegao/go-orderedmap@latest

Examples

package main

import (
	"fmt"

	omap "github.com/kasegao/go-orderedmap"
)

func main() {
	om := omap.New[string, string]()

	om.Set("a", "foo")
	om.Set("b", "bar")
	om.Set("c", "baz")

	if v, ok := om.Get("a"); ok {
		fmt.Println(v) // print "foo"
	}

	if e, ok := om.GetAt(1); ok {
		fmt.Println(e.Key, e.Value) // print "bar"
	}

	om.DeleteAt(-1) // delete "c:baz"
	if _, ok := om.Get("c"); !ok {
		fmt.Println("not found") // print "not found"
	}

	fmt.Println(om) // print "OrderedMap[a:foo b:bar]"
}

About

Python's OrderedDict for Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages