summaryrefslogtreecommitdiff
path: root/src/pkg/io/ioutil/blackhole.go
blob: 101d2c12153e6538bd33c3dea8fd65497d6a502c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ioutil

var blackHoleBuf = make(chan []byte, 1)

func blackHole() []byte {
	select {
	case b := <-blackHoleBuf:
		return b
	default:
	}
	return make([]byte, 8192)
}

func blackHolePut(p []byte) {
	select {
	case blackHoleBuf <- p:
	default:
	}
}