attr

package
v0.0.0-...-a380f54 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: BSD-2-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package attr defines types and helpers for accessing typed attributes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

type Getter interface {
	GetInt(string) int
	GetString(string) string
	GetStrings(string) []string
}

Getter is an interface which is implemented by types which want to export typed values.

type Interface

type Interface interface {
	// Name returns the name of the attribute.
	Name() string

	// IsEmpty returns true iff `x` is a representation of the empty value of this attribute.
	IsEmpty(x interface{}) bool

	// Value returns the value of this attribute in `g`.
	Value(g Getter) interface{}

	// Intersect returns the intersection of `x` and `y`, assumed to be the type of the
	// attribute.
	Intersect(x, y interface{}) interface{}
}

Interface is a type which defines behaviour necessary to implement a typed attribute.

func Int

func Int(f string) Interface

Int constructs an implementation of Interface with the field name `f` to access an int attribute of an implementation of Getter.

func String

func String(f string) Interface

String constructs an implementation of Interface with the field name `f` to access a string attribute of an implementation of Getter.

func Strings

func Strings(f string) Interface

Strings constructs an implementation of Interface with the field name `f` to access a string slice attribute of an implementation of Getter.

Jump to

Keyboard shortcuts

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