1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:21:22 -06:00
Commit Graph

9281 Commits

Author SHA1 Message Date
Russ Cox
ebe1664d27 go/build: replace FindTree, ScanDir, Tree, DirInfo with Import, Package
This is an API change, but one I have been promising would
happen when it was clear what the go command needed.

This is basically a complete replacement of what used to be here.

build.Tree is gone.

build.DirInfo is expanded and now called build.Package.

build.FindTree is now build.Import(package, srcDir, build.FindOnly).
The returned *Package contains information that FindTree returned,
but applicable only to a single package.

build.ScanDir is now build.ImportDir.

build.FindTree+build.ScanDir is now build.Import.

The new Import API allows specifying the source directory,
in order to resolve local imports (import "./foo") and also allows
scanning of packages outside of $GOPATH.  They will come back
with less information in the Package, but they will still work.

The old go/build API exposed both too much and too little.
This API is much closer to what the go command needs,
and it works well enough in the other places where it is
used.  Path is gone, so it can no longer be misused.  (Fixes issue 2749.)

This CL updates clients of go/build other than the go command.
The go command changes are in a separate CL, to be submitted
at the same time.

R=golang-dev, r, alex.brainman, adg
CC=golang-dev
https://golang.org/cl/5713043
2012-03-01 12:12:09 -05:00
Russ Cox
a72b87efa9 reflect: make Value.Interface return immutable data
Fixes #3134.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5713049
2012-03-01 11:48:27 -05:00
Russ Cox
dc159fabff runtime: run init on main thread
Fixes #3125.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/5714049
2012-03-01 11:48:17 -05:00
Russ Cox
03769efe41 cmd/dist: recognize CC="ccache clang" as clang
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5711052
2012-03-01 11:46:13 -05:00
Anthony Martin
d88af88dfb 5g, 8g: remove documentation dregs
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5714051
2012-02-29 22:56:50 -08:00
David Symonds
289a1638aa html/template: encoding/json does more escaping now, so update the html/template test that uses it.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5714052
2012-03-01 17:52:05 +11:00
David Symonds
99e45e49b7 encoding/json: escape output from Marshalers.
Fixes #3127.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5707054
2012-03-01 17:41:59 +11:00
Alex Brainman
ed238ca4e5 os: release process handle at the end of windows (*Process).Wait
Fixes #3154.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5707052
2012-03-01 17:36:35 +11:00
David Symonds
1f0f459a16 encoding/gob: more hardening for lengths of input strings.
Fixes #3160.

R=r
CC=golang-dev
https://golang.org/cl/5716046
2012-03-01 15:57:54 +11:00
Rob Pike
dd001b5931 text/template: add examples that use multiple templates
Fixes #2742.

R=golang-dev, peterthrun, adg
CC=golang-dev
https://golang.org/cl/5699083
2012-03-01 14:55:18 +11:00
Robert Griesemer
fd5718ce82 go/printer, gofmt: improved comment placement
Applied gofmt -w src misc (no changes).

Fixes #3147.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5710046
2012-02-29 17:25:15 -08:00
Rob Pike
5a5279e128 io: Pipes and ReadAt are safe to use concurrently.
Updates #1599.

R=golang-dev, bradfitz, rsc, r
CC=golang-dev
https://golang.org/cl/5708056
2012-03-01 11:24:13 +11:00
Johan Euphrosine
6652b0b866 doc: add The Laws of Reflection article
Originally published on The Go Programming Language Blog, September 6, 2011.

http://blog.golang.org/2011/09/laws-of-reflection.html

Update #2547

R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/5689054
2012-03-01 10:05:51 +11:00
Mikio Hara
7301065fcc net: make -external flag for tests default to true
go test -short # like in the build; no external stuff
go test # long tests, + external
go test -external=false # long tests, no external

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5696079
2012-03-01 07:39:03 +09:00
Anthony Martin
564a1f3358 gc: fix string comparisons for new bool rules
The two string comparison optimizations were
missing the implicit cast from ideal bool.

Fixes #3119.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5696071
2012-02-29 13:55:50 -08:00
Russ Cox
fc268acf05 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
2012-02-29 16:37:40 -05:00
Brad Fitzpatrick
8c5290502f 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.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5713044
2012-02-29 13:14:05 -08:00
Russ Cox
7aba72baaa os: diagnose chdir error during StartProcess
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5711044
2012-02-29 15:53:57 -05:00
Russ Cox
b47cef394b path/filepath: note that SplitList is different from strings.Split
R=golang-dev, r, bradfitz, gustavo
CC=golang-dev
https://golang.org/cl/5712044
2012-02-29 15:50:46 -05:00
Russ Cox
d0d251f858 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.

If we need to make them work later, we can.

R=ken2
CC=golang-dev
https://golang.org/cl/5712043
2012-02-29 15:28:36 -05:00
Brad Fitzpatrick
8f0bfc5a29 net/http/httptest: make Server.Close wait for outstanding requests to finish
Might fix issue 3050

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5708066
2012-02-29 12:18:26 -08:00
Shenghou Ma
357b257cd1 runtime/pprof: skip test on 64-bit Mac OS X 10.6
R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5709060
2012-03-01 03:11:37 +08:00
Shenghou Ma
df3a841021 doc: elaborate available checks for cmd/vet
R=golang-dev, r, ality, r
CC=golang-dev
https://golang.org/cl/5709053
2012-03-01 02:22:35 +08:00
Brad Fitzpatrick
3684ae9da0 net/http: make a test more paranoid & reliable on Windows, maybe.
Part of diagnosing issue 3050.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5707056
2012-02-29 09:53:20 -08:00
Brad Fitzpatrick
f5df930618 net/http: fix ProxyFromEnvironment bug, docs, add tests
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.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5708055
2012-02-29 09:52:52 -08:00
Brad Fitzpatrick
02b124e59a net/http/httputil: make https DumpRequestOut less racy
It's still racy in that it mutates req.Body, though.  *shrug*

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5709054
2012-02-29 09:52:28 -08:00
Robert Hencke
fc79058199 gob: trivial print fix
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5707062
2012-02-29 08:45:57 -08:00
Robert Griesemer
b1b0ed1e60 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.

R=rsc
CC=golang-dev
https://golang.org/cl/5706055
2012-02-29 08:38:31 -08:00
Luuk van Dijk
fb2706113f pkg/runtime: 2 sanity checks in the runtime-gdb.py prettyprinters.
Don't try to print obviously corrupt slices or interfaces.
Doesn't actually solve 3047 or 2818, but seems a good idea anyway.

R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5708061
2012-02-29 16:42:25 +01:00
Mikio Hara
ecdd9f2376 net: minor fixes to test
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5707058
2012-02-29 12:34:05 +09:00
Rob Pike
ee149d9a6b io: document that i/o is not necessarily safe for parallel access.
Updates #1599.

R=golang-dev, adg, dsymonds
CC=golang-dev
https://golang.org/cl/5704052
2012-02-29 13:30:08 +11:00
Brad Fitzpatrick
1b1039a1c1 net/http/httputil: fix DumpRequestOut on https URLs
Don't try to do an SSL negotiation with a *bytes.Buffer.

Fixes #3135

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5709050
2012-02-28 16:03:32 -08:00
Mikio Hara
e266d6064c net: fix comment on Dial with unixgram
We should use DialUnix or ListenPacket for unixgram networks
because Dial doesn't take a local UnixAddr.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5706043
2012-02-29 07:45:38 +09:00
Russ Cox
38a03de6a1 go/build: move code around
Only copy+paste here.
Will make next code review's diffs a bit smaller.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5704050
2012-02-28 16:34:41 -05:00
Russ Cox
6e2ae0a12c 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.

Clean up disassembly of base register on amd64.

Fixes #2008.

R=golang-dev, bradfitz, mikioh.mikioh, r, iant
CC=golang-dev
https://golang.org/cl/5697066
2012-02-28 16:18:24 -05:00
Rémy Oudompheng
c10f50859e all: remove various unused unexported functions and constants.
R=golang-dev, minux.ma, rsc
CC=golang-dev, remy
https://golang.org/cl/5702050
2012-02-28 21:48:03 +01:00
Rob Pike
250fa82122 net/rpc: API changes, all documentation
except for hiding one type that is only used internally.

Fixes #2944.

R=golang-dev, rsc, kevlar
CC=golang-dev
https://golang.org/cl/5707044
2012-02-29 07:34:28 +11:00
Shenghou Ma
26daf6a03f 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

R=r, rsc
CC=golang-dev
https://golang.org/cl/5700070
2012-02-29 02:22:28 +08:00
Mikkel Krautz
fb1a5fcacf crypto/tls: force OS X target version to 10.6 for API compatibility
This is a band-aid until we can use weak imports with cgo.

Fixes #3131.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/5700083
2012-02-28 11:34:48 -05:00
Shenghou Ma
e0aa36147d encoding/gob: fix "// +build" comment for debug.go
R=golang-dev, rsc, adg, r, r
CC=golang-dev
https://golang.org/cl/5693060
2012-02-28 13:39:42 +08:00
Robert Griesemer
e952e241ae gotype: provide -comments flag
When debugging ASTs, it's useful to also
see the comments on occasion. Usage:

gotype -ast -comments file.go

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5703043
2012-02-27 21:35:26 -08:00
Rob Pike
26c2443d80 text/template: add example showing use of custom function
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5694100
2012-02-28 15:50:41 +11:00
Rob Pike
180541b2b1 text/template: fix redefinition bugs
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5696087
2012-02-28 14:23:57 +11:00
Rob Pike
7201b0c27c tutorial: delete
Instead we'll point people at the Tour and beef up code.html.

Fixes #3107.

R=golang-dev, bradfitz, r, adg
CC=golang-dev
https://golang.org/cl/5697077
2012-02-28 13:35:58 +11:00
Mikio Hara
d9c5626047 net: no panic on placeholders for netbsd
Perhaps it might be better than panic.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5701064
2012-02-28 10:58:01 +09:00
David Symonds
9dd746c4cb 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
2012-02-28 11:41:16 +11:00
Benny Siegert
740d503866 net: add stubs for NetBSD
This fixes the build of package net for GOOS=NetBSD.
Of course, a real implementation would be even better.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5693065
2012-02-28 11:28:10 +11:00
Benny Siegert
8c7b832ad5 os: fix NetBSD build
os.fileStat.Sys is no longer exported.

R=golang-dev, m4dh4tt3r, r
CC=golang-dev
https://golang.org/cl/5696074
2012-02-28 11:26:01 +11:00
Brad Fitzpatrick
fa33fdbc7d encoding/binary: better example
leave that joke to Java.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5695080
2012-02-28 10:15:23 +11:00
Andrew Gerrand
ce51e10749 archive/zip: use encoding/binary again, add readBuf helper
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5699097
2012-02-28 09:41:30 +11:00