option.go 626 B

1234567891011121314151617181920212223242526272829303132
  1. package option
  2. // Interface defines the minimum interface that an option must fulfill
  3. type Interface interface {
  4. // Ident returns the "indentity" of this option, a unique identifier that
  5. // can be used to differentiate between options
  6. Ident() interface{}
  7. // Value returns the corresponding value.
  8. Value() interface{}
  9. }
  10. type pair struct {
  11. ident interface{}
  12. value interface{}
  13. }
  14. // New creates a new Option
  15. func New(ident, value interface{}) Interface {
  16. return &pair{
  17. ident: ident,
  18. value: value,
  19. }
  20. }
  21. func (p *pair) Ident() interface{} {
  22. return p.ident
  23. }
  24. func (p *pair) Value() interface{} {
  25. return p.value
  26. }