Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

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

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages