2018-02-15 16:59:49 +08:00
|
|
|
package vars
|
2018-01-05 06:54:04 +08:00
|
|
|
|
|
|
|
type blackhole struct{}
|
|
|
|
|
2022-03-20 23:50:25 +08:00
|
|
|
func (blackhole) Set(any) error {
|
2018-01-05 06:54:04 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-20 23:50:25 +08:00
|
|
|
func (blackhole) Get() any {
|
2019-04-20 02:44:11 +08:00
|
|
|
return nil
|
2018-01-05 06:54:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewBlackhole returns a blackhole variable. Assignments to a blackhole
|
|
|
|
// variable will be discarded, and getting a blackhole variable always returns
|
2020-09-05 05:45:04 +08:00
|
|
|
// nil.
|
2018-03-08 21:20:31 +08:00
|
|
|
func NewBlackhole() Var {
|
2018-01-05 06:54:04 +08:00
|
|
|
return blackhole{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsBlackhole returns whether the variable is a blackhole variable.
|
2018-03-08 21:20:31 +08:00
|
|
|
func IsBlackhole(v Var) bool {
|
2018-01-05 06:54:04 +08:00
|
|
|
_, ok := v.(blackhole)
|
|
|
|
return ok
|
|
|
|
}
|