objDict

package module
v0.0.0-...-fb86327 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 7 Imported by: 0

README

go-obj-map

A map indexed with object but not string. A toy project that cannot be used for industry.

A map index could be a normal struct like:

type someStruct struct {
	// ... `objmap:"ignore"`
}

Struct name and type are considered for comparison of equality.

By default, struct instance of "different struct type" and "same struct type with different values" are both considered different.

objk = someStruct{...}

d := objmap.New()
d.Set(objk, v)

if v1, ok := d.Get(objk); ok {
	fmt.Println(v)
	fmt.Println(v1.(someStruct))
}

You may add tags to configure the equality judgement for different objects. For now, only "ignoring" some fields are permitted.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjDict

type ObjDict struct {
	cache.Cache
}

func New

func New(expire time.Duration) ObjDict

func (ObjDict) Get

func (o ObjDict) Get(k objIndex) (interface{}, bool)

func (ObjDict) Set

func (o ObjDict) Set(k objIndex, v interface{})

Jump to

Keyboard shortcuts

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