Each package using struct field tags assumes that
it is the only package storing data in the tag.
This CL adds support in package reflect for sharing
tags between multiple packages. In this scheme, the
tags must be of the form
key:"value" key2:"value2"
(raw strings help when writing that tag in Go source).
reflect.StructField's Tag field now has type StructTag
(a string type), which has method Get(key string) string
that returns the associated value.
Clients of json and xml will need to be updated.
Code that says
type T struct {
X int "name"
}
should become
type T struct {
X int `json:"name"` // or `xml:"name"`
}
Use govet to identify struct tags that need to be changed
to use the new syntax.
R=r, r, dsymonds, bradfitz, kevlar, fvbommel, n13m3y3r
CC=golang-dev
https://golang.org/cl/4645069
Also reuse of *Regexp nodes.
I believe this is the end of the parser.
The only non-execution code that remains is
the code to expand x{3,5} into simpler operations.
R=sam.thorogood, r
CC=golang-dev
https://golang.org/cl/4629078
The decision for when to say "hash/crc32".New instead of
crc32.New in an error was double-counting imports
from different packages or indirect imports, so it was
quoting even when there was no ambiguity.
R=ken2
CC=golang-dev
https://golang.org/cl/4645070
The gosymtab and gopclntab sections were pointing to the proper
data, but that data was already owned by the rodata section.
Some ELF references explicitly prohibit multiple sections from
owning the same data, and strip behaves accordingly.
The data for these sections was moved to after rodata, and the
gosymtab and gopclntab sections now own their respective ranges.
This change makes strip happy both with and without -s being
provided at link time. Note that it won't remove these sections
because they are still allocated, and that's by design since
they are necessary at runtime for generating proper backtraces
and similar introspection operations.
Unlike the previous behavior, -s will now maintain zero-sized
gosymtab and gopclntab sections. This makes the implementation
slightly cleaner.
Fixes#1242.
NOTE: Tested on Linux amd64/386/arm only.
R=ality, rsc
CC=golang-dev
https://golang.org/cl/4639077
The public godoc looked confused. I imagine these were
written before current conventions were established.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4662060
The implementation does not grab the lock,
if Once is already initalized.
Benchmark results on HP Z600 (2 x Xeon E5620, 8 HT cores, 2.40GHz)
are as follows:
benchmark old ns/op new ns/op delta
sync_test.BenchmarkOnce 187.00 14.00 -92.51%
sync_test.BenchmarkOnce-2 909.00 21.40 -97.65%
sync_test.BenchmarkOnce-4 3684.00 20.90 -99.43%
sync_test.BenchmarkOnce-8 5987.00 23.00 -99.62%
sync_test.BenchmarkOnce-16 5051.00 21.60 -99.57%
R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4641066
including evaluation up the data tree (in this code all fields must be
in dot itself), plus more control structure, but the basics are in place.
R=rsc, r
CC=golang-dev
https://golang.org/cl/4665041
For both contended and uncontended case:
- support arbitrary number of cpus (not just 2)
- dynamic load balancing (improves stability)
- periodic execution of Gosched() to work around non-preemptiviness
For uncontended case eliminates possible false-sharing.
For contended case includes additional variation with some
amount of local work between mutex operations.
R=r, rsc
CC=golang-dev
https://golang.org/cl/4634093
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
#pragma varargck countpos f 1
says that the first argument to f is
the count of variadic arguments that follow.
#pragma varargck type f t
says that t is one of the allowed types for
a variadic argument to f.
(can be repeated)
combined, these can be used to check the
runtime.stdcall functions in the windows port
or in any other port that needs a vararg list of
uintptrs even on a 64-bit platform (where it is
very easy to pass a less-than-uintptr in the ...).
demo:
typedef unsigned int uintptr;
#pragma varargck countpos f 1
#pragma varargck type f uintptr
#pragma varargck type f void*
int f(int count, ...);
void *v;
char *p;
void
main(void)
{
f(1, v); // ok
f(1, main); // ok
f(1, p); // ok
f(2, v, v); // ok
f(2, v); // found 1 argument after count 2
f(1, 'a'); // invalid type INT in call to f
f(1, 0); // invalid type INT in call to f
}
R=ken, r, alex.brainman
CC=golang-dev
https://golang.org/cl/4634103
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.
R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
I have written up a Marshal and MarshalIndent pair that should
closely reflect the way that Unmarshal works. I would love feedback
on making this code more accessible and efficient... I haven't used
reflecton on this scale before, so there is probably a lot of work
that can be done on that.
Some potentially controversial things:
- All tag names are lower-cased by default.
- Zero-valued struct values are skipped.
- No namespace prefix (o:tag, etc) mechanism is supplied.
- You are allowed to marshal non-struct values (even though unmarshal
cannot handle them).
- A tag for a non-XMLName struct field that isn't "attr", "chardata",
or "innerxml" is used as the name of the tag. This could wreak
havoc if you try to marshal a protobuf struct.
- The "innerxml" and "chardata" are inserted verbatim. If you try to
marshal something straight from unmarshal, the results could be
unexpected (remove "innerxml" support from Marshal would be one
possible solution).
R=rsc
CC=golang-dev
https://golang.org/cl/4539082
Permits serving from virtual filesystems, such as files linked
into a binary, or from a zip file.
Also adds a gofix for:
http.FileServer(root, prefix) -> http.StripPrefix(prefix, http.FileServer(http.Dir(root)))
R=r, rsc, gri, adg, dsymonds, r, gri
CC=golang-dev
https://golang.org/cl/4629047