identity

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

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? :(

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

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

Add inserts new into given ids

func Get

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

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

func Has

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

Has returns true if k exists in given ids

func Remove

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

Remove deletes identifier with name k in given ids

func Set

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

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

Types

type Identifier

type Identifier interface{ Identifier() string }

Identifier wraps classes with Identifier()

Jump to

Keyboard shortcuts

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