Robert Griesemer [Fri, 10 Feb 2012 21:27:32 +0000 (13:27 -0800)]
go/printer: implement SourcePos mode
If a printer is configured with the SourcePos mode
set, it will emit //-line comments as necessary to
ensure that the result - if reparsed - reflects the
original source position information.
This change required a bit of reworking of the
output section in printer.go. Specifically:
- Introduced new Config mode 'SourcePos'.
- Introduced new position 'out' which tracks the
position of the generated output if it were read
in again. If there is a discrepancy between out
and the current AST/source position, a //line
comment is emitted to correct for it.
- Lazy emission of indentation so that //line
comments can be placed correctly. As a result,
the trimmer will have to do less work.
- Merged writeItem into writeString.
- Merged writeByteN into writeByte.
- Use a []byte instead of a byte.Buffer both in the
printer and in the trimmer (eliminates dependency).
Also: introduced explicit printer.Mode type (in
sync w/ parser.Mode, scanner.Mode, etc.)
Runs all tests. Applied gofmt to src, misc w/o changes.
Nigel Tao [Fri, 10 Feb 2012 07:49:19 +0000 (18:49 +1100)]
compress: make flate, gzip and zlib's NewWriterXxx functions all return
(*Writer, error) if they take a compression level, and *Writer otherwise.
Rename gzip's Compressor and Decompressor to Writer and Reader, similar to
flate and zlib.
Clarify commentary when writing gzip metadata that is not representable
as Latin-1, and fix io.EOF comment bug.
Also refactor gzip_test to be more straightforward.
Russ Cox [Fri, 10 Feb 2012 04:46:48 +0000 (23:46 -0500)]
dashboard: add gobuilder -fail mode
This is for filling a column with "fail", like I just did for
Windows, when the builder would get stuck running that
build. (We have safeguards against the tests getting stuck
but this was the bootstrap build getting stuck.)
I usually use -cmd=/bin/false, but this avoids the Mercurial
checkouts, which means it runs instantly instead of requiring
~1 minute per "fail".
Rob Pike [Fri, 10 Feb 2012 03:30:44 +0000 (14:30 +1100)]
unicode: various documentation tweaks
The comment on IsOneOf regarding Latin-1 was an implementation detail:
when the function is called internally, that condition is true. It used to matter,
but now the comment is a dreg. The function works fine if the character is
Latin-1, so we just delete the comment.
Andrew Balholm [Thu, 9 Feb 2012 22:19:22 +0000 (09:19 +1100)]
database/sql: support ErrSkip in Tx.Exec
If the database driver supports the Execer interface but returns
ErrSkip, calling Exec on a transaction was returning the error instead
of using the slow path.
Alex Brainman [Thu, 9 Feb 2012 03:52:01 +0000 (14:52 +1100)]
gobuilder: fix windows builder
Do not rewrite commands if they have .bash extnsion.
Use path/filepath to manipulate file paths everywhere.
Use all.bat on windows, not all.bash.
Use HOMEDRIVE/HOMEPATH to find .gobuildkey on windows.
Rob Pike [Thu, 9 Feb 2012 03:12:18 +0000 (14:12 +1100)]
cmd/go: rearrange help for 'go test'
Put the 'go test' flags into 'go help test', so 'go help testflags'
is about the flags for the compiled test binary.
Russ Cox [Wed, 8 Feb 2012 20:24:48 +0000 (15:24 -0500)]
spec: send on closed channel counts as "proceeding"
Other wordings are possible but defining this as one
of the ways to proceed means we don't have to add
language about this to the description of select.
Fixes #2825.
R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5643062
Robert Griesemer [Wed, 8 Feb 2012 19:41:32 +0000 (11:41 -0800)]
go/scanner: clean up error interface
Issue 2856 asks for a rename of a few methods to a
more idiomatic Go style. This is a very early API
that evolved organically throughout the years.
Together with the fact that ErrorVectors were embedded
in other data structures (e.g. Parser), just renaming
methods (e.g. GetError -> Error) would lead to undesired
behavior (e.g., Parser would act like an Error). Instead,
cleaned up API a bit more:
- removed ErrorVector in favor of ErrorList (already
present)
- simplified Scanner.Init by making the error handler a
function instead of requiring an ErrorHandler implementation
- adjusted helper functions accordingly
- updated Go 1 doc
Paul Borman [Wed, 8 Feb 2012 19:39:16 +0000 (14:39 -0500)]
runtime: drop to 32 bit malloc if 64 bit will not work
On 64 bit UML it is not possible to reserve memory at 0xF8<<32.
Detect when linux cannot use these high virtual memory addresses
and drop back to the 32 bit memory allocator.
Russ Cox [Wed, 8 Feb 2012 15:33:54 +0000 (10:33 -0500)]
runtime, pprof: add profiling of thread creation
Same idea as heap profile: how did each thread get created?
Low memory (256 bytes per OS thread), high reward for
programs that suddenly have many threads running.
Jamie Gennis [Wed, 8 Feb 2012 15:25:13 +0000 (10:25 -0500)]
6g,8g: make constant propagation inlining-friendly.
This changes makes constant propagation compare 'from' values using node
pointers rather than symbol names when checking to see whether a set
operation is redundant. When a function is inlined multiple times in a
calling function its arguments will share symbol names even though the values
are different. Prior to this fix the bug409 test would hit a case with 6g
where an LEAQ instruction was incorrectly eliminated from the second inlined
function call. 8g appears to have had the same bug, but the test did not fail
there.
Andrew Pritchard [Wed, 8 Feb 2012 06:14:15 +0000 (17:14 +1100)]
database/sql: treat pointers as nullable types like encoding/json
- convert from nil pointers to the nil interface{}
- dereference non-nil pointers
- convert from nil interface{}s to nil pointers
- allocate pointers for non-nil interface{}s
- tests for all of the above
Russ Cox [Wed, 8 Feb 2012 04:37:25 +0000 (23:37 -0500)]
time: clean up MarshalJSON, add RFC3339 method
encoding/xml: handle time.Time as recognized type
The long term plan is to define an interface that time.Time
can implement and that encoding/xml can call, but we are
not going to try to define that interface before Go 1.
Instead, special-case time.Time in package xml, because
it is such a fundamental type, as a stop-gap.
The eventual methods will behave this way.
Gustavo Niemeyer [Wed, 8 Feb 2012 03:57:44 +0000 (01:57 -0200)]
encoding/xml: add support for the omitempty flag
This also changes the behavior of attribute marshalling so
that strings and byte slices are marshalled even if empty.
The omitempty flag may be used to obtain the previous behavior.
Rob Pike [Wed, 8 Feb 2012 03:09:20 +0000 (14:09 +1100)]
encoding/binary: hide TotalSize
The function has a bizarre signature: it was the only public function there
that exposed the reflect package. Also, its definition is peculiar and hard to
explain. It doesn't merit being exported.
This is an API change but really, it should never have been exported and
it's certain very few programs will depend on it: it's too weird.
Rob Pike [Wed, 8 Feb 2012 02:07:13 +0000 (13:07 +1100)]
bufio: drop error return for NewReaderSize and NewWriterSize
It complicates the interface unnecessarily.
Document this in go1.html.
Also update the go/doc Makefile.