Russ Cox [Wed, 29 Feb 2012 21:37:40 +0000 (16:37 -0500)]
path/filepath: steer people away from HasPrefix
The strikes against it are:
1. It does not take path boundaries into account.
2. It assumes that Windows==case-insensitive file system
and non-Windows==case-sensitive file system, neither of
which is always true.
3. Comparing ToLower against ToLower is not a correct
implementation of a case-insensitive string comparison.
4. If it returns true on Windows you still don't know how long
the matching prefix is in bytes, so you can't compute what
the suffix is.
R=golang-dev, r, dsymonds, r
CC=golang-dev
https://golang.org/cl/5712045
Brad Fitzpatrick [Wed, 29 Feb 2012 21:14:05 +0000 (13:14 -0800)]
time: skip a often-flaky test in short mode
In -test.short mode, skip measuring the upper bound of time
sleeps. The API only guarantees minimum bounds on sleeps,
anyway, so this isn't a bug we're ignoring as much as it is
simply observing bad builder virtualization and/or loaded
machines.
We keep the test in full mode where developers will
presumably be running on a lightly-loaded, native, fast
machine.
Russ Cox [Wed, 29 Feb 2012 20:54:06 +0000 (15:54 -0500)]
spec: apply method sets, embedding to all types, not just named types
When we first wrote the method set definition, we had long
discussions about whether method sets applied to all types
or just named types, and we (or at least I) concluded that it
didn't matter: the two were equivalent points of view, because
the only way to introduce a new method was to write a method
function, which requires a named receiver type.
However, the addition of embedded types changed this.
Embedding can introduce a method without writing an explicit
method function, as in:
var x struct {
sync.Mutex
}
var px *struct {
sync.Mutex
}
var _, _ sync.Locker = &x, px
The edits in this CL make clear that both &x and px satisfy
sync.Locker. Today, gccgo already works this way; 6g does not.
R=golang-dev, gri, iant, r
CC=golang-dev
https://golang.org/cl/5702062
Russ Cox [Wed, 29 Feb 2012 20:28:36 +0000 (15:28 -0500)]
gc: disallow absolute import paths
They are broken and hard to make work.
They have never worked: if you import "/tmp/x"
from "/home/rsc/p.c" then the compiler rewrites
this into import "/home/rsc/tmp/x", which is
clearly wrong.
Also we just disallowed the : character in import
paths, so import "c:/foo" is already not allowed.
Finally, in order to support absolute paths well in
a build tool we'd have to provide a mechanism to
instruct the compiler to resolve absolute imports
by looking in some other tree (where the binaries live)
and provide a mapping from absolute path to location
in that tree. This CL avoids adding that complexity.
This is not part of the language spec (and should not be),
so no spec change is needed.
Fixes #2919 I believe. (gets as far as sending a CONNECT
request to my little dummy logging proxy that doesn't actually
support CONNECT now.) Untested with a real CONNECT-supporting
proxy, though.
Robert Griesemer [Wed, 29 Feb 2012 16:38:31 +0000 (08:38 -0800)]
go/printer: replace multiline logic
This CL mostly deletes code.
Using existing position information is
just as good to determine if a new section
is needed; no need to track exact multi-
line information. Eliminates the need to
carry around a multiLine parameter with
practically every function.
Applied gofmt -w src misc resulting in only
a minor change to godoc.go. In return, a couple
of test cases are now formatted better.
Not Go1-required, but nice-to-have as it will
simplify fixes going forward.
Stefan Nilsson [Tue, 28 Feb 2012 22:38:58 +0000 (09:38 +1100)]
doc/style.css: make selectors more selective.
Change #foo to div#foo to avoid selecting headings
with anchor foo, such as <h1 id="foo">.
(A more extensive change would be to use class
selectors for styling. Perhaps this is better, since id:s
should be unique within a document according to
http://www.w3.org/TR/CSS2/selector.html#id-selectors)
Russ Cox [Tue, 28 Feb 2012 21:18:24 +0000 (16:18 -0500)]
runtime/pprof: support OS X CPU profiling
Work around profiling kernel bug with signal masks.
Still broken on 64-bit Snow Leopard kernel,
but I think we can ignore that one and let people
upgrade to Lion.
Add new trivial tools addr2line and objdump to take
the place of the GNU tools of the same name, since
those are not installed on OS X.
Adapt pprof to invoke 'go tool addr2line' and
'go tool objdump' if the system tools do not exist.
Shenghou Ma [Tue, 28 Feb 2012 18:22:28 +0000 (02:22 +0800)]
cmd/dist: force line-buffering stdout/stderr on Unix
If stdout and stderr are indeed the same file (not a tty), which is
often the case, fully-buffered stdout will make it harder to see
progresses, for example, ./make.bash 2>&1 | tee log
David Symonds [Tue, 28 Feb 2012 00:41:16 +0000 (11:41 +1100)]
encoding/json: drop MarshalForHTML; gofix calls to Marshal.
I've elected to omit escaping the output of Marshalers for now.
I haven't thought through the implications of that;
I suspect that double escaping might be the undoing of that idea.
Fixes #3127.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5694098
Robert Griesemer [Mon, 27 Feb 2012 19:18:00 +0000 (11:18 -0800)]
godoc: don't show directories w/o packages in flat dir mode
The main change is simple: Both the Directory and DirEntry
struct have an extra field 'HasPkg' indicating whether the
directory contains any package files. The remaining changes
are more comments and adjustments to the template files.
Anthony Martin [Mon, 27 Feb 2012 18:01:45 +0000 (10:01 -0800)]
go/printer: fix test for new import path restrictions
Import paths with spaces are now invalid.
The builders would've caught this if they were running
the long tests. I've removed the check for short tests
in this package since the current tests are fast enough
already.
Robert Griesemer [Fri, 24 Feb 2012 21:44:22 +0000 (13:44 -0800)]
go/doc, godoc: fix range of type declarations
For grouped type declarations, go/doc introduces
fake individual declarations. Don't use the original
location of the "type" keyword because it will lead
to an overly large source code range for that fake
declaration, and thus an overly large selection shown
via godoc (e.g.: click on the AssignStmt link for:
http://golang.org/pkg/go/ast/#AssignStmt ).
Also: Don't create a fake declaration if not needed.
Rob Pike [Fri, 24 Feb 2012 21:02:35 +0000 (08:02 +1100)]
doc/go1: new introduction
This distills the motivational discussion and makes it the introduction to the release notes.
After this lands, I'll expand the discussion of the major changes to include more background.
Rob Pike [Fri, 24 Feb 2012 21:00:55 +0000 (08:00 +1100)]
cmd/go: in list, don't print blank lines for no output
Otherwise
go list -f "{{if .Stale}}{{.ImportPath}}{{end}}" all
and similar commands can print pages of empty lines.
Russ Cox [Fri, 24 Feb 2012 03:45:55 +0000 (22:45 -0500)]
cmd/cc: grow some global arrays
Avoids global array buffer overflows if they are
indexed using some of the values between NTYPE
and NALLTYPE. It is entirely likely that not all of these
are necessary, but this is the C compiler and not worth
worrying much about. This change takes up only a
few more bytes of memory and makes the behavior
deterministic.