github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vars/blackhole.go (about)

     1  package vars
     2  
     3  type blackhole struct{}
     4  
     5  func (blackhole) Set(interface{}) error {
     6  	return nil
     7  }
     8  
     9  func (blackhole) Get() interface{} {
    10  	// TODO: Return a special placeholder value.
    11  	return ""
    12  }
    13  
    14  // NewBlackhole returns a blackhole variable. Assignments to a blackhole
    15  // variable will be discarded, and getting a blackhole variable always returns
    16  // an empty string.
    17  func NewBlackhole() Var {
    18  	return blackhole{}
    19  }
    20  
    21  // IsBlackhole returns whether the variable is a blackhole variable.
    22  func IsBlackhole(v Var) bool {
    23  	_, ok := v.(blackhole)
    24  	return ok
    25  }