inertia: Index | Files

package identity

import ""

Package identity provides a small set of utilities for dealing with structs that have an identifier.

Why does this exist? Because, for example, you can't have `Set(v string, ids ...Identifier)` and:

profiles := []*Profile{ ... }
identity.Set(v, profiles...)

With the above code, you get:

cannot use p.Profiles (type []*Profile) as type []identity.Identifier in argument to identity.Set

Even though this works:

profiles := []*Profile{ ... }
identity.Set(v, profiles[0], profiles[1])

tl;dr generics please? :(


Package Files


func Add Uses

func Add(new Identifier, ids *[]Identifier) bool

Add inserts new into given ids

func Get Uses

func Get(k string, ids []Identifier) (interface{}, bool)

Get finds and returns the value and true if k exists in given ids

func Has Uses

func Has(k string, ids []Identifier) bool

Has returns true if k exists in given ids

func Remove Uses

func Remove(k string, ids *[]Identifier) bool

Remove deletes identifier with name k in given ids

func Set Uses

func Set(new Identifier, ids *[]Identifier)

Set updates an existing entry with the same name as k, or just adds it

type Identifier Uses

type Identifier interface{ Identifier() string }

Identifier wraps classes with Identifier()

Package identity is imported by 2 packages. Updated 2021-01-10. Refresh now. Tools for package owners.