...

Source file src/github.com/lestrrat-go/option/option.go

Documentation: github.com/lestrrat-go/option

     1  package option
     2  
     3  import "fmt"
     4  
     5  // Interface defines the minimum interface that an option must fulfill
     6  type Interface interface {
     7  	// Ident returns the "identity" of this option, a unique identifier that
     8  	// can be used to differentiate between options
     9  	Ident() interface{}
    10  
    11  	// Value returns the corresponding value.
    12  	Value() interface{}
    13  }
    14  
    15  type pair struct {
    16  	ident interface{}
    17  	value interface{}
    18  }
    19  
    20  // New creates a new Option
    21  func New(ident, value interface{}) Interface {
    22  	return &pair{
    23  		ident: ident,
    24  		value: value,
    25  	}
    26  }
    27  
    28  func (p *pair) Ident() interface{} {
    29  	return p.ident
    30  }
    31  
    32  func (p *pair) Value() interface{} {
    33  	return p.value
    34  }
    35  
    36  func (p *pair) String() string {
    37  	return fmt.Sprintf(`%v(%v)`, p.ident, p.value)
    38  }
    39  

View as plain text