github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/io/ioutil/blackhole.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ioutil
     6  
     7  var blackHoleBuf = make(chan []byte, 1)
     8  
     9  func blackHole() []byte {
    10  	select {
    11  	case b := <-blackHoleBuf:
    12  		return b
    13  	default:
    14  	}
    15  	return make([]byte, 8192)
    16  }
    17  
    18  func blackHolePut(p []byte) {
    19  	select {
    20  	case blackHoleBuf <- p:
    21  	default:
    22  	}
    23  }