]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 years agoweekly.2011-12-14 weekly.2011-12-14
Andrew Gerrand [Thu, 15 Dec 2011 05:56:12 +0000 (16:56 +1100)]
weekly.2011-12-14

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5494045

12 years agospec: skip carriage returns in raw literals
Rob Pike [Thu, 15 Dec 2011 05:52:41 +0000 (21:52 -0800)]
spec: skip carriage returns in raw literals

This change guarantees that whether the line ending convention
when the source is created includes carriage returns is irrelevant
to the value of the string. See issue 680.

The compilers do not yet implement this.

R=golang-dev, adg, r, gri, rsc, iant
CC=golang-dev
https://golang.org/cl/5491043

12 years agogo: implement build, install, run
Russ Cox [Thu, 15 Dec 2011 03:42:42 +0000 (22:42 -0500)]
go: implement build, install, run

clean is gone; all the intermediate files are created
in a temporary tree that is wiped when the command ends.

Not using go/build's Script because it is not well aligned
with this API.  The various builder methods are copied from
go/build and adapted.  Probably once we delete goinstall
we can delete the Script API too.

R=rogpeppe, adg, adg
CC=golang-dev
https://golang.org/cl/5483069

12 years agofmt: don't recur if String method (etc.) misbehaves
Rob Pike [Thu, 15 Dec 2011 00:37:54 +0000 (16:37 -0800)]
fmt: don't recur if String method (etc.) misbehaves

Fixes #2555.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/5486076

12 years agohtml: don't leave "in column group" mode when ignoring a token
Andrew Balholm [Wed, 14 Dec 2011 23:45:19 +0000 (10:45 +1100)]
html: don't leave "in column group" mode when ignoring a token

Pass tests6.dat, test 26:
foo<col>

| <col>

Also pass tests through test 35:
<table><tr><div><td>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5482074

12 years agocgo: add basic gccgo support.
Rémy Oudompheng [Wed, 14 Dec 2011 23:40:35 +0000 (15:40 -0800)]
cgo: add basic gccgo support.

R=rsc, iant
CC=golang-dev, remy
https://golang.org/cl/5485070

12 years ago5c, 6c, 8c: support 64-bit switch value
Anthony Martin [Wed, 14 Dec 2011 22:30:40 +0000 (17:30 -0500)]
5c, 6c, 8c: support 64-bit switch value

For real this time. :-)

R=rsc, ken
CC=golang-dev
https://golang.org/cl/5486061

12 years agogzip: Convert between Latin-1 and Unicode
Vadim Vygonets [Wed, 14 Dec 2011 22:17:40 +0000 (17:17 -0500)]
gzip: Convert between Latin-1 and Unicode

I realize I didn't send the tests in last time.  Anyway, I added
a test that knows too much about the package's internal structure,
and I'm not sure whether it's the right thing to do.

Vadik.

R=bradfitz, rsc, go.peter.90
CC=golang-dev
https://golang.org/cl/5450073

12 years agonet/smtp: add CRAM-MD5 authentication
Vadim Vygonets [Wed, 14 Dec 2011 22:17:25 +0000 (17:17 -0500)]
net/smtp: add CRAM-MD5 authentication

R=golang-dev, edsrzf, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5451087

12 years agoA+C: Vadim Vygonets (individual CLA)
Russ Cox [Wed, 14 Dec 2011 22:17:09 +0000 (17:17 -0500)]
A+C: Vadim Vygonets (individual CLA)

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5482073

12 years agomisc/osx: Rename profile.go to profile_go to avoid confusing scripts
Scott Lawrence [Wed, 14 Dec 2011 21:26:48 +0000 (16:26 -0500)]
misc/osx: Rename profile.go to profile_go to avoid confusing scripts

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5472043

12 years agohtml/template: define the FuncMap type locally
Rob Pike [Wed, 14 Dec 2011 19:22:17 +0000 (11:22 -0800)]
html/template: define the FuncMap type locally
This redefinition means that the public signature of html/template
does not refer to text/template.

Fixes #2546.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5487083

12 years agogotest: use build.DefaultContext.GOARCH
Robert Hencke [Wed, 14 Dec 2011 19:21:30 +0000 (11:21 -0800)]
gotest: use build.DefaultContext.GOARCH

Fixes https://golang.org/cl/5480060/#msg4

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5485051

12 years agohttp: fix failing Transport HEAD request with gzip-looking response
Brad Fitzpatrick [Wed, 14 Dec 2011 19:20:21 +0000 (11:20 -0800)]
http: fix failing Transport HEAD request with gzip-looking response

We only want to attempt to un-gzip if there's a body (not in
response to a HEAD)

This was accidentally passing before, but revealed to be broken
when c3c6e72d7cc went in.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5477093

12 years agostrconv: slightly faster int conversion for GOARCH=386
Robert Griesemer [Wed, 14 Dec 2011 19:14:10 +0000 (11:14 -0800)]
strconv: slightly faster int conversion for GOARCH=386

benchmark                           old ns/op    new ns/op    delta
strconv_test.BenchmarkFormatInt         12198        12031   -1.37%
strconv_test.BenchmarkAppendInt          9268         9153   -1.24%
strconv_test.BenchmarkFormatUint         3538         3429   -3.08%
strconv_test.BenchmarkAppendUint         3133         3062   -2.27%

No performance difference for GOARCH=amd64.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5488089

12 years agojson: treat renamed byte slices the same as []byte
Rob Pike [Wed, 14 Dec 2011 19:03:28 +0000 (11:03 -0800)]
json: treat renamed byte slices the same as []byte
Fixes #2163.

R=rsc
CC=golang-dev
https://golang.org/cl/5488068

12 years agostrconv: even faster int conversion
Robert Griesemer [Wed, 14 Dec 2011 18:45:59 +0000 (10:45 -0800)]
strconv: even faster int conversion

benchmark                           old ns/op    new ns/op    delta
strconv_test.BenchmarkFormatInt         10038         8217  -18.14%
strconv_test.BenchmarkAppendInt          6822         4969  -27.16%
strconv_test.BenchmarkFormatUint         2811         1814  -35.47%
strconv_test.BenchmarkAppendUint         2349         1360  -42.10%

R=rsc
CC=golang-dev
https://golang.org/cl/5488083

12 years agoundo CL 5477092 / c3c6e72d7cc5
Robert Griesemer [Wed, 14 Dec 2011 18:44:34 +0000 (10:44 -0800)]
undo CL 5477092 / c3c6e72d7cc5

The obvious fix is breaking the build in non-obvious ways.
Reverting while waiting for the correct fix, if any is needed.

««« original CL description
net/http: fix bug in error checking

Thanks to josef86@gmail.com for pointing this out.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5477092
»»»

R=iant
CC=golang-dev
https://golang.org/cl/5488085

12 years agonet/http: fix bug in error checking
Robert Griesemer [Wed, 14 Dec 2011 16:43:42 +0000 (08:43 -0800)]
net/http: fix bug in error checking

Thanks to josef86@gmail.com for pointing this out.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5477092

12 years agogc: use inferred type rather than original one when reporting non-assignability.
Luuk van Dijk [Wed, 14 Dec 2011 16:34:35 +0000 (17:34 +0100)]
gc: use inferred type rather than original one when reporting non-assignability.

Fixes #2451

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5372105

12 years agocrypto/tls: make compatible with go/build
Russ Cox [Wed, 14 Dec 2011 15:25:48 +0000 (10:25 -0500)]
crypto/tls: make compatible with go/build

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5484073

12 years agohash/crc32: make compatible with go/build
Russ Cox [Wed, 14 Dec 2011 15:25:16 +0000 (10:25 -0500)]
hash/crc32: make compatible with go/build

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5486060

12 years agogo/build: make compatible with go/build
Russ Cox [Wed, 14 Dec 2011 15:24:17 +0000 (10:24 -0500)]
go/build: make compatible with go/build

The irony!

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5482062

12 years agogc: add forgotten typecheck in a lonely corner of sinit
Luuk van Dijk [Wed, 14 Dec 2011 14:54:10 +0000 (15:54 +0100)]
gc: add forgotten typecheck in a lonely corner of sinit

Fixes #2549

R=rsc
CC=golang-dev
https://golang.org/cl/5484060

12 years agogc: inlining (disabled without -l)
Luuk van Dijk [Wed, 14 Dec 2011 14:05:33 +0000 (15:05 +0100)]
gc: inlining (disabled without -l)

Cross- and intra package inlining of single assignments or return <expression>.
Minus some hairy cases, currently including other calls, expressions with closures and ... arguments.

R=rsc, rogpeppe, adg, gri
CC=golang-dev
https://golang.org/cl/5400043

12 years agohtml: close <button> element before opening a new one
Andrew Balholm [Wed, 14 Dec 2011 10:40:31 +0000 (21:40 +1100)]
html: close <button> element before opening a new one

Pass tests6.dat, test 13:
<button><button>

| <html>
|   <head>
|   <body>
|     <button>
|     <button>

Also pass tests through test 25:
<table><colgroup>foo

R=nigeltao
CC=golang-dev
https://golang.org/cl/5487072

12 years agogc: Use %#F in error messages instead of %F.
Luuk van Dijk [Wed, 14 Dec 2011 07:22:36 +0000 (08:22 +0100)]
gc: Use %#F in error messages instead of %F.

Fixes #2520

R=rsc
CC=golang-dev
https://golang.org/cl/5482056

12 years agogc: suppress non-root cause message for bad receivers.
Luuk van Dijk [Wed, 14 Dec 2011 07:21:37 +0000 (08:21 +0100)]
gc: suppress non-root cause message for bad receivers.

Fixed issue 2500

R=rsc
CC=golang-dev
https://golang.org/cl/5485053

12 years agoundo CL 5485063 / 21595dc0395a
Russ Cox [Wed, 14 Dec 2011 05:46:07 +0000 (00:46 -0500)]
undo CL 5485063 / 21595dc0395a

breaks 64-bit build

««« original CL description
8c: handle 64-bit switch value
Cases must still be 32-bit values, but one thing at a time.

R=ality, ken2, ken
CC=golang-dev
https://golang.org/cl/5485063
»»»

R=ken2
CC=golang-dev
https://golang.org/cl/5488075

12 years agoruntime: bump gc 'extra bytes' check
Christopher Wedgwood [Wed, 14 Dec 2011 05:28:43 +0000 (21:28 -0800)]
runtime: bump gc 'extra bytes' check

(needed for non-zero GOMAXPROCS)

R=iant, rsc
CC=go.peter.90, golang-dev
https://golang.org/cl/5486059

12 years ago8c: handle 64-bit switch value
Russ Cox [Wed, 14 Dec 2011 05:08:38 +0000 (00:08 -0500)]
8c: handle 64-bit switch value
Cases must still be 32-bit values, but one thing at a time.

R=ality, ken2, ken
CC=golang-dev
https://golang.org/cl/5485063

12 years agoencoding/gob: better error messages when types mismatch
Rob Pike [Wed, 14 Dec 2011 04:40:55 +0000 (20:40 -0800)]
encoding/gob: better error messages when types mismatch
The transmitter must encode an interface value if it is to be decoded
into an interface value, but it's a common and confusing error to
encode a concrete value and attempt to decode it into an interface,
particularly *interface{}. This CL attempts to explain things better.

Fixes #2367.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5485072

12 years agoexp/winfsnotify: fix build.
Yasuhiro Matsumoto [Wed, 14 Dec 2011 02:17:48 +0000 (13:17 +1100)]
exp/winfsnotify: fix build.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5483057

12 years agospec: values of underlying type uintptr can be converted to unsafe.Pointer
Robert Griesemer [Wed, 14 Dec 2011 01:22:11 +0000 (17:22 -0800)]
spec: values of underlying type uintptr can be converted to unsafe.Pointer

Not a language change, just stating the facts.

Fixes #1793.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5488071

12 years agosyscall: regenerate z-files for openbsd
Joel Sing [Tue, 13 Dec 2011 23:46:49 +0000 (10:46 +1100)]
syscall: regenerate z-files for openbsd

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5414053

12 years agoruntime: Make gc_test test extra allocated space, not total space.
Ian Lance Taylor [Tue, 13 Dec 2011 23:12:55 +0000 (15:12 -0800)]
runtime: Make gc_test test extra allocated space, not total space.

Testing total space fails for gccgo when not using split
stacks, because then each goroutine has a large stack, and so
the total memory usage is large.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5487068

12 years agobufio: make the minimum read buffer size 16 bytes.
Rob Pike [Tue, 13 Dec 2011 23:07:17 +0000 (15:07 -0800)]
bufio: make the minimum read buffer size 16 bytes.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/5485067

12 years agotest/garbage: move to test/bench/garbage
Russ Cox [Tue, 13 Dec 2011 23:02:49 +0000 (18:02 -0500)]
test/garbage: move to test/bench/garbage

(These are benchmarks for the garbage collector, not tests.)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5484070

12 years agofix build, sorry
Russ Cox [Tue, 13 Dec 2011 22:53:00 +0000 (17:53 -0500)]
fix build, sorry

TBR=r
CC=golang-dev
https://golang.org/cl/5488066

12 years agostrconv: some allocation tests
Brad Fitzpatrick [Tue, 13 Dec 2011 22:49:26 +0000 (14:49 -0800)]
strconv: some allocation tests

R=rsc, r
CC=golang-dev
https://golang.org/cl/5477084

12 years agotest/bench: move to test/bench/shootout
Russ Cox [Tue, 13 Dec 2011 22:46:54 +0000 (17:46 -0500)]
test/bench: move to test/bench/shootout

R=golang-dev, r, gri, bradfitz
CC=golang-dev
https://golang.org/cl/5487067

12 years agocontribute.html: do not fill in the reviewer field
Florian Weimer [Tue, 13 Dec 2011 22:45:01 +0000 (17:45 -0500)]
contribute.html: do not fill in the reviewer field

The golang-dev mailing list is added automatically.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5482060

12 years agoA+C: Florian Weimer (individual CLA)
Russ Cox [Tue, 13 Dec 2011 22:44:44 +0000 (17:44 -0500)]
A+C: Florian Weimer (individual CLA)

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5486056

12 years agomath: delete non-Sqrt-based Hypot
Russ Cox [Tue, 13 Dec 2011 22:08:56 +0000 (17:08 -0500)]
math: delete non-Sqrt-based Hypot

I was confused by the existence of two portable Hypot
routines in the tree when I cleaned things up, and I made
ARM use the wrong (imprecise) one.  Use the right one,
and delete the wrong one.

Fixes arm build.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5485065

12 years agoundo CL 5414048 / f6b994f33cf4
Russ Cox [Tue, 13 Dec 2011 22:08:18 +0000 (17:08 -0500)]
undo CL 5414048 / f6b994f33cf4

breaks build

««« original CL description
http: close connection after printing panic stack trace
In a testing situation, it's possible for a local http
server to panic and the test exit without the stack trace
ever being printed.
Fixes #2480.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5414048

»»»

R=bradfitz
CC=golang-dev
https://golang.org/cl/5482061

12 years agogo/printer, godoc: print comments in example code
Robert Griesemer [Tue, 13 Dec 2011 22:05:05 +0000 (14:05 -0800)]
go/printer, godoc: print comments in example code

- go/printer: support for printing CommentedNodes
- go/doc: collect comments from examples

Fixes #2429.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/5482052

12 years agogofmt: simplify flags
Robert Griesemer [Tue, 13 Dec 2011 22:03:25 +0000 (14:03 -0800)]
gofmt: simplify flags

-tabs replaces -tabindent
-spaces has been removed

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/5487066

12 years agogofix: add googlecode module for rewriting Google Code imports
Andrew Gerrand [Tue, 13 Dec 2011 21:46:26 +0000 (08:46 +1100)]
gofix: add googlecode module for rewriting Google Code imports
goinstall: disallow googlecode.com import paths

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5421049

12 years agohttp: close connection after printing panic stack trace
Roger Peppe [Tue, 13 Dec 2011 21:34:22 +0000 (16:34 -0500)]
http: close connection after printing panic stack trace
In a testing situation, it's possible for a local http
server to panic and the test exit without the stack trace
ever being printed.
Fixes #2480.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5414048

12 years agogofix: add fix httputil
Yasuhiro Matsumoto [Tue, 13 Dec 2011 21:23:06 +0000 (16:23 -0500)]
gofix: add fix httputil

R=r, rsc, adg
CC=golang-dev
https://golang.org/cl/5364056

12 years agocodereview: fix path slash issue.
Yasuhiro Matsumoto [Tue, 13 Dec 2011 21:18:56 +0000 (16:18 -0500)]
codereview: fix path slash issue.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5487057

12 years agoarchive/tar: (test) structure comparison not reflect.DeepEqual
Christopher Wedgwood [Tue, 13 Dec 2011 21:08:49 +0000 (08:08 +1100)]
archive/tar: (test) structure comparison not reflect.DeepEqual

R=dsymonds
CC=golang-dev
https://golang.org/cl/5487064

12 years agomath: regularize build
Russ Cox [Tue, 13 Dec 2011 20:20:12 +0000 (15:20 -0500)]
math: regularize build

This will be nicer to the automatic tools.
It requires a few more assembly stubs
but fewer Go files.

There are a few instances where it looks like
there are new blobs of code, but they are just
being copied out of deleted files.

There is no new code here.

Suppose you have a portable implementation for Sin
and a 386-specific assembly one.  The old way to
do this was to write three files

sin_decl.go
   func Sin(x float64) float64  // declaration only
sin_386.s
   assembly implementation

sin_port.go
   func Sin(x float64) float64 { ... }  // pure-Go impl

and then link in either sin_decl.go+sin_386.s or
just sin_port.go.  The Makefile actually did the magic
of linking in only the _port.go files for those without
assembly and only the _decl.go files for those with
assembly, or at least some of that magic.

The biggest problem with this, beyond being hard
to explain to the build system, is that once you do
explain it to the build system, godoc knows which
of sin_port.go or sin_decl.go are involved on a given
architecture, and it (correctly) ignores the other.
That means you have to put identical doc comments
in both files.

The new approach, which is more like what we did
in the later packages math/big and sync/atomic,
is to have

sin.go
   func Sin(x float64) float64  // decl only
   func sin(x float64) float64 {...}  // pure-Go impl

sin_386.s
   // assembly for Sin (ignores sin)
sin_amd64.s
   // assembly for Sin: jmp sin
sin_arm.s
   // assembly for Sin: jmp sin

Once we abandon Makefiles we can put all the assembly
stubs in one source file, so the number of files will
actually go down.

Chris asked whether the branches cost anything.
Given that they are branching to pure-Go implementations
that are not typically known for their speed, the single
direct branch is not going to be noticeable.  That is,
it's on the slow path.

An alternative would have been to preserve the old
"only write assembly files when there's an implementation"
and still have just one copy of the declaration of Sin
(and thus one doc comment) by doing:

sin.go
   func Sin(x float64) float64 { return sin(x) }

sin_decl.go
   func sin(x float64) float64 // declaration only
sin_386.s
   // assembly for sin

sin_port.go
   func sin(x float64) float64 { portable code }

In this version everyone would link in sin.go and
then either sin_decl.go+sin_386.s or sin_port.go.

This has an extra function call on all paths, including
the "fast path" to get to assembly, and it triples the
number of Go files involved compared to what I did
in this CL.  On the other hand you don't have to
write assembly stubs.  After starting down this path
I decided that the assembly stubs were the easier
approach.

As for generating the assembly stubs on the fly, much
of the goal here is to eliminate magic from the build
process, so that zero-configuration tools like goinstall
or the new go tool can handle this package.

R=golang-dev, r, cw, iant, r
CC=golang-dev
https://golang.org/cl/5488057

12 years agocypto/ocsp: fix tests
Christopher Wedgwood [Tue, 13 Dec 2011 19:40:28 +0000 (14:40 -0500)]
cypto/ocsp: fix tests

Actually compare the result with expected not itself

R=agl, bradfitz
CC=golang-dev, rsc
https://golang.org/cl/5477079

12 years agogo: implement doc, fmt, fix, list, vet
Russ Cox [Tue, 13 Dec 2011 19:28:41 +0000 (14:28 -0500)]
go: implement doc, fmt, fix, list, vet

This CL is concerned with the basic Package structure
and applies it to the (trivial) implementations of the
doc, fmt, fix, list, and vet commands.

The command as a whole is still very much a work in progress.
In particular, work making the error messages look nice
is deferred to a future CL.

R=golang-dev, adg, dsymonds, r
CC=golang-dev
https://golang.org/cl/5482048

12 years agobuild: disable cgo on Windows/amd64
Russ Cox [Tue, 13 Dec 2011 19:20:38 +0000 (14:20 -0500)]
build: disable cgo on Windows/amd64

Apparently it is broken.  Disable so that dashboard
will let us see other breakages on Windows.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5477081

12 years agostrconv: make QuoteRune etc. take a rune argument
Rob Pike [Tue, 13 Dec 2011 19:13:23 +0000 (11:13 -0800)]
strconv: make QuoteRune etc. take a rune argument
Just an oversight it didn't already.
Fixes #2515.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5483064

12 years ago5g: fix build
Russ Cox [Tue, 13 Dec 2011 19:12:16 +0000 (14:12 -0500)]
5g: fix build

R=ken2
CC=golang-dev
https://golang.org/cl/5482059

12 years agostrconv: include package and function name in error strings
Rob Pike [Tue, 13 Dec 2011 18:42:05 +0000 (10:42 -0800)]
strconv: include package and function name in error strings
Fixes #2548.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5484062

12 years agogodoc: text wrapping
Russ Cox [Tue, 13 Dec 2011 18:33:40 +0000 (13:33 -0500)]
godoc: text wrapping

Example:

PACKAGE

package utf8
    import "unicode/utf8"

    Package utf8 implements functions and constants to support text
    encoded in UTF-8.  This package calls a Unicode character a rune for
    brevity.

CONSTANTS

const (
    RuneError = unicode.ReplacementChar // the "error" Rune or "replacement character".
    RuneSelf  = 0x80                    // characters below Runeself are represented as themselves in a single byte.
    UTFMax    = 4                       // maximum number of bytes of a UTF-8 encoded Unicode character.
)
    Numbers fundamental to the encoding.

FUNCTIONS

func DecodeLastRune(p []byte) (r rune, size int)
    DecodeLastRune unpacks the last UTF-8 encoding in p and returns the
    rune and its width in bytes.

func DecodeLastRuneInString(s string) (r rune, size int)
    DecodeLastRuneInString is like DecodeLastRune but its input is a
    string.

func DecodeRune(p []byte) (r rune, size int)
    DecodeRune unpacks the first UTF-8 encoding in p and returns the rune
    and its width in bytes.

func DecodeRuneInString(s string) (r rune, size int)
    DecodeRuneInString is like DecodeRune but its input is a string.

func EncodeRune(p []byte, r rune) int
    EncodeRune writes into p (which must be large enough) the UTF-8
    encoding of the rune.  It returns the number of bytes written.

func FullRune(p []byte) bool
    FullRune reports whether the bytes in p begin with a full UTF-8
    encoding of a rune.  An invalid encoding is considered a full Rune
    since it will convert as a width-1 error rune.

func FullRuneInString(s string) bool
    FullRuneInString is like FullRune but its input is a string.

func RuneCount(p []byte) int
    RuneCount returns the number of runes in p.  Erroneous and short
    encodings are treated as single runes of width 1 byte.

func RuneCountInString(s string) (n int)
    RuneCountInString is like RuneCount but its input is a string.

func RuneLen(r rune) int
    RuneLen returns the number of bytes required to encode the rune.

func RuneStart(b byte) bool
    RuneStart reports whether the byte could be the first byte of an
    encoded rune.  Second and subsequent bytes always have the top two
    bits set to 10.

func Valid(p []byte) bool
    Valid reports whether p consists entirely of valid UTF-8-encoded
    runes.

func ValidString(s string) bool
    ValidString reports whether s consists entirely of valid UTF-8-encoded
    runes.

TYPES

type String struct {
    // contains filtered or unexported fields
}
    String wraps a regular string with a small structure that provides
    more efficient indexing by code point index, as opposed to byte index.
    Scanning incrementally forwards or backwards is O(1) per index
    operation (although not as fast a range clause going forwards).
    Random access is O(N) in the length of the string, but the overhead is
    less than always scanning from the beginning.  If the string is ASCII,
    random access is O(1).  Unlike the built-in string type, String has
    internal mutable state and is not thread-safe.

func NewString(contents string) *String
    NewString returns a new UTF-8 string with the provided contents.

func (s *String) At(i int) rune
    At returns the rune with index i in the String.  The sequence of runes
    is the same as iterating over the contents with a "for range" clause.

func (s *String) Init(contents string) *String
    Init initializes an existing String to hold the provided contents.
    It returns a pointer to the initialized String.

func (s *String) IsASCII() bool
    IsASCII returns a boolean indicating whether the String contains only
    ASCII bytes.

func (s *String) RuneCount() int
    RuneCount returns the number of runes (Unicode code points) in the
    String.

func (s *String) Slice(i, j int) string
    Slice returns the string sliced at rune positions [i:j].

func (s *String) String() string
    String returns the contents of the String.  This method also means the
    String is directly printable by fmt.Print.

Fixes #2479.

R=golang-dev, dsymonds, mattn.jp, r, gri, r
CC=golang-dev
https://golang.org/cl/5472051

12 years agogc: delete DUPOK definition
Russ Cox [Tue, 13 Dec 2011 18:25:48 +0000 (13:25 -0500)]
gc: delete DUPOK definition

The relevant header is already included.

R=ken2
CC=golang-dev
https://golang.org/cl/5487062

12 years agoexp/ssh: improve client channel close behavior
Dave Cheney [Tue, 13 Dec 2011 15:27:17 +0000 (10:27 -0500)]
exp/ssh: improve client channel close behavior

R=gustav.paul
CC=golang-dev
https://golang.org/cl/5480062

12 years agogc: small fixes to fmt.c
Luuk van Dijk [Tue, 13 Dec 2011 08:15:46 +0000 (09:15 +0100)]
gc: small fixes to fmt.c

don't crash when printing error messages about symbols in a garbled state.
render OCOMPLIT in export mode.

R=rsc
CC=golang-dev
https://golang.org/cl/5466045

12 years agogc: fix use of stackallocated AST node in generation of static initialisation code.
Luuk van Dijk [Tue, 13 Dec 2011 08:09:10 +0000 (09:09 +0100)]
gc: fix use of stackallocated AST node in generation of static initialisation code.

Fixes #2529

R=rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/5483048

12 years agodoc/go1: time
Rob Pike [Tue, 13 Dec 2011 05:08:03 +0000 (21:08 -0800)]
doc/go1: time

R=rsc
CC=golang-dev
https://golang.org/cl/5477077

12 years agodoc/go1: more package updates
Rob Pike [Tue, 13 Dec 2011 03:25:25 +0000 (19:25 -0800)]
doc/go1: more package updates
Everything there (as first draft) except the time package.

R=golang-dev, adg, bradfitz
CC=golang-dev
https://golang.org/cl/5487052

12 years agogc: implement == on structs and arrays
Russ Cox [Tue, 13 Dec 2011 03:22:09 +0000 (22:22 -0500)]
gc: implement == on structs and arrays

To allow these types as map keys, we must fill in
equal and hash functions in their algorithm tables.
Structs or arrays that are "just memory", like [2]int,
can and do continue to use the AMEM algorithm.
Structs or arrays that contain special values like
strings or interface values use generated functions
for both equal and hash.

The runtime helper func runtime.equal(t, x, y) bool handles
the general equality case for x == y and calls out to
the equal implementation in the algorithm table.

For short values (<= 4 struct fields or array elements),
the sequence of elementwise comparisons is inlined
instead of calling runtime.equal.

R=ken, mpimenov
CC=golang-dev
https://golang.org/cl/5451105

12 years agospec: allow comparison of structs, arrays containing comparable values
Russ Cox [Tue, 13 Dec 2011 03:21:46 +0000 (22:21 -0500)]
spec: allow comparison of structs, arrays containing comparable values

Also, clarify when interface comparison panics and
that comparison to nil is a special syntax rather than
a general comparison rule.

R=r, gri, r, iant, cw, bradfitz
CC=golang-dev
https://golang.org/cl/5440117

12 years agohtml: update comments to match latest spec.
Nigel Tao [Tue, 13 Dec 2011 03:20:26 +0000 (14:20 +1100)]
html: update comments to match latest spec.

R=dsymonds
CC=golang-dev
https://golang.org/cl/5482054

12 years agohtml: a first step at parsing foreign content (MathML, SVG).
Nigel Tao [Tue, 13 Dec 2011 02:52:47 +0000 (13:52 +1100)]
html: a first step at parsing foreign content (MathML, SVG).

Nodes now have a Namespace field.

Pass adoption01.dat, test 12:
<a><svg><tr><input></a>

| <html>
|   <head>
|   <body>
|     <a>
|       <svg svg>
|         <svg tr>
|           <svg input>

The other adoption01.dat tests already passed.

R=andybalholm
CC=golang-dev
https://golang.org/cl/5467075

12 years agosyscall: regenerate z-files for darwin, freebsd
Mikio Hara [Tue, 13 Dec 2011 01:27:23 +0000 (10:27 +0900)]
syscall: regenerate z-files for darwin, freebsd

R=golang-dev, jsing, rsc
CC=golang-dev
https://golang.org/cl/5479054

12 years agonet: fix typo
Mikio Hara [Tue, 13 Dec 2011 01:12:45 +0000 (10:12 +0900)]
net: fix typo

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5488052

12 years agoenv.bash: export CGO_ENABLED so cgo tests run
Alex Brainman [Mon, 12 Dec 2011 23:47:51 +0000 (10:47 +1100)]
env.bash: export CGO_ENABLED so cgo tests run

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5394042

12 years agomisc/cgo/test: fix after latest time changes
Alex Brainman [Mon, 12 Dec 2011 23:46:58 +0000 (10:46 +1100)]
misc/cgo/test: fix after latest time changes

R=rsc
CC=golang-dev
https://golang.org/cl/5454047

12 years agovarious: a grab-bag of time.Duration cleanups.
David Symonds [Mon, 12 Dec 2011 23:42:56 +0000 (10:42 +1100)]
various: a grab-bag of time.Duration cleanups.

R=adg, r, rsc
CC=golang-dev
https://golang.org/cl/5475069

12 years agotime: allow sleep tests to run for 200% too long
Russ Cox [Mon, 12 Dec 2011 23:33:47 +0000 (18:33 -0500)]
time: allow sleep tests to run for 200% too long

Some VMs are slow.  Very slow.
Fixes #2421.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5482049

12 years agocompress/flate: fix out of bounds error
Ivan Krasin [Mon, 12 Dec 2011 23:25:32 +0000 (18:25 -0500)]
compress/flate: fix out of bounds error

Fixes #2508.

R=rsc, krasin
CC=golang-dev
https://golang.org/cl/5449115

12 years agoruntime: Changes to the runtime to support NetBSD.
Christopher Nielsen [Mon, 12 Dec 2011 23:10:11 +0000 (18:10 -0500)]
runtime: Changes to the runtime to support NetBSD.

R=rsc
CC=golang-dev
https://golang.org/cl/5477052

12 years agogodoc: added an opensearch description document.
Christoph Hack [Mon, 12 Dec 2011 23:01:06 +0000 (18:01 -0500)]
godoc: added an opensearch description document.

R=golang-dev, r, tux21b, rsc
CC=golang-dev
https://golang.org/cl/5479062

12 years agoA+C: add Christoph Hack (individual CLA)
Russ Cox [Mon, 12 Dec 2011 23:01:02 +0000 (18:01 -0500)]
A+C: add Christoph Hack (individual CLA)

R=golang-dev, dsymonds, gri
CC=golang-dev
https://golang.org/cl/5485048

12 years agodoc: add Error Handling article
Andrew Gerrand [Mon, 12 Dec 2011 22:44:06 +0000 (09:44 +1100)]
doc: add Error Handling article

Originally published on The Go Programming Language Blog, July 12, 2011.

http://blog.golang.org/2011/07/error-handling-and-go.html

Update #2547

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5475060

12 years agosql: fix missing mutex unlock in an error case
Brad Fitzpatrick [Mon, 12 Dec 2011 21:56:56 +0000 (13:56 -0800)]
sql: fix missing mutex unlock in an error case

Fixes #2542

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5483054

12 years agoreflect: fix Slice cap
Gustavo Niemeyer [Mon, 12 Dec 2011 21:45:40 +0000 (19:45 -0200)]
reflect: fix Slice cap

R=golang-dev, dsymonds, r, rsc
CC=golang-dev
https://golang.org/cl/5483044

12 years agoruntime: madvise and SysUnused for Linux
Sébastien Paolacci [Mon, 12 Dec 2011 21:33:13 +0000 (16:33 -0500)]
runtime: madvise and SysUnused for Linux

SysUnused being a direct call to madvise MADV_DONTNEED.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/5477057

12 years agogc: avoid 0-length C array
Lucio De Re [Mon, 12 Dec 2011 21:25:31 +0000 (16:25 -0500)]
gc: avoid 0-length C array

R=golang-dev, ality
CC=golang-dev, rsc
https://golang.org/cl/5467066

12 years agoos: fix Plan 9 build for new FileInfo API
Anthony Martin [Mon, 12 Dec 2011 21:14:00 +0000 (16:14 -0500)]
os: fix Plan 9 build for new FileInfo API

R=lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/5440073

12 years agotime: fix Plan 9 build for new API
Anthony Martin [Mon, 12 Dec 2011 21:12:22 +0000 (16:12 -0500)]
time: fix Plan 9 build for new API

I had to move readFile into sys_$GOOS.go
since syscall.Open takes only two arguments
on Plan 9.

R=lucio.dere, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/5447061

12 years agogc: fix wrong arguments to error message for switches.
Rémy Oudompheng [Mon, 12 Dec 2011 21:08:32 +0000 (16:08 -0500)]
gc: fix wrong arguments to error message for switches.

Fixes #2502.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/5472062

12 years agotime: gob marshaler for Time
Robert Hencke [Mon, 12 Dec 2011 21:08:29 +0000 (16:08 -0500)]
time: gob marshaler for Time

Addresses issue 2526

R=rsc, r
CC=golang-dev
https://golang.org/cl/5448114

12 years agomath: fix special cases in Nextafter
Charles L. Dorian [Mon, 12 Dec 2011 20:51:11 +0000 (15:51 -0500)]
math: fix special cases in Nextafter

Nextafter(0, -1) != -0.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5467060

12 years agold/6l/8l: First pass at changes to the linker to support NetBSD binaries.
Christopher Nielsen [Mon, 12 Dec 2011 20:42:11 +0000 (15:42 -0500)]
ld/6l/8l: First pass at changes to the linker to support NetBSD binaries.

This will not currently create valid NetBSD binaries because NetBSD requires
an ELF note section to run, otherwise the kernel will throw ENOEXEC. I was
unable to determine an elegant way to add the section, so I am submitting
what I have.

References:
http://www.netbsd.org/docs/kernel/elf-notes.html
http://mail-index.netbsd.org/netbsd-bugs/2001/08/03/0012.html

R=rsc
CC=golang-dev
https://golang.org/cl/5472049

12 years agobuild: Changes to the build infrastructure for NetBSD.
Christopher Nielsen [Mon, 12 Dec 2011 20:42:06 +0000 (15:42 -0500)]
build: Changes to the build infrastructure for NetBSD.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5476048

12 years agogc: add varargck for %lN
Lucio De Re [Mon, 12 Dec 2011 20:42:02 +0000 (15:42 -0500)]
gc: add varargck for %lN

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/5476049

12 years agogc: allow colon in //line file name
Russ Cox [Mon, 12 Dec 2011 20:41:54 +0000 (15:41 -0500)]
gc: allow colon in //line file name

Assume last colon introduces line number.

Fixes #2543.

R=ken2
CC=golang-dev
https://golang.org/cl/5485047

12 years agodoc/go1: the simpler package changes
Rob Pike [Mon, 12 Dec 2011 20:26:56 +0000 (12:26 -0800)]
doc/go1: the simpler package changes

R=golang-dev, fullung, dsymonds, r, adg
CC=golang-dev
https://golang.org/cl/5477056

12 years agoarchive/zip: make zip understand os.FileMode.
Roger Peppe [Mon, 12 Dec 2011 20:22:55 +0000 (15:22 -0500)]
archive/zip: make zip understand os.FileMode.
Fixes implicit dependency on underlying os file modes.

R=rsc, r, n13m3y3r, gustavo, adg
CC=golang-dev
https://golang.org/cl/5440130

12 years agonet/http: make test remove temporary file and directory
Ian Lance Taylor [Mon, 12 Dec 2011 18:40:15 +0000 (10:40 -0800)]
net/http: make test remove temporary file and directory

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5486044

12 years agocrypto/aes: Made faster by eliminating some indirection
Taru Karttunen [Mon, 12 Dec 2011 14:58:04 +0000 (09:58 -0500)]
crypto/aes: Made faster by eliminating some indirection

Made te and td arrays into variables te0-3 and td0-3,
which improves performance from 7000ns/op to 5800.

R=rsc, rogpeppe, agl
CC=golang-dev
https://golang.org/cl/5449077

12 years agodoc: remove file.go from run (fix windows build)
Andrew Gerrand [Mon, 12 Dec 2011 05:14:38 +0000 (16:14 +1100)]
doc: remove file.go from run (fix windows build)

R=golang-dev, r, alex.brainman, r
CC=golang-dev
https://golang.org/cl/5479069

12 years agodoc/go_tutorial: make clear the file example is Unix-specific
Rob Pike [Mon, 12 Dec 2011 05:03:49 +0000 (21:03 -0800)]
doc/go_tutorial: make clear the file example is Unix-specific
Fixes #2553.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5472074