1
0
mirror of https://github.com/golang/go synced 2024-10-01 13:18:33 -06:00
Commit Graph

94 Commits

Author SHA1 Message Date
Russ Cox
8dce57e169 os: new FileInfo, FileMode types + update tree
R=golang-dev, r, r, gri, bradfitz, iant, iant, nigeltao, n13m3y3r
CC=golang-dev
https://golang.org/cl/5416060
2011-11-30 12:04:16 -05:00
Russ Cox
03823b881c use new time API
R=bradfitz, gri, r, dsymonds
CC=golang-dev
https://golang.org/cl/5390042
2011-11-30 12:01:46 -05:00
Anthony Martin
a6c501e4b1 net, io/ioutil: remove use of os.Time
I had to replace the single use of io/ioutil
in the time package with a bytes.Buffer since
there would've been a dependency cycle.

There are no other uses of os.Time.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5372054
2011-11-11 14:40:41 -05:00
Russ Cox
965845a86d all: sort imports
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5319072
2011-11-02 15:54:16 -04:00
Russ Cox
c2049d2dfe src/pkg/[a-m]*: gofix -r error -force=error
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5322051
2011-11-01 22:04:37 -04:00
Russ Cox
c06cf03f0b io: use error, add EOF, avoid os
R=r, r
CC=golang-dev
https://golang.org/cl/5311068
2011-11-01 21:48:52 -04:00
Russ Cox
9f6d036f33 bufio, io: use rune
ReadRune, WriteRune change signature.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5314043
2011-10-25 22:23:34 -07:00
David Symonds
39493be294 io: rename Copyn to CopyN.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5157045
2011-09-30 13:13:39 -07:00
Brad Fitzpatrick
51b09190ac io/ioutil: add a comment on why devNull is a ReaderFrom
... protects this optimization from future well-meaning
Gophers looking to delete unused code. :)

R=gri
CC=golang-dev
https://golang.org/cl/5165041
2011-09-29 15:35:01 -07:00
Hector Chu
75199664d9 io: add TeeReader
TeeReader is a Reader that writes what it reads.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4953041
2011-08-26 17:08:59 -04:00
Mike Solomon
7911965fe9 io/ioutil: improve performance of ioutil.Discard
Fixes #2084.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4817041
2011-07-20 14:34:49 -07:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Evan Shaw
cf3eeb2984 io.WriteString: if the object has a WriteString method, use it
This avoids allocation when writing to bytes.Buffers and bufio.Writers, for
example.

R=golang-dev, rsc, r, consalus, r
CC=golang-dev
https://golang.org/cl/4625068
2011-06-28 16:10:39 +10:00
Russ Cox
36b5e1d698 io: clarify Read, ReadAt, Copy, Copyn EOF behavior
R=golang-dev, bradfitz, iant, dsymonds, nigeltao, r
CC=golang-dev
https://golang.org/cl/4629062
2011-06-22 19:33:07 -04:00
Robert Griesemer
712fb6dcd3 os.Error API: don't export os.ErrorString, use os.NewError consistently
This is a core API change.

1) gofix misc src
2) Manual adjustments to the following files under src/pkg:
   gob/decode.go
   rpc/client.go
   os/error.go
   io/io.go
   bufio/bufio.go
   http/request.go
   websocket/client.go
as well as:
   src/cmd/gofix/testdata/*.go.in (reverted)
   test/fixedbugs/bug243.go
3) Implemented gofix patch (oserrorstring.go) and test case (oserrorstring_test.go)

Compiles and runs all tests.

R=r, rsc, gri
CC=golang-dev
https://golang.org/cl/4607052
2011-06-22 10:52:47 -07:00
Robert Griesemer
c8ee1b8ebc io/ioutil: fix typo in comment
R=r, r
CC=golang-dev
https://golang.org/cl/4592052
2011-06-10 17:07:22 -07:00
Robert Griesemer
5b1fb9d5c6 io: add ByteScanner, RuneScanner interfaces
R=r, rsc
CC=golang-dev
https://golang.org/cl/4530069
2011-05-26 11:03:52 -07:00
Brad Fitzpatrick
b0f39cc27c io, net, http: sendfile support
Speeds up static fileserver, avoiding kernel/userspace copies.

Numbers: downloading 14 MB AppEngine Go SDK with ab (Apache Bench)
with 5 threads:

Before/after numbers:

CPU:
user    0m3.910s
sys     0m23.650s
->
user    0m0.720s
sys     0m4.890s

Time taken for tests:   8.906 seconds
->
Time taken for tests:   8.545 seconds

Percentage of the requests served within a certain time (ms)
50%     44
66%     45
75%     46
80%     46
90%     48
95%     51
98%     59
99%     71
100     74 (longest request)
->
50%     42
66%     43
75%     43
80%     44
90%     46
95%     57
98%     62
99%     63
100%    64 (longest request)

R=iant, gary.burd, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4543071
2011-05-25 10:15:26 -07:00
Brad Fitzpatrick
ca83cd2c2f http: fix transport bug with zero-length bodies
An optimization in Transport which re-uses TCP
connections early in the case where there is
no response body interacted poorly with
ErrBodyReadAfterClose.  Upon recycling the TCP
connection early we would Close the Response.Body
(in case the user forgot to), but in the case
of a zero-lengthed body, the user's handler might
not have run yet.

This CL makes sure the Transport doesn't try
to Close requests when we're about to immediately
re-use the TCP connection.

This also includes additional tests I wrote
while debugging.

R=rsc, bradfitzgoog
CC=golang-dev
https://golang.org/cl/4529050
2011-05-11 12:11:32 -07:00
Brad Fitzpatrick
9d12307a12 ioutil: add Discard, update tree.
This also removes an unnecessary allocation in
http/transfer.go

R=r, rsc1, r2, adg
CC=golang-dev
https://golang.org/cl/4426066
2011-04-27 15:47:04 -07:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Brad Fitzpatrick
0be2ef3fc4 io: clarify that ReadAt shouldn't move the seek offset
R=r, mkrautz, r2, rsc
CC=golang-dev
https://golang.org/cl/4415041
2011-04-13 11:18:38 -07:00
Robert Hencke
8dc0ba7ae5 io: fixes for Read with n > 0, os.EOF
R=rsc
CC=golang-dev
https://golang.org/cl/4271080
2011-04-08 13:45:56 -04:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Brad Fitzpatrick
3479bb6c12 ioutil: add NopCloser
R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/4278044
2011-03-12 16:05:07 -08:00
Robert Griesemer
478f08a517 io/ioutil: clean-up of ReadAll and ReadFile
Make ReadAll use the same mechanism as ReadFile.

R=r
CC=golang-dev
https://golang.org/cl/4279041
2011-03-10 16:41:54 -08:00
Russ Cox
6d6f3381ff io: reimplement Pipe
No known bugs in the current pipe,
but this one is simpler and easier to
understand.

R=iant
CC=golang-dev
https://golang.org/cl/4252057
2011-03-07 10:37:28 -05:00
Russ Cox
2b4a9603d3 io/ioutil: use filepath.Join, handle trailing / in $TMPDIR
R=niemeyer
CC=golang-dev
https://golang.org/cl/4256057
2011-03-06 21:52:37 -05:00
Gustavo Niemeyer
04ca4f8242 path/filepath: new OS-specific path support
The path package now contains only functions which
deal with slashed paths, sensible for any OS when dealing
with network paths or URLs.  OS-specific functionality
has been moved into the new path/filepath package.

This also includes fixes for godoc, goinstall and other
packages which were mixing slashed and OS-specific paths.

R=rsc, gri, mattn, brainman
CC=golang-dev
https://golang.org/cl/4252044
2011-03-06 17:33:23 -05:00
Russ Cox
9ebe384b71 io/ioutil: add TempDir
It's a little confusing that os.TempDir and ioutil.TempDir have
different meanings.  I don't know what to change the names to,
if anything.  At least they also have different signatures.

R=golang-dev, bradfitzgo, r, gri
CC=golang-dev
https://golang.org/cl/4247051
2011-03-03 14:51:49 -05:00
Robert Griesemer
827e98d4fd io: rename interfaces
ReadByter -> ByteReader
ReadRuner -> RuneReader

R=r, r2, rsc
CC=golang-dev
https://golang.org/cl/4023062
2011-02-02 13:42:15 -08:00
Rob Pike
622d729b86 io: add ReadRuner
Put it in the same package as ReadByter.
There is no implementation here for either interface.

R=rsc
CC=golang-dev
https://golang.org/cl/4121051
2011-02-01 21:09:33 -08:00
Russ Cox
0f26608ebc io: fix Copyn EOF handling
Fixes #1383.

R=r
CC=golang-dev
https://golang.org/cl/3821044
2011-01-05 14:35:13 -05:00
Anschel Schaffer-Cohen
84fc1e20f1 Fix documentation typo.
This is really insignificant, but it might as well be fixed.

R=golang-dev, brainman
CC=golang-dev
https://golang.org/cl/3832045
2010-12-31 10:37:55 +11:00
Christopher Wedgwood
6101788972 io: use SetFinalizer more elegantly in Pipe
(this works now that issue 751 is resolved)

R=rsc
CC=golang-dev
https://golang.org/cl/2834041
2010-11-05 15:05:39 -04:00
Rob Pike
4e9cc085d2 testing: eliminate testing/regexp
Rather than updating the stripped-down regexp implementation embedded
in testing, delete it by passing the one function we need from the package
main file created by gotest.

R=rsc
CC=golang-dev
https://golang.org/cl/2761043
2010-10-28 16:54:24 -07:00
Robert Griesemer
3478891d12 gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
2010-10-22 10:06:33 -07:00
Russ Cox
f3549d8323 io/ioutil: use _test not _obj in test
Fixes: make clean; make test

R=gri
CC=golang-dev
https://golang.org/cl/2234044
2010-09-23 14:31:44 -04:00
Rob Pike
1959c3ac5b tests: fix prints
- delete unnecessary newlines
- make sure formatted prints call the formatting routines

R=adg
CC=golang-dev
https://golang.org/cl/2225046
2010-09-23 13:48:56 +10:00
Andrew Gerrand
4642708984 io: prevent ReadAtLeast spinloop if min > len(buf)
R=r, heresy.mc
CC=golang-dev
https://golang.org/cl/2017042
2010-08-23 12:04:15 +10:00
Russ Cox
da392d9136 build: no required environment variables
R=adg, r, PeterGo
CC=golang-dev
https://golang.org/cl/1942044
2010-08-18 10:08:49 -04:00
Rob Pike
e45b58fe96 os: change the type of permissions argument for Open etc. to uint32.
Besides being more correct, it protects against people accidentally
exchanging the permission and open mode arguments to Open.

R=rsc
CC=golang-dev
https://golang.org/cl/1904045
2010-08-04 08:34:52 +10:00
Rob Pike
3f5966dcc0 io: consolidate multi_reader and multi_writer into a single file, multi.go
R=rsc
CC=golang-dev
https://golang.org/cl/1860046
2010-08-03 08:04:33 +10:00
Brad Fitzpatrick
719cde2c47 io: MultiReader and MultiWriter
Little helpers I've found useful.

R=adg, rsc, r, gri
CC=golang-dev
https://golang.org/cl/1764043
2010-07-28 11:30:00 -07:00
Ian Lance Taylor
9a2f0029bc io: Avoid another race condition in pipes.
Goroutine 1:
  Call Read on read half of pipe, entering pipeHalf.rw.
  Check ioclosed field, which is false.
  Send data to p.c1
  Wait for response on p.c2.

Goroutine 2:
  Call Close on read half of pipe, entering pipeHalf.close.
  Set closed field.
  Send error to p.cclose.
  Set ioclosed field.
  Send 1 to p.done.
  Return and exit goroutine.

Goroutine 3:
  This is the goroutine running pipe.run, and for some reason
  it has started late.
  Read error from p.rclose; set rerr and continue.
  Read 1 from p.done; increment ndone and continue.
  Read data from r1 (sent by goroutine 1); set r1 = nil and continue

Now goroutine 1 is waiting for a response, and goroutine 3 is
waiting for something else to happen.

This patch fixes the race by having the runner check whether
the read half is closed when it is asked for read data, and
similarly for the corresponding race on the write half.

This patch also fixes the similar race in which ndone gets
bumped up to 2 while there is a reader or writer waiting.

There is still another race to fix.  It is possible for the
read half and the write half to both be closed, and for the
runner goroutine to exit, all before the runner goroutine sees
the request from a reader.  E.g., in the above, have goroutine
2 also close the write half, and have goroutine 3 see both
done messages before it sees the request from goroutine 1.

R=rsc
CC=golang-dev
https://golang.org/cl/1862045
2010-07-21 10:57:46 -07:00
Peter Mundy
56b3e5d644 io: fix SectionReader Seek to seek backwards
Fixes #899.

R=golang-dev, rminnich, adg
CC=golang-dev
https://golang.org/cl/1749041
2010-07-08 16:57:07 +10:00
Peter Mundy
0e25775518 io/ioutil.TempFile for Windows
Fixes #834.

R=rsc, brainman
CC=golang-dev
https://golang.org/cl/1686047
2010-06-30 13:52:34 -07:00
Ian Lance Taylor
7c1be45f58 io: Avoid race condition in pipe.
One goroutine started up and was waiting in rw.  Then another
goroutine decided to close the pipe.  The closing goroutine
stalled calling p.io.Lock() in pipeHalf.close.  (This happened
in gccgo).  If the closing goroutine had been able to set the
ioclosed flag, it would have gone on to tell the runner that
the pipe was closed, which would then send an EINVAL to the
goroutine sleeping in rw.  Unlocking p.io before sleeping in
rw avoids the race.

R=rsc, rsc1
CC=golang-dev
https://golang.org/cl/1682048
2010-06-30 13:14:46 -07:00
Russ Cox
28852c1531 io/ioutil: add TempFile
R=r
CC=golang-dev
https://golang.org/cl/1472042
2010-06-03 16:29:34 -07:00
Russ Cox
cc62bed075 pipe: implementation #3; this time for sure!
Added goroutine; got simpler.

Fixes deadlock when doing Read+Close
or Write+Close on same end.

R=r, cw
CC=golang-dev
https://golang.org/cl/994043
2010-04-27 10:17:17 -07:00