go/src/net
Brad Fitzpatrick ee2ecc4552 bufio: add Reader.Discard
Reader.Discard is the complement to Peek. It discards the next n bytes
of input.

We already have Reader.Buffered to see how many bytes of data are
sitting available in memory, and Reader.Peek to get that that buffer
directly. But once you're done with the Peek'd data, you can't get rid
of it, other than Reading it.
Both Read and io.CopyN(ioutil.Discard, bufReader, N) are relatively
slow. People instead resort to multiple blind ReadByte calls, just to
advance the internal b.r variable.

I've wanted this previously, several people have asked for it in the
past on golang-nuts/dev, and somebody just asked me for it again in a
private email. There are a few places in the standard library we'd use
it too.

Change-Id: I85dfad47704a58bd42f6867adbc9e4e1792bc3b0
Reviewed-on: https://go-review.googlesource.com/2260
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 06:37:57 +00:00
..
http bufio: add Reader.Discard 2015-01-07 06:37:57 +00:00
mail net/mail: allow us-ascii encoding 2014-09-16 17:40:33 -04:00
rpc net/rpc: fix mutex comment 2014-10-13 10:27:51 -07:00
smtp net/smtp: add TLSConnectionState accessor 2014-12-28 21:35:58 +00:00
testdata
textproto net/textproto: turn an ancient DoS BUG annotation into a comment 2014-12-16 04:17:30 +00:00
url net/url: add example of using URL.Opaque with http.Request 2014-11-12 14:27:27 -08:00
cgo_android.go
cgo_bsd.go
cgo_linux.go
cgo_netbsd.go
cgo_openbsd.go
cgo_stub.go
cgo_unix.go
cgo_unix_test.go
conn_test.go
dial.go
dial_gen.go
dial_gen_test.go
dial_test.go net: disable TestDialMultiFDLeak 2014-09-18 14:48:26 -04:00
dialgoogle_test.go
dnsclient.go
dnsclient_test.go
dnsclient_unix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
dnsclient_unix_test.go
dnsconfig_unix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
dnsconfig_unix_test.go
dnsmsg.go
dnsmsg_test.go
dnsname_test.go
example_test.go
fd_mutex.go
fd_mutex_test.go
fd_plan9.go
fd_poll_nacl.go
fd_poll_runtime.go
fd_posix.go net: don't return io.EOF on reading data from datagram, raw sockets on windows 2015-01-01 05:21:32 +00:00
fd_posix_test.go net: don't return io.EOF on reading data from datagram, raw sockets on windows 2015-01-01 05:21:32 +00:00
fd_unix.go net: don't return io.EOF on reading data from datagram, raw sockets on windows 2015-01-01 05:21:32 +00:00
fd_windows.go net: don't return io.EOF on reading data from datagram, raw sockets on windows 2015-01-01 05:21:32 +00:00
file_plan9.go
file_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
file_test.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
file_unix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
file_windows.go
hosts.go
hosts_test.go
interface.go
interface_bsd.go
interface_bsd_test.go
interface_darwin.go
interface_dragonfly.go
interface_freebsd.go
interface_linux.go
interface_linux_test.go
interface_netbsd.go
interface_openbsd.go
interface_stub.go
interface_test.go
interface_unix_test.go
interface_windows.go
ip.go
ip_test.go net: add test cases for parsing ipv4-mapped ipv6 address 2015-01-04 10:28:00 +00:00
ipraw_test.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
iprawsock.go
iprawsock_plan9.go
iprawsock_posix.go
ipsock.go
ipsock_plan9.go
ipsock_posix.go
ipsock_test.go
lookup.go net: if a DNS lookup times out, forget that it is in flight 2014-10-27 08:46:18 -07:00
lookup_plan9.go
lookup_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
lookup_test.go net: remove redundant test case for lookupIP with threadLimit 2015-01-01 05:20:16 +00:00
lookup_unix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
lookup_windows.go
lookup_windows_test.go
mac.go
mac_test.go
mockicmp_test.go
mockserver_test.go
multicast_test.go
net.go net: fix misleading package comment example 2014-09-29 12:24:06 -07:00
net_test.go
net_windows_test.go
netgo_unix_test.go
packetconn_test.go
parse.go
parse_test.go
pipe.go
pipe_test.go
port.go
port_test.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
port_unix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
protoconn_test.go
race.go
race0.go
sendfile_dragonfly.go
sendfile_freebsd.go
sendfile_linux.go
sendfile_stub.go
sendfile_windows.go
server_test.go
singleflight.go net: if a DNS lookup times out, forget that it is in flight 2014-10-27 08:46:18 -07:00
sock_bsd.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sock_cloexec.go
sock_linux.go
sock_plan9.go
sock_posix.go
sock_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sock_windows.go
sockopt_bsd.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockopt_linux.go
sockopt_plan9.go
sockopt_posix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockopt_solaris.go
sockopt_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockopt_windows.go
sockoptip_bsd.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockoptip_linux.go
sockoptip_posix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockoptip_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
sockoptip_windows.go
sys_cloexec.go
tcp_test.go
tcpsock.go
tcpsock_plan9.go
tcpsock_posix.go
tcpsockopt_darwin.go net: fix inconsistent behavior across platforms in SetKeepAlivePeriod 2014-09-11 17:56:58 +09:00
tcpsockopt_dragonfly.go net: fix inconsistent behavior across platforms in SetKeepAlivePeriod 2014-09-11 17:56:58 +09:00
tcpsockopt_openbsd.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
tcpsockopt_plan9.go
tcpsockopt_posix.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
tcpsockopt_stub.go net: separate NaCl dependent placeholders from BSD's 2014-09-18 19:17:55 +09:00
tcpsockopt_unix.go net: fix inconsistent behavior across platforms in SetKeepAlivePeriod 2014-09-11 17:56:58 +09:00
tcpsockopt_windows.go net: fix inconsistent behavior across platforms in SetKeepAlivePeriod 2014-09-11 17:56:58 +09:00
timeout_test.go
udp_test.go net: link skipped TestReadFromUDP to the issue 2014-10-10 13:12:32 +11:00
udpsock.go
udpsock_plan9.go
udpsock_posix.go
unicast_posix_test.go net: disable TestDualStackUDPListener in short mode 2014-10-06 13:09:14 -04:00
unix_test.go
unixsock.go
unixsock_plan9.go
unixsock_posix.go