OSDN Git Service

libgo: Update to weekly 2011-11-09.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Dec 2011 01:11:29 +0000 (01:11 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Dec 2011 01:11:29 +0000 (01:11 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182073 138bc75d-0d04-0410-961f-82ee72b054a4

386 files changed:
gcc/testsuite/go.test/test/chan/select5.go
gcc/testsuite/go.test/test/cmplxdivide.go
gcc/testsuite/go.test/test/fixedbugs/bug358.go
gcc/testsuite/go.test/test/ken/divconst.go
gcc/testsuite/go.test/test/ken/modconst.go
gcc/testsuite/go.test/test/mallocrand.go
gcc/testsuite/go.test/test/stringrange.go
gcc/testsuite/go.test/test/utf.go
libgo/MERGE
libgo/Makefile.am
libgo/Makefile.in
libgo/go/archive/tar/reader.go
libgo/go/archive/zip/reader.go
libgo/go/archive/zip/reader_test.go
libgo/go/archive/zip/writer_test.go
libgo/go/bufio/bufio.go
libgo/go/bufio/bufio_test.go
libgo/go/builtin/builtin.go
libgo/go/bytes/buffer.go
libgo/go/bytes/buffer_test.go
libgo/go/bytes/bytes.go
libgo/go/bytes/bytes_test.go
libgo/go/compress/bzip2/bit_reader.go
libgo/go/compress/bzip2/bzip2.go
libgo/go/compress/zlib/testdata/e.txt [deleted file]
libgo/go/compress/zlib/testdata/pi.txt [deleted file]
libgo/go/container/heap/heap.go
libgo/go/container/heap/heap_test.go
libgo/go/crypto/dsa/dsa.go
libgo/go/crypto/dsa/dsa_test.go
libgo/go/crypto/ecdsa/ecdsa.go
libgo/go/crypto/ecdsa/ecdsa_test.go
libgo/go/crypto/elliptic/elliptic.go
libgo/go/crypto/elliptic/elliptic_test.go
libgo/go/crypto/hmac/hmac_test.go
libgo/go/crypto/ocsp/ocsp.go
libgo/go/crypto/openpgp/armor/armor.go
libgo/go/crypto/openpgp/elgamal/elgamal.go
libgo/go/crypto/openpgp/elgamal/elgamal_test.go
libgo/go/crypto/openpgp/packet/encrypted_key.go
libgo/go/crypto/openpgp/packet/encrypted_key_test.go
libgo/go/crypto/openpgp/packet/packet.go
libgo/go/crypto/openpgp/packet/private_key.go
libgo/go/crypto/openpgp/packet/public_key.go
libgo/go/crypto/openpgp/s2k/s2k_test.go
libgo/go/crypto/rand/util.go
libgo/go/crypto/rsa/pkcs1v15.go
libgo/go/crypto/rsa/pkcs1v15_test.go
libgo/go/crypto/rsa/rsa.go
libgo/go/crypto/rsa/rsa_test.go
libgo/go/crypto/tls/conn.go
libgo/go/crypto/tls/generate_cert.go
libgo/go/crypto/tls/handshake_messages_test.go
libgo/go/crypto/tls/handshake_server_test.go
libgo/go/crypto/tls/key_agreement.go
libgo/go/crypto/x509/pkcs1.go
libgo/go/crypto/x509/pkix/pkix.go
libgo/go/crypto/x509/x509.go
libgo/go/crypto/x509/x509_test.go
libgo/go/debug/gosym/pclntab_test.go
libgo/go/encoding/asn1/asn1.go [moved from libgo/go/asn1/asn1.go with 99% similarity]
libgo/go/encoding/asn1/asn1_test.go [moved from libgo/go/asn1/asn1_test.go with 100% similarity]
libgo/go/encoding/asn1/common.go [moved from libgo/go/asn1/common.go with 100% similarity]
libgo/go/encoding/asn1/marshal.go [moved from libgo/go/asn1/marshal.go with 99% similarity]
libgo/go/encoding/asn1/marshal_test.go [moved from libgo/go/asn1/marshal_test.go with 100% similarity]
libgo/go/encoding/binary/binary.go
libgo/go/encoding/binary/binary_test.go
libgo/go/encoding/csv/reader.go [moved from libgo/go/csv/reader.go with 100% similarity]
libgo/go/encoding/csv/reader_test.go [moved from libgo/go/csv/reader_test.go with 100% similarity]
libgo/go/encoding/csv/writer.go [moved from libgo/go/csv/writer.go with 99% similarity]
libgo/go/encoding/csv/writer_test.go [moved from libgo/go/csv/writer_test.go with 100% similarity]
libgo/go/encoding/gob/codec_test.go [moved from libgo/go/gob/codec_test.go with 100% similarity]
libgo/go/encoding/gob/debug.go [new file with mode: 0644]
libgo/go/encoding/gob/decode.go [moved from libgo/go/gob/decode.go with 100% similarity]
libgo/go/encoding/gob/decoder.go [moved from libgo/go/gob/decoder.go with 100% similarity]
libgo/go/encoding/gob/doc.go [moved from libgo/go/gob/doc.go with 100% similarity]
libgo/go/encoding/gob/dump.go [new file with mode: 0644]
libgo/go/encoding/gob/encode.go [moved from libgo/go/gob/encode.go with 100% similarity]
libgo/go/encoding/gob/encoder.go [moved from libgo/go/gob/encoder.go with 100% similarity]
libgo/go/encoding/gob/encoder_test.go [moved from libgo/go/gob/encoder_test.go with 100% similarity]
libgo/go/encoding/gob/error.go [moved from libgo/go/gob/error.go with 100% similarity]
libgo/go/encoding/gob/gobencdec_test.go [moved from libgo/go/gob/gobencdec_test.go with 100% similarity]
libgo/go/encoding/gob/timing_test.go [moved from libgo/go/gob/timing_test.go with 100% similarity]
libgo/go/encoding/gob/type.go [moved from libgo/go/gob/type.go with 97% similarity]
libgo/go/encoding/gob/type_test.go [moved from libgo/go/gob/type_test.go with 95% similarity]
libgo/go/encoding/json/decode.go [moved from libgo/go/json/decode.go with 99% similarity]
libgo/go/encoding/json/decode_test.go [moved from libgo/go/json/decode_test.go with 100% similarity]
libgo/go/encoding/json/encode.go [moved from libgo/go/json/encode.go with 99% similarity]
libgo/go/encoding/json/encode_test.go [moved from libgo/go/json/encode_test.go with 100% similarity]
libgo/go/encoding/json/indent.go [moved from libgo/go/json/indent.go with 100% similarity]
libgo/go/encoding/json/scanner.go [moved from libgo/go/json/scanner.go with 100% similarity]
libgo/go/encoding/json/scanner_test.go [moved from libgo/go/json/scanner_test.go with 99% similarity]
libgo/go/encoding/json/stream.go [moved from libgo/go/json/stream.go with 100% similarity]
libgo/go/encoding/json/stream_test.go [moved from libgo/go/json/stream_test.go with 100% similarity]
libgo/go/encoding/json/tagkey_test.go [moved from libgo/go/json/tagkey_test.go with 100% similarity]
libgo/go/encoding/json/tags.go [moved from libgo/go/json/tags.go with 100% similarity]
libgo/go/encoding/json/tags_test.go [moved from libgo/go/json/tags_test.go with 100% similarity]
libgo/go/encoding/xml/atom_test.go [moved from libgo/go/xml/atom_test.go with 100% similarity]
libgo/go/encoding/xml/embed_test.go [moved from libgo/go/xml/embed_test.go with 100% similarity]
libgo/go/encoding/xml/marshal.go [moved from libgo/go/xml/marshal.go with 100% similarity]
libgo/go/encoding/xml/marshal_test.go [moved from libgo/go/xml/marshal_test.go with 100% similarity]
libgo/go/encoding/xml/read.go [moved from libgo/go/xml/read.go with 99% similarity]
libgo/go/encoding/xml/read_test.go [moved from libgo/go/xml/read_test.go with 98% similarity]
libgo/go/encoding/xml/xml.go [moved from libgo/go/xml/xml.go with 99% similarity]
libgo/go/encoding/xml/xml_test.go [moved from libgo/go/xml/xml_test.go with 98% similarity]
libgo/go/exp/ebnf/ebnf.go
libgo/go/exp/ebnf/parser.go
libgo/go/exp/norm/composition.go
libgo/go/exp/norm/input.go
libgo/go/exp/norm/maketables.go
libgo/go/exp/norm/normalize.go
libgo/go/exp/norm/normregtest.go
libgo/go/exp/norm/trie_test.go
libgo/go/exp/norm/triegen.go
libgo/go/exp/spdy/read.go
libgo/go/exp/spdy/spdy_test.go
libgo/go/exp/spdy/types.go
libgo/go/exp/spdy/write.go
libgo/go/exp/sql/convert.go
libgo/go/exp/sql/convert_test.go
libgo/go/exp/sql/driver/driver.go
libgo/go/exp/sql/driver/types.go
libgo/go/exp/sql/driver/types_test.go [new file with mode: 0644]
libgo/go/exp/sql/fakedb_test.go
libgo/go/exp/sql/sql.go
libgo/go/exp/ssh/client.go
libgo/go/exp/ssh/client_auth.go [new file with mode: 0644]
libgo/go/exp/ssh/common.go
libgo/go/exp/ssh/doc.go
libgo/go/exp/ssh/messages.go
libgo/go/exp/ssh/messages_test.go
libgo/go/exp/ssh/server.go
libgo/go/exp/types/const.go
libgo/go/exp/types/gcimporter.go
libgo/go/exp/types/gcimporter_test.go
libgo/go/exp/wingui/gui.go
libgo/go/exp/wingui/winapi.go
libgo/go/expvar/expvar.go
libgo/go/expvar/expvar_test.go
libgo/go/fmt/format.go
libgo/go/fmt/print.go
libgo/go/fmt/scan.go
libgo/go/fmt/scan_test.go
libgo/go/go/ast/ast.go
libgo/go/go/ast/import.go [new file with mode: 0644]
libgo/go/go/build/build.go
libgo/go/go/build/build_test.go
libgo/go/go/doc/comment.go
libgo/go/go/doc/example.go
libgo/go/go/parser/parser.go
libgo/go/go/printer/printer.go
libgo/go/go/scanner/scanner.go
libgo/go/go/token/serialize.go
libgo/go/html/doc.go
libgo/go/html/entity_test.go
libgo/go/html/escape.go
libgo/go/html/parse.go
libgo/go/html/parse_test.go
libgo/go/html/template/attr.go [moved from libgo/go/exp/template/html/attr.go with 99% similarity]
libgo/go/html/template/clone.go [moved from libgo/go/exp/template/html/clone.go with 98% similarity]
libgo/go/html/template/clone_test.go [moved from libgo/go/exp/template/html/clone_test.go with 96% similarity]
libgo/go/html/template/content.go [moved from libgo/go/exp/template/html/content.go with 99% similarity]
libgo/go/html/template/content_test.go [moved from libgo/go/exp/template/html/content_test.go with 98% similarity]
libgo/go/html/template/context.go [moved from libgo/go/exp/template/html/context.go with 99% similarity]
libgo/go/html/template/css.go [moved from libgo/go/exp/template/html/css.go with 99% similarity]
libgo/go/html/template/css_test.go [moved from libgo/go/exp/template/html/css_test.go with 99% similarity]
libgo/go/html/template/doc.go [moved from libgo/go/exp/template/html/doc.go with 71% similarity]
libgo/go/html/template/error.go [moved from libgo/go/exp/template/html/error.go with 75% similarity]
libgo/go/html/template/escape.go [moved from libgo/go/exp/template/html/escape.go with 96% similarity]
libgo/go/html/template/escape_test.go [moved from libgo/go/exp/template/html/escape_test.go with 96% similarity]
libgo/go/html/template/html.go [moved from libgo/go/exp/template/html/html.go with 99% similarity]
libgo/go/html/template/html_test.go [moved from libgo/go/exp/template/html/html_test.go with 99% similarity]
libgo/go/html/template/js.go [moved from libgo/go/exp/template/html/js.go with 99% similarity]
libgo/go/html/template/js_test.go [moved from libgo/go/exp/template/html/js_test.go with 99% similarity]
libgo/go/html/template/template.go [new file with mode: 0644]
libgo/go/html/template/transition.go [moved from libgo/go/exp/template/html/transition.go with 99% similarity]
libgo/go/html/template/url.go [moved from libgo/go/exp/template/html/url.go with 99% similarity]
libgo/go/html/template/url_test.go [moved from libgo/go/exp/template/html/url_test.go with 99% similarity]
libgo/go/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat [new file with mode: 0644]
libgo/go/html/token.go
libgo/go/html/token_test.go
libgo/go/http/dump.go [deleted file]
libgo/go/image/bmp/reader.go
libgo/go/image/jpeg/writer_test.go
libgo/go/index/suffixarray/suffixarray_test.go
libgo/go/io/multi_test.go
libgo/go/log/log.go
libgo/go/log/syslog/syslog.go [moved from libgo/go/syslog/syslog.go with 100% similarity]
libgo/go/log/syslog/syslog_c.c [moved from libgo/go/syslog/syslog_c.c with 100% similarity]
libgo/go/log/syslog/syslog_libc.go [moved from libgo/go/syslog/syslog_libc.go with 100% similarity]
libgo/go/log/syslog/syslog_test.go [moved from libgo/go/syslog/syslog_test.go with 100% similarity]
libgo/go/log/syslog/syslog_unix.go [moved from libgo/go/syslog/syslog_unix.go with 100% similarity]
libgo/go/math/all_test.go
libgo/go/math/big/arith.go [moved from libgo/go/big/arith.go with 100% similarity]
libgo/go/math/big/arith_decl.go [moved from libgo/go/big/arith_decl.go with 100% similarity]
libgo/go/math/big/arith_test.go [moved from libgo/go/big/arith_test.go with 100% similarity]
libgo/go/math/big/calibrate_test.go [moved from libgo/go/big/calibrate_test.go with 100% similarity]
libgo/go/math/big/hilbert_test.go [moved from libgo/go/big/hilbert_test.go with 100% similarity]
libgo/go/math/big/int.go [moved from libgo/go/big/int.go with 99% similarity]
libgo/go/math/big/int_test.go [moved from libgo/go/big/int_test.go with 99% similarity]
libgo/go/math/big/nat.go [moved from libgo/go/big/nat.go with 99% similarity]
libgo/go/math/big/nat_test.go [moved from libgo/go/big/nat_test.go with 100% similarity]
libgo/go/math/big/rat.go [moved from libgo/go/big/rat.go with 100% similarity]
libgo/go/math/big/rat_test.go [moved from libgo/go/big/rat_test.go with 99% similarity]
libgo/go/math/cmplx/abs.go [moved from libgo/go/cmath/abs.go with 81% similarity]
libgo/go/math/cmplx/asin.go [moved from libgo/go/cmath/asin.go with 99% similarity]
libgo/go/math/cmplx/cmath_test.go [moved from libgo/go/cmath/cmath_test.go with 99% similarity]
libgo/go/math/cmplx/conj.go [moved from libgo/go/cmath/conj.go with 95% similarity]
libgo/go/math/cmplx/exp.go [moved from libgo/go/cmath/exp.go with 99% similarity]
libgo/go/math/cmplx/isinf.go [moved from libgo/go/cmath/isinf.go with 97% similarity]
libgo/go/math/cmplx/isnan.go [moved from libgo/go/cmath/isnan.go with 97% similarity]
libgo/go/math/cmplx/log.go [moved from libgo/go/cmath/log.go with 99% similarity]
libgo/go/math/cmplx/phase.go [moved from libgo/go/cmath/phase.go with 96% similarity]
libgo/go/math/cmplx/polar.go [moved from libgo/go/cmath/polar.go with 96% similarity]
libgo/go/math/cmplx/pow.go [moved from libgo/go/cmath/pow.go with 99% similarity]
libgo/go/math/cmplx/rect.go [moved from libgo/go/cmath/rect.go with 95% similarity]
libgo/go/math/cmplx/sin.go [moved from libgo/go/cmath/sin.go with 99% similarity]
libgo/go/math/cmplx/sqrt.go [moved from libgo/go/cmath/sqrt.go with 99% similarity]
libgo/go/math/cmplx/tan.go [moved from libgo/go/cmath/tan.go with 99% similarity]
libgo/go/math/gamma.go
libgo/go/math/rand/exp.go [moved from libgo/go/rand/exp.go with 100% similarity]
libgo/go/math/rand/normal.go [moved from libgo/go/rand/normal.go with 100% similarity]
libgo/go/math/rand/rand.go [moved from libgo/go/rand/rand.go with 100% similarity]
libgo/go/math/rand/rand_test.go [moved from libgo/go/rand/rand_test.go with 100% similarity]
libgo/go/math/rand/rng.go [moved from libgo/go/rand/rng.go with 100% similarity]
libgo/go/math/rand/zipf.go [moved from libgo/go/rand/zipf.go with 100% similarity]
libgo/go/math/tan.go
libgo/go/mime/multipart/multipart.go
libgo/go/mime/multipart/multipart_test.go
libgo/go/net/dnsclient.go
libgo/go/net/dnsclient_unix.go
libgo/go/net/http/cgi/child.go [moved from libgo/go/http/cgi/child.go with 99% similarity]
libgo/go/net/http/cgi/child_test.go [moved from libgo/go/http/cgi/child_test.go with 100% similarity]
libgo/go/net/http/cgi/host.go [moved from libgo/go/http/cgi/host.go with 99% similarity]
libgo/go/net/http/cgi/host_test.go [moved from libgo/go/http/cgi/host_test.go with 99% similarity]
libgo/go/net/http/cgi/matryoshka_test.go [moved from libgo/go/http/cgi/matryoshka_test.go with 99% similarity]
libgo/go/net/http/cgi/testdata/test.cgi [moved from libgo/go/http/cgi/testdata/test.cgi with 100% similarity, mode: 0644]
libgo/go/net/http/chunked.go [new file with mode: 0644]
libgo/go/net/http/client.go [moved from libgo/go/http/client.go with 99% similarity]
libgo/go/net/http/client_test.go [moved from libgo/go/http/client_test.go with 99% similarity]
libgo/go/net/http/cookie.go [moved from libgo/go/http/cookie.go with 100% similarity]
libgo/go/net/http/cookie_test.go [moved from libgo/go/http/cookie_test.go with 99% similarity]
libgo/go/net/http/doc.go [moved from libgo/go/http/doc.go with 100% similarity]
libgo/go/net/http/export_test.go [moved from libgo/go/http/export_test.go with 100% similarity]
libgo/go/net/http/fcgi/child.go [moved from libgo/go/http/fcgi/child.go with 99% similarity]
libgo/go/net/http/fcgi/fcgi.go [moved from libgo/go/http/fcgi/fcgi.go with 100% similarity]
libgo/go/net/http/fcgi/fcgi_test.go [moved from libgo/go/http/fcgi/fcgi_test.go with 100% similarity]
libgo/go/net/http/filetransport.go [moved from libgo/go/http/filetransport.go with 100% similarity]
libgo/go/net/http/filetransport_test.go [moved from libgo/go/http/filetransport_test.go with 99% similarity]
libgo/go/net/http/fs.go [moved from libgo/go/http/fs.go with 99% similarity]
libgo/go/net/http/fs_test.go [moved from libgo/go/http/fs_test.go with 99% similarity]
libgo/go/net/http/header.go [moved from libgo/go/http/header.go with 96% similarity]
libgo/go/net/http/header_test.go [moved from libgo/go/http/header_test.go with 100% similarity]
libgo/go/net/http/httptest/recorder.go [moved from libgo/go/http/httptest/recorder.go with 99% similarity]
libgo/go/net/http/httptest/server.go [moved from libgo/go/http/httptest/server.go with 99% similarity]
libgo/go/net/http/httputil/chunked.go [moved from libgo/go/http/chunked.go with 78% similarity]
libgo/go/net/http/httputil/chunked_test.go [new file with mode: 0644]
libgo/go/net/http/httputil/dump.go [new file with mode: 0644]
libgo/go/net/http/httputil/dump_test.go [new file with mode: 0644]
libgo/go/net/http/httputil/persist.go [moved from libgo/go/http/persist.go with 90% similarity]
libgo/go/net/http/httputil/reverseproxy.go [moved from libgo/go/http/reverseproxy.go with 87% similarity]
libgo/go/net/http/httputil/reverseproxy_test.go [moved from libgo/go/http/reverseproxy_test.go with 84% similarity]
libgo/go/net/http/lex.go [moved from libgo/go/http/lex.go with 100% similarity]
libgo/go/net/http/lex_test.go [moved from libgo/go/http/lex_test.go with 100% similarity]
libgo/go/net/http/pprof/pprof.go [moved from libgo/go/http/pprof/pprof.go with 99% similarity]
libgo/go/net/http/proxy_test.go [moved from libgo/go/http/proxy_test.go with 100% similarity]
libgo/go/net/http/range_test.go [moved from libgo/go/http/range_test.go with 100% similarity]
libgo/go/net/http/readrequest_test.go [moved from libgo/go/http/readrequest_test.go with 78% similarity]
libgo/go/net/http/request.go [moved from libgo/go/http/request.go with 92% similarity]
libgo/go/net/http/request_test.go [moved from libgo/go/http/request_test.go with 93% similarity]
libgo/go/net/http/requestwrite_test.go [moved from libgo/go/http/requestwrite_test.go with 93% similarity]
libgo/go/net/http/response.go [moved from libgo/go/http/response.go with 99% similarity]
libgo/go/net/http/response_test.go [moved from libgo/go/http/response_test.go with 99% similarity]
libgo/go/net/http/responsewrite_test.go [moved from libgo/go/http/responsewrite_test.go with 100% similarity]
libgo/go/net/http/serve_test.go [moved from libgo/go/http/serve_test.go with 99% similarity]
libgo/go/net/http/server.go [moved from libgo/go/http/server.go with 99% similarity]
libgo/go/net/http/sniff.go [moved from libgo/go/http/sniff.go with 97% similarity]
libgo/go/net/http/sniff_test.go [moved from libgo/go/http/sniff_test.go with 95% similarity]
libgo/go/net/http/status.go [moved from libgo/go/http/status.go with 100% similarity]
libgo/go/net/http/testdata/file [moved from libgo/go/http/testdata/file with 100% similarity]
libgo/go/net/http/testdata/index.html [moved from libgo/go/http/testdata/index.html with 100% similarity]
libgo/go/net/http/testdata/style.css [moved from libgo/go/http/testdata/style.css with 100% similarity]
libgo/go/net/http/transfer.go [moved from libgo/go/http/transfer.go with 89% similarity]
libgo/go/net/http/transport.go [moved from libgo/go/http/transport.go with 95% similarity]
libgo/go/net/http/transport_test.go [moved from libgo/go/http/transport_test.go with 99% similarity]
libgo/go/net/http/transport_windows.go [moved from libgo/go/http/transport_windows.go with 100% similarity]
libgo/go/net/http/triv.go [new file with mode: 0644]
libgo/go/net/ip_test.go
libgo/go/net/lookup_test.go
libgo/go/net/lookup_windows.go
libgo/go/net/mail/message.go [moved from libgo/go/mail/message.go with 100% similarity]
libgo/go/net/mail/message_test.go [moved from libgo/go/mail/message_test.go with 100% similarity]
libgo/go/net/net_test.go
libgo/go/net/parse_test.go
libgo/go/net/rpc/client.go [moved from libgo/go/rpc/client.go with 99% similarity]
libgo/go/net/rpc/debug.go [moved from libgo/go/rpc/debug.go with 98% similarity]
libgo/go/net/rpc/jsonrpc/all_test.go [moved from libgo/go/rpc/jsonrpc/all_test.go with 99% similarity]
libgo/go/net/rpc/jsonrpc/client.go [moved from libgo/go/rpc/jsonrpc/client.go with 99% similarity]
libgo/go/net/rpc/jsonrpc/server.go [moved from libgo/go/rpc/jsonrpc/server.go with 99% similarity]
libgo/go/net/rpc/server.go [moved from libgo/go/rpc/server.go with 99% similarity]
libgo/go/net/rpc/server_test.go [moved from libgo/go/rpc/server_test.go with 99% similarity]
libgo/go/net/server_test.go
libgo/go/net/smtp/auth.go [moved from libgo/go/smtp/auth.go with 100% similarity]
libgo/go/net/smtp/smtp.go [moved from libgo/go/smtp/smtp.go with 100% similarity]
libgo/go/net/smtp/smtp_test.go [moved from libgo/go/smtp/smtp_test.go with 100% similarity]
libgo/go/net/sock_bsd.go
libgo/go/net/textproto/reader.go
libgo/go/net/url/url.go [moved from libgo/go/url/url.go with 100% similarity]
libgo/go/net/url/url_test.go [moved from libgo/go/url/url_test.go with 100% similarity]
libgo/go/old/netchan/common.go
libgo/go/old/netchan/export.go
libgo/go/old/regexp/regexp.go
libgo/go/old/template/parse.go
libgo/go/old/template/template_test.go
libgo/go/os/dir_unix.go
libgo/go/os/env_plan9.go
libgo/go/os/env_windows.go
libgo/go/os/error_plan9.go
libgo/go/os/exec/exec.go [moved from libgo/go/exec/exec.go with 100% similarity]
libgo/go/os/exec/exec_test.go [moved from libgo/go/exec/exec_test.go with 100% similarity]
libgo/go/os/exec/lp_plan9.go [moved from libgo/go/exec/lp_plan9.go with 100% similarity]
libgo/go/os/exec/lp_test.go [moved from libgo/go/exec/lp_test.go with 100% similarity]
libgo/go/os/exec/lp_unix.go [moved from libgo/go/exec/lp_unix.go with 100% similarity]
libgo/go/os/exec/lp_windows.go [moved from libgo/go/exec/lp_windows.go with 100% similarity]
libgo/go/os/exec_plan9.go
libgo/go/os/file_unix.go
libgo/go/os/path_test.go
libgo/go/path/filepath/match.go
libgo/go/path/filepath/match_test.go
libgo/go/path/match.go
libgo/go/regexp/exec_test.go
libgo/go/regexp/regexp.go
libgo/go/regexp/syntax/parse.go
libgo/go/regexp/testdata/re2-exhaustive.txt.bz2 [new file with mode: 0644]
libgo/go/runtime/export_test.go
libgo/go/runtime/softfloat64_test.go
libgo/go/sort/sort_test.go
libgo/go/strconv/quote.go
libgo/go/strings/reader.go
libgo/go/strings/strings.go
libgo/go/strings/strings_test.go
libgo/go/sync/once_test.go
libgo/go/testing/quick/quick.go
libgo/go/testing/quick/quick_test.go
libgo/go/testing/script/script.go
libgo/go/text/scanner/scanner.go [moved from libgo/go/scanner/scanner.go with 99% similarity]
libgo/go/text/scanner/scanner_test.go [moved from libgo/go/scanner/scanner_test.go with 99% similarity]
libgo/go/text/tabwriter/tabwriter.go [moved from libgo/go/tabwriter/tabwriter.go with 99% similarity]
libgo/go/text/tabwriter/tabwriter_test.go [moved from libgo/go/tabwriter/tabwriter_test.go with 100% similarity]
libgo/go/text/template/doc.go [moved from libgo/go/template/doc.go with 100% similarity]
libgo/go/text/template/exec.go [moved from libgo/go/template/exec.go with 98% similarity]
libgo/go/text/template/exec_test.go [moved from libgo/go/template/exec_test.go with 97% similarity]
libgo/go/text/template/funcs.go [moved from libgo/go/template/funcs.go with 99% similarity]
libgo/go/text/template/helper.go [moved from libgo/go/template/helper.go with 100% similarity]
libgo/go/text/template/parse.go [moved from libgo/go/template/parse.go with 88% similarity]
libgo/go/text/template/parse/lex.go [moved from libgo/go/template/parse/lex.go with 99% similarity]
libgo/go/text/template/parse/lex_test.go [moved from libgo/go/template/parse/lex_test.go with 100% similarity]
libgo/go/text/template/parse/node.go [moved from libgo/go/template/parse/node.go with 100% similarity]
libgo/go/text/template/parse/parse.go [moved from libgo/go/template/parse/parse.go with 100% similarity]
libgo/go/text/template/parse/parse_test.go [moved from libgo/go/template/parse/parse_test.go with 100% similarity]
libgo/go/text/template/parse/set.go [moved from libgo/go/template/parse/set.go with 100% similarity]
libgo/go/text/template/set.go [moved from libgo/go/template/set.go with 94% similarity]
libgo/go/text/template/set_test.go [moved from libgo/go/template/set_test.go with 100% similarity]
libgo/go/text/template/testdata/file1.tmpl [moved from libgo/go/template/testdata/file1.tmpl with 100% similarity]
libgo/go/text/template/testdata/file2.tmpl [moved from libgo/go/template/testdata/file2.tmpl with 100% similarity]
libgo/go/text/template/testdata/tmpl1.tmpl [moved from libgo/go/template/testdata/tmpl1.tmpl with 100% similarity]
libgo/go/text/template/testdata/tmpl2.tmpl [moved from libgo/go/template/testdata/tmpl2.tmpl with 100% similarity]
libgo/go/time/sleep_test.go
libgo/go/time/sys.go
libgo/go/time/zoneinfo_windows.go
libgo/go/unicode/utf16/utf16.go [moved from libgo/go/utf16/utf16.go with 100% similarity]
libgo/go/unicode/utf16/utf16_test.go [moved from libgo/go/utf16/utf16_test.go with 99% similarity]
libgo/go/unicode/utf8/string.go [moved from libgo/go/utf8/string.go with 100% similarity]
libgo/go/unicode/utf8/string_test.go [moved from libgo/go/utf8/string_test.go with 98% similarity]
libgo/go/unicode/utf8/utf8.go [moved from libgo/go/utf8/utf8.go with 100% similarity]
libgo/go/unicode/utf8/utf8_test.go [moved from libgo/go/utf8/utf8_test.go with 99% similarity]
libgo/go/websocket/client.go
libgo/go/websocket/hixie.go
libgo/go/websocket/hixie_test.go
libgo/go/websocket/hybi.go
libgo/go/websocket/hybi_test.go
libgo/go/websocket/server.go
libgo/go/websocket/websocket.go
libgo/go/websocket/websocket_test.go
libgo/merge.sh
libgo/runtime/time.goc [new file with mode: 0644]

index 6071821..cc2cc71 100644 (file)
@@ -18,7 +18,7 @@ import (
        "fmt"
        "io"
        "os"
-       "template"
+       "text/template"
 )
 
 func main() {
index 6a67b17..461ee97 100644 (file)
@@ -9,14 +9,14 @@
 package main
 
 import (
-       "cmath"
        "fmt"
        "math"
+       "math/cmplx"
 )
 
-type Test struct{
-       f, g    complex128
-       out     complex128
+type Test struct {
+       f, g complex128
+       out  complex128
 }
 
 var nan = math.NaN()
@@ -25,9 +25,9 @@ var negzero = math.Copysign(0, -1)
 
 func calike(a, b complex128) bool {
        switch {
-       case cmath.IsInf(a) && cmath.IsInf(b):
+       case cmplx.IsInf(a) && cmplx.IsInf(b):
                return true
-       case cmath.IsNaN(a) && cmath.IsNaN(b):
+       case cmplx.IsNaN(a) && cmplx.IsNaN(b):
                return true
        }
        return a == b
@@ -36,7 +36,7 @@ func calike(a, b complex128) bool {
 func main() {
        bad := false
        for _, t := range tests {
-               x := t.f/t.g
+               x := t.f / t.g
                if !calike(x, t.out) {
                        if !bad {
                                fmt.Printf("BUG\n")
index f43709b..82fbf7f 100644 (file)
@@ -10,8 +10,8 @@
 package main
 
 import (
-       "http"
        "io/ioutil"     // GCCGO_ERROR "imported and not used"
+       "net/http"
        "os"
 )
 
index c3b9092..5a64d16 100644 (file)
@@ -6,7 +6,7 @@
 
 package main
 
-import "rand"
+import "math/rand"
 
 const Count = 1e5
 
index acb8831..c2603a0 100644 (file)
@@ -6,7 +6,7 @@
 
 package main
 
-import "rand"
+import "math/rand"
 
 const Count = 1e5
 
index f014b44..726e367 100644 (file)
@@ -10,7 +10,7 @@ package main
 
 import (
        "flag"
-       "rand"
+       "math/rand"
        "runtime"
        "unsafe"
 )
index d5ada26..6a7063e 100644 (file)
@@ -9,28 +9,29 @@ package main
 import (
        "fmt"
        "os"
-       "utf8"
+       "unicode/utf8"
 )
 
 func main() {
        s := "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe\U0010FFFFx"
-       expect := []int{ 0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x' }
+       expect := []rune{0, 0123, 0, 0xFFFD, 0xFFFD, 0x123, 0xbabe, 0xbabe, 0x10FFFF, 'x'}
        offset := 0
-       var i, c int
+       var i int
+       var c rune
        ok := true
        cnum := 0
        for i, c = range s {
-               rune, size := utf8.DecodeRuneInString(s[i:len(s)])  // check it another way
+               r, size := utf8.DecodeRuneInString(s[i:len(s)]) // check it another way
                if i != offset {
                        fmt.Printf("unexpected offset %d not %d\n", i, offset)
                        ok = false
                }
-               if rune != expect[cnum] {
-                       fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, rune, expect[cnum])
+               if r != expect[cnum] {
+                       fmt.Printf("unexpected rune %d from DecodeRuneInString: %x not %x\n", i, r, expect[cnum])
                        ok = false
                }
                if c != expect[cnum] {
-                       fmt.Printf("unexpected rune %d from range: %x not %x\n", i, rune, expect[cnum])
+                       fmt.Printf("unexpected rune %d from range: %x not %x\n", i, r, expect[cnum])
                        ok = false
                }
                offset += size
index a93fc29..9fba581 100644 (file)
@@ -6,10 +6,10 @@
 
 package main
 
-import "utf8"
+import "unicode/utf8"
 
 func main() {
-       var chars [6] int
+       var chars [6]rune
        chars[0] = 'a'
        chars[1] = 'b'
        chars[2] = 'c'
@@ -21,16 +21,22 @@ func main() {
                s += string(chars[i])
        }
        var l = len(s)
-       for w, i, j := 0,0,0; i < l; i += w {
-               var r int
+       for w, i, j := 0, 0, 0; i < l; i += w {
+               var r rune
                r, w = utf8.DecodeRuneInString(s[i:len(s)])
-               if w == 0 { panic("zero width in string") }
-               if r != chars[j] { panic("wrong value from string") }
+               if w == 0 {
+                       panic("zero width in string")
+               }
+               if r != chars[j] {
+                       panic("wrong value from string")
+               }
                j++
        }
        // encoded as bytes:  'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
        const L = 12
-       if L != l { panic("wrong length constructing array") }
+       if L != l {
+               panic("wrong length constructing array")
+       }
        a := make([]byte, L)
        a[0] = 'a'
        a[1] = 'b'
@@ -44,11 +50,15 @@ func main() {
        a[9] = 0xe8
        a[10] = 0xaa
        a[11] = 0x9e
-       for w, i, j := 0,0,0; i < L; i += w {
-               var r int
+       for w, i, j := 0, 0, 0; i < L; i += w {
+               var r rune
                r, w = utf8.DecodeRune(a[i:L])
-               if w == 0 { panic("zero width in bytes") }
-               if r != chars[j] { panic("wrong value from bytes") }
+               if w == 0 {
+                       panic("zero width in bytes")
+               }
+               if r != chars[j] {
+                       panic("wrong value from bytes")
+               }
                j++
        }
 }
index f55d80b..5e896c0 100644 (file)
@@ -1,4 +1,4 @@
-780c85032b17
+2f4482b89a6b
 
 The first line of this file holds the Mercurial revision number of the
 last merge done from the master library sources.
index 9a4588e..cd264e3 100644 (file)
@@ -100,56 +100,36 @@ toolexeclib_LIBRARIES = libgobegin.a
 toolexeclibgodir = $(toolexeclibdir)/go/$(gcc_version)/$(target_alias)
 
 toolexeclibgo_DATA = \
-       asn1.gox \
-       big.gox \
        bufio.gox \
        bytes.gox \
-       cmath.gox \
        crypto.gox \
-       csv.gox \
        errors.gox \
-       exec.gox \
        expvar.gox \
        flag.gox \
        fmt.gox \
-       gob.gox \
        hash.gox \
        html.gox \
-       http.gox \
        image.gox \
        io.gox \
-       json.gox \
        log.gox \
        math.gox \
-       mail.gox \
        mime.gox \
        net.gox \
        os.gox \
        patch.gox \
        path.gox \
-       rand.gox \
        reflect.gox \
        regexp.gox \
-       rpc.gox \
        runtime.gox \
-       scanner.gox \
-       smtp.gox \
        sort.gox \
        strconv.gox \
        strings.gox \
        sync.gox \
        syscall.gox \
-       syslog.gox \
-       tabwriter.gox \
-       template.gox \
        testing.gox \
        time.gox \
        unicode.gox \
-       url.gox \
-       utf16.gox \
-       utf8.gox \
-       websocket.gox \
-       xml.gox
+       websocket.gox
 
 toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
 
@@ -230,12 +210,17 @@ toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
 
 toolexeclibgoencoding_DATA = \
        encoding/ascii85.gox \
+       encoding/asn1.gox \
        encoding/base32.gox \
        encoding/base64.gox \
        encoding/binary.gox \
+       encoding/csv.gox \
        encoding/git85.gox \
+       encoding/gob.gox \
        encoding/hex.gox \
-       encoding/pem.gox
+       encoding/json.gox \
+       encoding/pem.gox \
+       encoding/xml.gox
 
 if LIBGO_IS_LINUX
 # exp_inotify_gox = exp/inotify.gox
@@ -267,11 +252,6 @@ toolexeclibgoexpsqldir = $(toolexeclibgoexpdir)/sql
 toolexeclibgoexpsql_DATA = \
        exp/sql/driver.gox
 
-toolexeclibgoexptemplatedir = $(toolexeclibgoexpdir)/template
-
-toolexeclibgoexptemplate_DATA = \
-       exp/template/html.gox
-
 toolexeclibgogodir = $(toolexeclibgodir)/go
 
 toolexeclibgogo_DATA = \
@@ -291,13 +271,10 @@ toolexeclibgohash_DATA = \
        hash/crc64.gox \
        hash/fnv.gox
 
-toolexeclibgohttpdir = $(toolexeclibgodir)/http
+toolexeclibgohtmldir = $(toolexeclibgodir)/html
 
-toolexeclibgohttp_DATA = \
-       http/cgi.gox \
-       http/fcgi.gox \
-       http/httptest.gox \
-       http/pprof.gox
+toolexeclibgohtml_DATA = \
+       html/template.gox
 
 toolexeclibgoimagedir = $(toolexeclibgodir)/image
 
@@ -321,6 +298,18 @@ toolexeclibgoiodir = $(toolexeclibgodir)/io
 toolexeclibgoio_DATA = \
        io/ioutil.gox
 
+toolexeclibgologdir = $(toolexeclibgodir)/log
+
+toolexeclibgolog_DATA = \
+       log/syslog.gox
+
+toolexeclibgomathdir = $(toolexeclibgodir)/math
+
+toolexeclibgomath_DATA = \
+       math/big.gox \
+       math/cmplx.gox \
+       math/rand.gox
+
 toolexeclibgomimedir = $(toolexeclibgodir)/mime
 
 toolexeclibgomime_DATA = \
@@ -330,7 +319,26 @@ toolexeclibgonetdir = $(toolexeclibgodir)/net
 
 toolexeclibgonet_DATA = \
        net/dict.gox \
-       net/textproto.gox
+       net/http.gox \
+       net/mail.gox \
+       net/rpc.gox \
+       net/smtp.gox \
+       net/textproto.gox \
+       net/url.gox
+
+toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http
+
+toolexeclibgonethttp_DATA = \
+       net/http/cgi.gox \
+       net/http/fcgi.gox \
+       net/http/httptest.gox \
+       net/http/httputil.gox \
+       net/http/pprof.gox
+
+toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc
+
+toolexeclibgonetrpc_DATA = \
+       net/rpc/jsonrpc.gox
 
 toolexeclibgoolddir = $(toolexeclibgodir)/old
 
@@ -342,6 +350,7 @@ toolexeclibgoold_DATA = \
 toolexeclibgoosdir = $(toolexeclibgodir)/os
 
 toolexeclibgoos_DATA = \
+       os/exec.gox \
        os/user.gox \
        os/signal.gox
 
@@ -355,22 +364,12 @@ toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp
 toolexeclibgoregexp_DATA = \
        regexp/syntax.gox
 
-toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
-
-toolexeclibgorpc_DATA = \
-       rpc/jsonrpc.gox
-
 toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
 
 toolexeclibgoruntime_DATA = \
        runtime/debug.gox \
        runtime/pprof.gox
 
-toolexeclibgotemplatedir = $(toolexeclibgodir)/template
-
-toolexeclibgotemplate_DATA = \
-       template/parse.gox
-
 toolexeclibgosyncdir = $(toolexeclibgodir)/sync
 
 toolexeclibgosync_DATA = \
@@ -383,6 +382,24 @@ toolexeclibgotesting_DATA = \
        testing/quick.gox \
        testing/script.gox
 
+toolexeclibgotextdir = $(toolexeclibgodir)/text
+
+toolexeclibgotext_DATA = \
+       text/scanner.gox \
+       text/tabwriter.gox \
+       text/template.gox
+
+toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
+
+toolexeclibgotexttemplate_DATA = \
+       text/template/parse.gox
+
+toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
+
+toolexeclibgounicode_DATA = \
+       unicode/utf16.gox \
+       unicode/utf8.gox
+
 if HAVE_SYS_MMAN_H
 runtime_mem_file = runtime/mem.c
 else
@@ -484,7 +501,8 @@ runtime_files = \
        runtime1.c \
        sema.c \
        sigqueue.c \
-       string.c
+       string.c \
+       time.c
 
 goc2c.$(OBJEXT): runtime/goc2c.c
        $(CC_FOR_BUILD) -c $(CFLAGS_FOR_BUILD) $<
@@ -516,21 +534,14 @@ sigqueue.c: $(srcdir)/runtime/sigqueue.goc goc2c
        ./goc2c --gcc --go-prefix libgo_runtime $< > $@.tmp
        mv -f $@.tmp $@
 
+time.c: $(srcdir)/runtime/time.goc goc2c
+       ./goc2c --gcc --go-prefix libgo_time $< > $@.tmp
+       mv -f $@.tmp $@
+
 %.c: $(srcdir)/runtime/%.goc goc2c
        ./goc2c --gcc $< > $@.tmp
        mv -f $@.tmp $@
 
-go_asn1_files = \
-       go/asn1/asn1.go \
-       go/asn1/common.go \
-       go/asn1/marshal.go
-
-go_big_files = \
-       go/big/arith.go \
-       go/big/int.go \
-       go/big/nat.go \
-       go/big/rat.go
-
 go_bufio_files = \
        go/bufio/bufio.go
 
@@ -541,36 +552,12 @@ go_bytes_files = \
 go_bytes_c_files = \
        go/bytes/indexbyte.c
 
-go_cmath_files = \
-       go/cmath/abs.go \
-       go/cmath/asin.go \
-       go/cmath/conj.go \
-       go/cmath/exp.go \
-       go/cmath/isinf.go \
-       go/cmath/isnan.go \
-       go/cmath/log.go \
-       go/cmath/phase.go \
-       go/cmath/polar.go \
-       go/cmath/pow.go \
-       go/cmath/rect.go \
-       go/cmath/sin.go \
-       go/cmath/sqrt.go \
-       go/cmath/tan.go
-
 go_crypto_files = \
        go/crypto/crypto.go
 
-go_csv_files = \
-       go/csv/reader.go \
-       go/csv/writer.go
-
 go_errors_files = \
        go/errors/errors.go
 
-go_exec_files = \
-       go/exec/exec.go \
-       go/exec/lp_unix.go
-
 go_expvar_files = \
        go/expvar/expvar.go
 
@@ -583,15 +570,6 @@ go_fmt_files = \
        go/fmt/print.go \
        go/fmt/scan.go
 
-go_gob_files = \
-       go/gob/decode.go \
-       go/gob/decoder.go \
-       go/gob/doc.go \
-       go/gob/encode.go \
-       go/gob/encoder.go \
-       go/gob/error.go \
-       go/gob/type.go
-
 go_hash_files = \
        go/hash/hash.go
 
@@ -605,25 +583,6 @@ go_html_files = \
        go/html/render.go \
        go/html/token.go
 
-go_http_files = \
-       go/http/chunked.go \
-       go/http/client.go \
-       go/http/cookie.go \
-       go/http/dump.go \
-       go/http/filetransport.go \
-       go/http/fs.go \
-       go/http/header.go \
-       go/http/lex.go \
-       go/http/persist.go \
-       go/http/request.go \
-       go/http/response.go \
-       go/http/reverseproxy.go \
-       go/http/server.go \
-       go/http/sniff.go \
-       go/http/status.go \
-       go/http/transfer.go \
-       go/http/transport.go
-
 go_image_files = \
        go/image/format.go \
        go/image/geom.go \
@@ -635,14 +594,6 @@ go_io_files = \
        go/io/io.go \
        go/io/pipe.go
 
-go_json_files = \
-       go/json/decode.go \
-       go/json/encode.go \
-       go/json/indent.go \
-       go/json/scanner.go \
-       go/json/stream.go \
-       go/json/tags.go
-
 go_log_files = \
        go/log/log.go
 
@@ -694,9 +645,6 @@ go_math_files = \
        go/math/tanh.go \
        go/math/unsafe.go
 
-go_mail_files = \
-       go/mail/message.go
-
 go_mime_files = \
        go/mime/grammar.go \
        go/mime/mediatype.go \
@@ -852,13 +800,6 @@ go_path_files = \
        go/path/match.go \
        go/path/path.go
 
-go_rand_files = \
-       go/rand/exp.go \
-       go/rand/normal.go \
-       go/rand/rand.go \
-       go/rand/rng.go \
-       go/rand/zipf.go
-
 go_reflect_files = \
        go/reflect/deepequal.go \
        go/reflect/type.go \
@@ -868,10 +809,10 @@ go_regexp_files = \
        go/regexp/exec.go \
        go/regexp/regexp.go
 
-go_rpc_files = \
-       go/rpc/client.go \
-       go/rpc/debug.go \
-       go/rpc/server.go
+go_net_rpc_files = \
+       go/net/rpc/client.go \
+       go/net/rpc/debug.go \
+       go/net/rpc/server.go
 
 go_runtime_files = \
        go/runtime/debug.go \
@@ -894,13 +835,6 @@ s-version: Makefile
        $(SHELL) $(srcdir)/../move-if-change version.go.tmp version.go
        $(STAMP) $@
 
-go_scanner_files = \
-       go/scanner/scanner.go
-
-go_smtp_files = \
-       go/smtp/auth.go \
-       go/smtp/smtp.go
-
 go_sort_files = \
        go/sort/search.go \
        go/sort/sort.go
@@ -927,31 +861,20 @@ go_sync_files = \
        go/sync/waitgroup.go
 
 if LIBGO_IS_SOLARIS
-go_syslog_file = go/syslog/syslog_libc.go
+go_syslog_file = go/log/syslog/syslog_libc.go
 else
 if LIBGO_IS_IRIX
-go_syslog_file = go/syslog/syslog_libc.go
+go_syslog_file = go/log/syslog/syslog_libc.go
 else
-go_syslog_file = go/syslog/syslog_unix.go
+go_syslog_file = go/log/syslog/syslog_unix.go
 endif
 endif
 
-go_syslog_files = \
-       go/syslog/syslog.go \
+go_log_syslog_files = \
+       go/log/syslog/syslog.go \
        $(go_syslog_file)
 go_syslog_c_files = \
-       go/syslog/syslog_c.c
-
-go_tabwriter_files = \
-       go/tabwriter/tabwriter.go
-
-go_template_files = \
-       go/template/doc.go \
-       go/template/exec.go \
-       go/template/funcs.go \
-       go/template/helper.go \
-       go/template/parse.go \
-       go/template/set.go
+       go/log/syslog/syslog_c.c
 
 go_testing_files = \
        go/testing/benchmark.go \
@@ -975,16 +898,6 @@ go_unicode_files = \
        go/unicode/letter.go \
        go/unicode/tables.go
 
-go_url_files = \
-       go/url/url.go
-
-go_utf16_files = \
-       go/utf16/utf16.go
-
-go_utf8_files = \
-       go/utf8/string.go \
-       go/utf8/utf8.go
-
 go_websocket_files = \
        go/websocket/client.go \
        go/websocket/hixie.go \
@@ -992,10 +905,6 @@ go_websocket_files = \
        go/websocket/server.go \
        go/websocket/websocket.go
 
-go_xml_files = \
-       go/xml/marshal.go \
-       go/xml/read.go \
-       go/xml/xml.go
 
 go_archive_tar_files = \
        go/archive/tar/common.go \
@@ -1183,6 +1092,10 @@ go_debug_pe_files = \
 
 go_encoding_ascii85_files = \
        go/encoding/ascii85/ascii85.go
+go_encoding_asn1_files = \
+       go/encoding/asn1/asn1.go \
+       go/encoding/asn1/common.go \
+       go/encoding/asn1/marshal.go
 go_encoding_base32_files = \
        go/encoding/base32/base32.go
 go_encoding_base64_files = \
@@ -1190,12 +1103,34 @@ go_encoding_base64_files = \
 go_encoding_binary_files = \
        go/encoding/binary/binary.go \
        go/encoding/binary/varint.go
+go_encoding_csv_files = \
+       go/encoding/csv/reader.go \
+       go/encoding/csv/writer.go
 go_encoding_git85_files = \
        go/encoding/git85/git.go
+go_encoding_gob_files = \
+       go/encoding/gob/decode.go \
+       go/encoding/gob/decoder.go \
+       go/encoding/gob/doc.go \
+       go/encoding/gob/encode.go \
+       go/encoding/gob/encoder.go \
+       go/encoding/gob/error.go \
+       go/encoding/gob/type.go
 go_encoding_hex_files = \
        go/encoding/hex/hex.go
+go_encoding_json_files = \
+       go/encoding/json/decode.go \
+       go/encoding/json/encode.go \
+       go/encoding/json/indent.go \
+       go/encoding/json/scanner.go \
+       go/encoding/json/stream.go \
+       go/encoding/json/tags.go
 go_encoding_pem_files = \
        go/encoding/pem/pem.go
+go_encoding_xml_files = \
+       go/encoding/xml/marshal.go \
+       go/encoding/xml/read.go \
+       go/encoding/xml/xml.go
 
 go_exp_ebnf_files = \
        go/exp/ebnf/ebnf.go \
@@ -1222,6 +1157,7 @@ go_exp_sql_files = \
 go_exp_ssh_files = \
        go/exp/ssh/channel.go \
        go/exp/ssh/client.go \
+       go/exp/ssh/client_auth.go \
        go/exp/ssh/common.go \
        go/exp/ssh/doc.go \
        go/exp/ssh/messages.go \
@@ -1248,23 +1184,10 @@ go_exp_sql_driver_files = \
        go/exp/sql/driver/driver.go \
        go/exp/sql/driver/types.go
 
-go_exp_template_html_files = \
-       go/exp/template/html/attr.go \
-       go/exp/template/html/clone.go \
-       go/exp/template/html/content.go \
-       go/exp/template/html/context.go \
-       go/exp/template/html/css.go \
-       go/exp/template/html/doc.go \
-       go/exp/template/html/error.go \
-       go/exp/template/html/escape.go \
-       go/exp/template/html/html.go \
-       go/exp/template/html/js.go \
-       go/exp/template/html/transition.go \
-       go/exp/template/html/url.go
-
 go_go_ast_files = \
        go/go/ast/ast.go \
        go/go/ast/filter.go \
+       go/go/ast/import.go \
        go/go/ast/print.go \
        go/go/ast/resolve.go \
        go/go/ast/scope.go \
@@ -1302,17 +1225,20 @@ go_hash_crc64_files = \
 go_hash_fnv_files = \
        go/hash/fnv/fnv.go
 
-go_http_cgi_files = \
-       go/http/cgi/child.go \
-       go/http/cgi/host.go
-go_http_fcgi_files = \
-       go/http/fcgi/child.go \
-       go/http/fcgi/fcgi.go
-go_http_httptest_files = \
-       go/http/httptest/recorder.go \
-       go/http/httptest/server.go
-go_http_pprof_files = \
-       go/http/pprof/pprof.go
+go_html_template_files = \
+       go/html/template/attr.go \
+       go/html/template/clone.go \
+       go/html/template/content.go \
+       go/html/template/context.go \
+       go/html/template/css.go \
+       go/html/template/doc.go \
+       go/html/template/error.go \
+       go/html/template/escape.go \
+       go/html/template/html.go \
+       go/html/template/js.go \
+       go/html/template/template.go \
+       go/html/template/transition.go \
+       go/html/template/url.go
 
 go_image_bmp_files = \
        go/image/bmp/reader.go
@@ -1354,6 +1280,33 @@ go_io_ioutil_files = \
        go/io/ioutil/ioutil.go \
        go/io/ioutil/tempfile.go
 
+go_math_big_files = \
+       go/math/big/arith.go \
+       go/math/big/int.go \
+       go/math/big/nat.go \
+       go/math/big/rat.go
+go_math_cmplx_files = \
+       go/math/cmplx/abs.go \
+       go/math/cmplx/asin.go \
+       go/math/cmplx/conj.go \
+       go/math/cmplx/exp.go \
+       go/math/cmplx/isinf.go \
+       go/math/cmplx/isnan.go \
+       go/math/cmplx/log.go \
+       go/math/cmplx/phase.go \
+       go/math/cmplx/polar.go \
+       go/math/cmplx/pow.go \
+       go/math/cmplx/rect.go \
+       go/math/cmplx/sin.go \
+       go/math/cmplx/sqrt.go \
+       go/math/cmplx/tan.go
+go_math_rand_files = \
+       go/math/rand/exp.go \
+       go/math/rand/normal.go \
+       go/math/rand/rand.go \
+       go/math/rand/rng.go \
+       go/math/rand/zipf.go
+
 go_mime_multipart_files = \
        go/mime/multipart/formdata.go \
        go/mime/multipart/multipart.go \
@@ -1361,13 +1314,52 @@ go_mime_multipart_files = \
 
 go_net_dict_files = \
        go/net/dict/dict.go
-
+go_net_http_files = \
+       go/net/http/chunked.go \
+       go/net/http/client.go \
+       go/net/http/cookie.go \
+       go/net/http/filetransport.go \
+       go/net/http/fs.go \
+       go/net/http/header.go \
+       go/net/http/lex.go \
+       go/net/http/request.go \
+       go/net/http/response.go \
+       go/net/http/server.go \
+       go/net/http/sniff.go \
+       go/net/http/status.go \
+       go/net/http/transfer.go \
+       go/net/http/transport.go
+go_net_mail_files = \
+       go/net/mail/message.go
+go_net_smtp_files = \
+       go/net/smtp/auth.go \
+       go/net/smtp/smtp.go
 go_net_textproto_files = \
        go/net/textproto/header.go \
        go/net/textproto/pipeline.go \
        go/net/textproto/reader.go \
        go/net/textproto/textproto.go \
        go/net/textproto/writer.go
+go_net_url_files = \
+       go/net/url/url.go
+
+go_net_http_cgi_files = \
+       go/net/http/cgi/child.go \
+       go/net/http/cgi/host.go
+go_net_http_fcgi_files = \
+       go/net/http/fcgi/child.go \
+       go/net/http/fcgi/fcgi.go
+go_net_http_httptest_files = \
+       go/net/http/httptest/recorder.go \
+       go/net/http/httptest/server.go
+go_net_http_pprof_files = \
+       go/net/http/pprof/pprof.go
+go_net_http_httputil_files = \
+       go/net/http/httputil/chunked.go \
+       go/net/http/httputil/dump.go \
+       go/net/http/httputil/persist.go \
+       go/net/http/httputil/reverseproxy.go
+
 
 go_old_netchan_files = \
        go/old/netchan/common.go \
@@ -1381,6 +1373,10 @@ go_old_template_files = \
        go/old/template/format.go \
        go/old/template/parse.go
 
+go_os_exec_files = \
+       go/os/exec/exec.go \
+       go/os/exec/lp_unix.go
+
 go_os_user_files = \
        go/os/user/user.go \
        go/os/user/lookup_unix.go
@@ -1401,20 +1397,29 @@ go_regexp_syntax_files = \
        go/regexp/syntax/regexp.go \
        go/regexp/syntax/simplify.go
 
-go_rpc_jsonrpc_files = \
-       go/rpc/jsonrpc/client.go \
-       go/rpc/jsonrpc/server.go
+go_net_rpc_jsonrpc_files = \
+       go/net/rpc/jsonrpc/client.go \
+       go/net/rpc/jsonrpc/server.go
 
 go_runtime_debug_files = \
        go/runtime/debug/stack.go
 go_runtime_pprof_files = \
        go/runtime/pprof/pprof.go
 
-go_template_parse_files = \
-       go/template/parse/lex.go \
-       go/template/parse/node.go \
-       go/template/parse/parse.go \
-       go/template/parse/set.go
+go_text_tabwriter_files = \
+       go/text/tabwriter/tabwriter.go
+go_text_template_files = \
+       go/text/template/doc.go \
+       go/text/template/exec.go \
+       go/text/template/funcs.go \
+       go/text/template/helper.go \
+       go/text/template/parse.go \
+       go/text/template/set.go
+go_text_template_parse_files = \
+       go/text/template/parse/lex.go \
+       go/text/template/parse/node.go \
+       go/text/template/parse/parse.go \
+       go/text/template/parse/set.go
 
 go_sync_atomic_files = \
        go/sync/atomic/doc.go
@@ -1430,6 +1435,15 @@ go_testing_quick_files = \
 go_testing_script_files = \
        go/testing/script/script.go
 
+go_text_scanner_files = \
+       go/text/scanner/scanner.go
+
+go_unicode_utf16_files = \
+       go/unicode/utf16/utf16.go
+go_unicode_utf8_files = \
+       go/unicode/utf8/string.go \
+       go/unicode/utf8/utf8.go
+
 # Define Syscall and Syscall6.
 if LIBGO_IS_RTEMS
 syscall_syscall_file = go/syscall/syscall_stubs.go
@@ -1619,56 +1633,35 @@ os_lib_inotify_lo =
 endif
 
 libgo_go_objs = \
-       asn1/asn1.lo \
-       big/big.lo \
        bufio/bufio.lo \
        bytes/bytes.lo \
        bytes/index.lo \
-       cmath/cmath.lo \
        crypto/crypto.lo \
-       csv/csv.lo \
        errors/errors.lo \
-       exec/exec.lo \
        expvar/expvar.lo \
        flag/flag.lo \
        fmt/fmt.lo \
-       gob/gob.lo \
        hash/hash.lo \
        html/html.lo \
-       http/http.lo \
        image/image.lo \
        io/io.lo \
-       json/json.lo \
        log/log.lo \
        math/math.lo \
-       mail/mail.lo \
-       mime/mime.lo \
        net/net.lo \
+       os/exec.lo \
        os/os.lo \
        patch/patch.lo \
        path/path.lo \
-       rand/rand.lo \
        reflect/reflect.lo \
        regexp/regexp.lo \
-       rpc/rpc.lo \
        runtime/runtime.lo \
-       scanner/scanner.lo \
-       smtp/smtp.lo \
        sort/sort.lo \
        strconv/strconv.lo \
        strings/strings.lo \
        sync/sync.lo \
-       syslog/syslog.lo \
-       syslog/syslog_c.lo \
-       tabwriter/tabwriter.lo \
-       template/template.lo \
        time/time.lo \
        unicode/unicode.lo \
-       url/url.lo \
-       utf16/utf16.lo \
-       utf8/utf8.lo \
        websocket/websocket.lo \
-       xml/xml.lo \
        archive/tar.lo \
        archive/zip.lo \
        compress/bzip2.lo \
@@ -1717,12 +1710,17 @@ libgo_go_objs = \
        debug/macho.lo \
        debug/pe.lo \
        encoding/ascii85.lo \
+       encoding/asn1.lo \
        encoding/base32.lo \
        encoding/base64.lo \
        encoding/binary.lo \
+       encoding/csv.lo \
        encoding/git85.lo \
+       encoding/gob.lo \
        encoding/hex.lo \
+       encoding/json.lo \
        encoding/pem.lo \
+       encoding/xml.lo \
        exp/ebnf.lo \
        exp/gui.lo \
        exp/norm.lo \
@@ -1733,7 +1731,7 @@ libgo_go_objs = \
        exp/types.lo \
        exp/gui/x11.lo \
        exp/sql/driver.lo \
-       exp/template/html.lo \
+       html/template.lo \
        go/ast.lo \
        go/build.lo \
        go/doc.lo \
@@ -1745,10 +1743,11 @@ libgo_go_objs = \
        hash/crc32.lo \
        hash/crc64.lo \
        hash/fnv.lo \
-       http/cgi.lo \
-       http/fcgi.lo \
-       http/httptest.lo \
-       http/pprof.lo \
+       net/http/cgi.lo \
+       net/http/fcgi.lo \
+       net/http/httptest.lo \
+       net/http/httputil.lo \
+       net/http/pprof.lo \
        image/bmp.lo \
        image/color.lo \
        image/draw.lo \
@@ -1759,9 +1758,20 @@ libgo_go_objs = \
        image/ycbcr.lo \
        index/suffixarray.lo \
        io/ioutil.lo \
+       log/syslog.lo \
+       log/syslog/syslog_c.lo \
+       math/big.lo \
+       math/cmplx.lo \
+       math/rand.lo \
+       mime/mime.lo \
        mime/multipart.lo \
        net/dict.lo \
+       net/http.lo \
+       net/mail.lo \
+       net/rpc.lo \
+       net/smtp.lo \
        net/textproto.lo \
+       net/url.lo \
        old/netchan.lo \
        old/regexp.lo \
        old/template.lo \
@@ -1770,7 +1780,7 @@ libgo_go_objs = \
        os/signal.lo \
        path/filepath.lo \
        regexp/syntax.lo \
-       rpc/jsonrpc.lo \
+       net/rpc/jsonrpc.lo \
        runtime/debug.lo \
        runtime/pprof.lo \
        sync/atomic.lo \
@@ -1778,11 +1788,16 @@ libgo_go_objs = \
        syscall/syscall.lo \
        syscall/errno.lo \
        syscall/wait.lo \
-       template/parse.lo \
+       text/scanner.lo \
+       text/tabwriter.lo \
+       text/template.lo \
+       text/template/parse.lo \
        testing/testing.lo \
        testing/iotest.lo \
        testing/quick.lo \
-       testing/script.lo
+       testing/script.lo \
+       unicode/utf16.lo \
+       unicode/utf8.lo
 
 libgo_la_SOURCES = $(runtime_files)
 
@@ -1871,36 +1886,23 @@ CHECK_DEPS = libgo.la libgobegin.a \
        $(toolexeclibgoexp_DATA) \
        $(toolexeclibgogo_DATA) \
        $(toolexeclibgohash_DATA) \
-       $(toolexeclibgohttp_DATA) \
        $(toolexeclibgoimage_DATA) \
        $(toolexeclibgoindex_DATA) \
        $(toolexeclibgoio_DATA) \
+       $(toolexeclibgolog_DATA) \
+       $(toolexeclibgomath_DATA) \
        $(toolexeclibgomime_DATA) \
        $(toolexeclibgonet_DATA) \
+       $(toolexeclibgonethttp_DATA) \
        $(toolexeclibgoos_DATA) \
        $(toolexeclibgopath_DATA) \
        $(toolexeclibgorpc_DATA) \
        $(toolexeclibgoruntime_DATA) \
        $(toolexeclibgosync_DATA) \
-       $(toolexeclibgotesting_DATA)
-
-@go_include@ asn1/asn1.lo.dep
-asn1/asn1.lo.dep: $(go_asn1_files)
-       $(BUILDDEPS)
-asn1/asn1.lo: $(go_asn1_files)
-       $(BUILDPACKAGE)
-asn1/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: asn1/check
-
-@go_include@ big/big.lo.dep
-big/big.lo.dep: $(go_big_files)
-       $(BUILDDEPS)
-big/big.lo: $(go_big_files)
-       $(BUILDPACKAGE)
-big/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: big/check
+       $(toolexeclibgotesting_DATA) \
+       $(toolexeclibgotext_DATA) \
+       $(toolexeclibgotexttemplate_DATA) \
+       $(toolexeclibgounicode_DATA)
 
 @go_include@ bufio/bufio.lo.dep
 bufio/bufio.lo.dep: $(go_bufio_files)
@@ -1922,15 +1924,6 @@ bytes/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: bytes/check
 
-@go_include@ cmath/cmath.lo.dep
-cmath/cmath.lo.dep: $(go_cmath_files)
-       $(BUILDDEPS)
-cmath/cmath.lo: $(go_cmath_files)
-       $(BUILDPACKAGE)
-cmath/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: cmath/check
-
 @go_include@ crypto/crypto.lo.dep
 crypto/crypto.lo.dep: $(go_crypto_files)
        $(BUILDDEPS)
@@ -1940,15 +1933,6 @@ crypto/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: crypto/check
 
-@go_include@ csv/csv.lo.dep
-csv/csv.lo.dep: $(go_csv_files)
-       $(BUILDDEPS)
-csv/csv.lo: $(go_csv_files)
-       $(BUILDPACKAGE)
-csv/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: csv/check
-
 @go_include@ errors/errors.lo.dep
 errors/errors.lo.dep: $(go_errors_files)
        $(BUILDDEPS)
@@ -1958,15 +1942,6 @@ errors/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: errors/check
 
-@go_include@ exec/exec.lo.dep
-exec/exec.lo.dep: $(go_exec_files)
-       $(BUILDDEPS)
-exec/exec.lo: $(go_exec_files)
-       $(BUILDPACKAGE)
-exec/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: exec/check
-
 @go_include@ expvar/expvar.lo.dep
 expvar/expvar.lo.dep: $(go_expvar_files)
        $(BUILDDEPS)
@@ -1994,15 +1969,6 @@ fmt/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: fmt/check
 
-@go_include@ gob/gob.lo.dep
-gob/gob.lo.dep: $(go_gob_files)
-       $(BUILDDEPS)
-gob/gob.lo: $(go_gob_files)
-       $(BUILDPACKAGE)
-gob/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: gob/check
-
 @go_include@ hash/hash.lo.dep
 hash/hash.lo.dep: $(go_hash_files)
        $(BUILDDEPS)
@@ -2021,15 +1987,6 @@ html/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: html/check
 
-@go_include@ http/http.lo.dep
-http/http.lo.dep: $(go_http_files)
-       $(BUILDDEPS)
-http/http.lo: $(go_http_files)
-       $(BUILDPACKAGE)
-http/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: http/check
-
 @go_include@ image/image.lo.dep
 image/image.lo.dep: $(go_image_files)
        $(BUILDDEPS)
@@ -2048,15 +2005,6 @@ io/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: io/check
 
-@go_include@ json/json.lo.dep
-json/json.lo.dep: $(go_json_files)
-       $(BUILDDEPS)
-json/json.lo: $(go_json_files)
-       $(BUILDPACKAGE)
-json/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: json/check
-
 @go_include@ log/log.lo.dep
 log/log.lo.dep: $(go_log_files)
        $(BUILDDEPS)
@@ -2075,15 +2023,6 @@ math/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: math/check
 
-@go_include@ mail/mail.lo.dep
-mail/mail.lo.dep: $(go_mail_files)
-       $(BUILDDEPS)
-mail/mail.lo: $(go_mail_files)
-       $(BUILDPACKAGE)
-mail/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: mail/check
-
 @go_include@ mime/mime.lo.dep
 mime/mime.lo.dep: $(go_mime_files)
        $(BUILDDEPS)
@@ -2133,15 +2072,6 @@ path/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: path/check
 
-@go_include@ rand/rand.lo.dep
-rand/rand.lo.dep: $(go_rand_files)
-       $(BUILDDEPS)
-rand/rand.lo: $(go_rand_files)
-       $(BUILDPACKAGE)
-rand/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: rand/check
-
 @go_include@ reflect/reflect.lo.dep
 reflect/reflect.lo.dep: $(go_reflect_files)
        $(BUILDDEPS)
@@ -2160,15 +2090,6 @@ regexp/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: regexp/check
 
-@go_include@ rpc/rpc.lo.dep
-rpc/rpc.lo.dep: $(go_rpc_files)
-       $(BUILDDEPS)
-rpc/rpc.lo: $(go_rpc_files)
-       $(BUILDPACKAGE)
-rpc/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: rpc/check
-
 @go_include@ runtime/runtime.lo.dep
 runtime/runtime.lo.dep: $(go_runtime_files)
        $(BUILDDEPS)
@@ -2178,23 +2099,15 @@ runtime/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: runtime/check
 
-@go_include@ scanner/scanner.lo.dep
-scanner/scanner.lo.dep: $(go_scanner_files)
-       $(BUILDDEPS)
-scanner/scanner.lo: $(go_scanner_files)
-       $(BUILDPACKAGE)
-scanner/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: scanner/check
-
-@go_include@ smtp/smtp.lo.dep
-smtp/smtp.lo.dep: $(go_smtp_files)
+@go_include@ text/scanner.lo.dep
+text/scanner.lo.dep: $(go_text_scanner_files)
        $(BUILDDEPS)
-smtp/smtp.lo: $(go_smtp_files)
+text/scanner.lo: $(go_text_scanner_files)
        $(BUILDPACKAGE)
-smtp/check: $(CHECK_DEPS)
+text/scanner/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/scanner
        @$(CHECK)
-.PHONY: smtp/check
+.PHONY: text/scanner/check
 
 @go_include@ sort/sort.lo.dep
 sort/sort.lo.dep: $(go_sort_files)
@@ -2232,35 +2145,6 @@ sync/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: sync/check
 
-@go_include@ syslog/syslog.lo.dep
-syslog/syslog.lo.dep: $(go_syslog_files)
-       $(BUILDDEPS)
-syslog/syslog.lo: $(go_syslog_files)
-       $(BUILDPACKAGE)
-syslog/syslog_c.lo: $(go_syslog_c_files) syslog/syslog.lo
-       $(LTCOMPILE) -c -o $@ $(srcdir)/go/syslog/syslog_c.c
-syslog/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: syslog/check
-
-@go_include@ tabwriter/tabwriter.lo.dep
-tabwriter/tabwriter.lo.dep: $(go_tabwriter_files)
-       $(BUILDDEPS)
-tabwriter/tabwriter.lo: $(go_tabwriter_files)
-       $(BUILDPACKAGE)
-tabwriter/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: tabwriter/check
-
-@go_include@ template/template.lo.dep
-template/template.lo.dep: $(go_template_files)
-       $(BUILDDEPS)
-template/template.lo: $(go_template_files)
-       $(BUILDPACKAGE)
-template/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: template/check
-
 @go_include@ testing/testing.lo.dep
 testing/testing.lo.dep: $(go_testing_files)
        $(BUILDDEPS)
@@ -2288,33 +2172,6 @@ unicode/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: unicode/check
 
-@go_include@ url/url.lo.dep
-url/url.lo.dep: $(go_url_files)
-       $(BUILDDEPS)
-url/url.lo: $(go_url_files)
-       $(BUILDPACKAGE)
-url/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: url/check
-
-@go_include@ utf16/utf16.lo.dep
-utf16/utf16.lo.dep: $(go_utf16_files)
-       $(BUILDDEPS)
-utf16/utf16.lo: $(go_utf16_files)
-       $(BUILDPACKAGE)
-utf16/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: utf16/check
-
-@go_include@ utf8/utf8.lo.dep
-utf8/utf8.lo.dep: $(go_utf8_files)
-       $(BUILDDEPS)
-utf8/utf8.lo: $(go_utf8_files)
-       $(BUILDPACKAGE)
-utf8/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: utf8/check
-
 @go_include@ websocket/websocket.lo.dep
 websocket/websocket.lo.dep: $(go_websocket_files)
        $(BUILDDEPS)
@@ -2324,15 +2181,6 @@ websocket/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: websocket/check
 
-@go_include@ xml/xml.lo.dep
-xml/xml.lo.dep: $(go_xml_files)
-       $(BUILDDEPS)
-xml/xml.lo: $(go_xml_files)
-       $(BUILDPACKAGE)
-xml/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: xml/check
-
 @go_include@ archive/tar.lo.dep
 archive/tar.lo.dep: $(go_archive_tar_files)
        $(BUILDDEPS)
@@ -2803,6 +2651,16 @@ debug/pe/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: debug/pe/check
 
+@go_include@ encoding/asn1.lo.dep
+encoding/asn1.lo.dep: $(go_encoding_asn1_files)
+       $(BUILDDEPS)
+encoding/asn1.lo: $(go_encoding_asn1_files)
+       $(BUILDPACKAGE)
+encoding/asn1/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/asn1
+       @$(CHECK)
+.PHONY: encoding/asn1/check
+
 @go_include@ encoding/ascii85.lo.dep
 encoding/ascii85.lo.dep: $(go_encoding_ascii85_files)
        $(BUILDDEPS)
@@ -2843,6 +2701,16 @@ encoding/binary/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/binary/check
 
+@go_include@ encoding/csv.lo.dep
+encoding/csv.lo.dep: $(go_encoding_csv_files)
+       $(BUILDDEPS)
+encoding/csv.lo: $(go_encoding_csv_files)
+       $(BUILDPACKAGE)
+encoding/csv/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/csv
+       @$(CHECK)
+.PHONY: encoding/csv/check
+
 @go_include@ encoding/git85.lo.dep
 encoding/git85.lo.dep: $(go_encoding_git85_files)
        $(BUILDDEPS)
@@ -2853,6 +2721,16 @@ encoding/git85/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/git85/check
 
+@go_include@ encoding/gob.lo.dep
+encoding/gob.lo.dep: $(go_encoding_gob_files)
+       $(BUILDDEPS)
+encoding/gob.lo: $(go_encoding_gob_files)
+       $(BUILDPACKAGE)
+encoding/gob/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/gob
+       @$(CHECK)
+.PHONY: encoding/gob/check
+
 @go_include@ encoding/hex.lo.dep
 encoding/hex.lo.dep: $(go_encoding_hex_files)
        $(BUILDDEPS)
@@ -2863,6 +2741,16 @@ encoding/hex/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/hex/check
 
+@go_include@ encoding/json.lo.dep
+encoding/json.lo.dep: $(go_encoding_json_files)
+       $(BUILDDEPS)
+encoding/json.lo: $(go_encoding_json_files)
+       $(BUILDPACKAGE)
+encoding/json/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/json
+       @$(CHECK)
+.PHONY: encoding/json/check
+
 @go_include@ encoding/pem.lo.dep
 encoding/pem.lo.dep: $(go_encoding_pem_files)
        $(BUILDDEPS)
@@ -2873,6 +2761,16 @@ encoding/pem/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/pem/check
 
+@go_include@ encoding/xml.lo.dep
+encoding/xml.lo.dep: $(go_encoding_xml_files)
+       $(BUILDDEPS)
+encoding/xml.lo: $(go_encoding_xml_files)
+       $(BUILDPACKAGE)
+encoding/xml/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/xml
+       @$(CHECK)
+.PHONY: encoding/xml/check
+
 @go_include@ exp/ebnf.lo.dep
 exp/ebnf.lo.dep: $(go_exp_ebnf_files)
        $(BUILDDEPS)
@@ -2983,15 +2881,15 @@ exp/sql/driver/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: exp/sql/driver/check
 
-@go_include@ exp/template/html.lo.dep
-exp/template/html.lo.dep: $(go_exp_template_html_files)
+@go_include@ html/template.lo.dep
+html/template.lo.dep: $(go_html_template_files)
        $(BUILDDEPS)
-exp/template/html.lo: $(go_exp_template_html_files)
+html/template.lo: $(go_html_template_files)
        $(BUILDPACKAGE)
-exp/template/html/check: $(CHECK_DEPS)
-       @$(MKDIR_P) exp/template/html
+html/template/check: $(CHECK_DEPS)
+       @$(MKDIR_P) html/template
        @$(CHECK)
-.PHONY: exp/template/html/check
+.PHONY: html/template/check
 
 @go_include@ go/ast.lo.dep
 go/ast.lo.dep: $(go_go_ast_files)
@@ -3112,46 +3010,6 @@ hash/fnv/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: hash/fnv/check
 
-@go_include@ http/cgi.lo.dep
-http/cgi.lo.dep: $(go_http_cgi_files)
-       $(BUILDDEPS)
-http/cgi.lo: $(go_http_cgi_files)
-       $(BUILDPACKAGE)
-http/cgi/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/cgi
-       @$(CHECK)
-.PHONY: http/cgi/check
-
-@go_include@ http/fcgi.lo.dep
-http/fcgi.lo.dep: $(go_http_fcgi_files)
-       $(BUILDDEPS)
-http/fcgi.lo: $(go_http_fcgi_files)
-       $(BUILDPACKAGE)
-http/fcgi/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/fcgi
-       @$(CHECK)
-.PHONY: http/fcgi/check
-
-@go_include@ http/httptest.lo.dep
-http/httptest.lo.dep: $(go_http_httptest_files)
-       $(BUILDDEPS)
-http/httptest.lo: $(go_http_httptest_files)
-       $(BUILDPACKAGE)
-http/httptest/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/httptest
-       @$(CHECK)
-.PHONY: http/httptest/check
-
-@go_include@ http/pprof.lo.dep
-http/pprof.lo.dep: $(go_http_pprof_files)
-       $(BUILDDEPS)
-http/pprof.lo: $(go_http_pprof_files)
-       $(BUILDPACKAGE)
-http/pprof/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/pprof
-       @$(CHECK)
-.PHONY: http/pprof/check
-
 @go_include@ image/bmp.lo.dep
 image/bmp.lo.dep: $(go_image_bmp_files)
        $(BUILDDEPS)
@@ -3252,6 +3110,48 @@ io/ioutil/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: io/ioutil/check
 
+@go_include@ log/syslog.lo.dep
+log/syslog.lo.dep: $(go_log_syslog_files)
+       $(BUILDDEPS)
+log/syslog.lo: $(go_log_syslog_files)
+       $(BUILDPACKAGE)
+log/syslog/syslog_c.lo: $(go_syslog_c_files) log/syslog.lo
+       $(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c
+log/syslog/check: $(CHECK_DEPS)
+       @$(MKDIR_P) log/syslog
+       @$(CHECK)
+.PHONY: log/syslog/check
+
+@go_include@ math/big.lo.dep
+math/big.lo.dep: $(go_math_big_files)
+       $(BUILDDEPS)
+math/big.lo: $(go_math_big_files)
+       $(BUILDPACKAGE)
+math/big/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/big
+       @$(CHECK)
+.PHONY: math/big/check
+
+@go_include@ math/cmplx.lo.dep
+math/cmplx.lo.dep: $(go_math_cmplx_files)
+       $(BUILDDEPS)
+math/cmplx.lo: $(go_math_cmplx_files)
+       $(BUILDPACKAGE)
+math/cmplx/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/cmplx
+       @$(CHECK)
+.PHONY: math/cmplx/check
+
+@go_include@ math/rand.lo.dep
+math/rand.lo.dep: $(go_math_rand_files)
+       $(BUILDDEPS)
+math/rand.lo: $(go_math_rand_files)
+       $(BUILDPACKAGE)
+math/rand/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/rand
+       @$(CHECK)
+.PHONY: math/rand/check
+
 @go_include@ mime/multipart.lo.dep
 mime/multipart.lo.dep: $(go_mime_multipart_files)
        $(BUILDDEPS)
@@ -3268,6 +3168,56 @@ net/dict.lo.dep: $(go_net_dict_files)
 net/dict.lo: $(go_net_dict_files)
        $(BUILDPACKAGE)
 
+@go_include@ net/http.lo.dep
+net/http.lo.dep: $(go_net_http_files)
+       $(BUILDDEPS)
+net/http.lo: $(go_net_http_files)
+       $(BUILDPACKAGE)
+net/http/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http
+       @$(CHECK)
+.PHONY: net/http/check
+
+@go_include@ net/mail.lo.dep
+net/mail.lo.dep: $(go_net_mail_files)
+       $(BUILDDEPS)
+net/mail.lo: $(go_net_mail_files)
+       $(BUILDPACKAGE)
+net/mail/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/mail
+       @$(CHECK)
+.PHONY: net/mail/check
+
+@go_include@ net/rpc.lo.dep
+net/rpc.lo.dep: $(go_net_rpc_files)
+       $(BUILDDEPS)
+net/rpc.lo: $(go_net_rpc_files)
+       $(BUILDPACKAGE)
+net/rpc/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/rpc
+       @$(CHECK)
+.PHONY: net/rpc/check
+
+@go_include@ net/smtp.lo.dep
+net/smtp.lo.dep: $(go_net_smtp_files)
+       $(BUILDDEPS)
+net/smtp.lo: $(go_net_smtp_files)
+       $(BUILDPACKAGE)
+net/smtp/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/smtp
+       @$(CHECK)
+.PHONY: net/smtp/check
+
+@go_include@ net/url.lo.dep
+net/url.lo.dep: $(go_net_url_files)
+       $(BUILDDEPS)
+net/url.lo: $(go_net_url_files)
+       $(BUILDPACKAGE)
+net/url/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/url
+       @$(CHECK)
+.PHONY: net/url/check
+
 @go_include@ net/textproto.lo.dep
 net/textproto.lo.dep: $(go_net_textproto_files)
        $(BUILDDEPS)
@@ -3278,6 +3228,66 @@ net/textproto/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: net/textproto/check
 
+@go_include@ net/http/cgi.lo.dep
+net/http/cgi.lo.dep: $(go_net_http_cgi_files)
+       $(BUILDDEPS)
+net/http/cgi.lo: $(go_net_http_cgi_files)
+       $(BUILDPACKAGE)
+net/http/cgi/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/cgi
+       @$(CHECK)
+.PHONY: net/http/cgi/check
+
+@go_include@ net/http/fcgi.lo.dep
+net/http/fcgi.lo.dep: $(go_net_http_fcgi_files)
+       $(BUILDDEPS)
+net/http/fcgi.lo: $(go_net_http_fcgi_files)
+       $(BUILDPACKAGE)
+net/http/fcgi/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/fcgi
+       @$(CHECK)
+.PHONY: net/http/fcgi/check
+
+@go_include@ net/http/httptest.lo.dep
+net/http/httptest.lo.dep: $(go_net_http_httptest_files)
+       $(BUILDDEPS)
+net/http/httptest.lo: $(go_net_http_httptest_files)
+       $(BUILDPACKAGE)
+net/http/httptest/check: $(check_deps)
+       @$(MKDIR_P) net/http/httptest
+       @$(CHECK)
+.PHONY: net/http/httptest/check
+
+@go_include@ net/http/httputil.lo.dep
+net/http/httputil.lo.dep: $(go_net_http_httputil_files)
+       $(BUILDDEPS)
+net/http/httputil.lo: $(go_net_http_httputil_files)
+       $(BUILDPACKAGE)
+net/http/httputil/check: $(check_deps)
+       @$(MKDIR_P) net/http/httputil
+       @$(CHECK)
+.PHONY: net/http/httputil/check
+
+@go_include@ net/http/pprof.lo.dep
+net/http/pprof.lo.dep: $(go_net_http_pprof_files)
+       $(BUILDDEPS)
+net/http/pprof.lo: $(go_net_http_pprof_files)
+       $(BUILDPACKAGE)
+net/http/pprof/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/pprof
+       @$(CHECK)
+.PHONY: net/http/pprof/check
+
+@go_include@ net/rpc/jsonrpc.lo.dep
+net/rpc/jsonrpc.lo.dep: $(go_net_rpc_jsonrpc_files)
+       $(BUILDDEPS)
+net/rpc/jsonrpc.lo: $(go_net_rpc_jsonrpc_files)
+       $(BUILDPACKAGE)
+net/rpc/jsonrpc/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/rpc/jsonrpc
+       @$(CHECK)
+.PHONY: net/rpc/jsonrpc/check
+
 @go_include@ old/netchan.lo.dep
 old/netchan.lo.dep: $(go_old_netchan_files)
        $(BUILDDEPS)
@@ -3308,6 +3318,16 @@ old/template/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: old/template/check
 
+@go_include@ os/exec.lo.dep
+os/exec.lo.dep: $(go_os_exec_files)
+       $(BUILDDEPS)
+os/exec.lo: $(go_os_exec_files)
+       $(BUILDPACKAGE)
+os/exec/check: $(CHECK_DEPS)
+       @$(MKDIR_P) os/exec
+       @$(CHECK)
+.PHONY: os/exec/check
+
 @go_include@ os/user.lo.dep
 os/user.lo.dep: $(go_os_user_files)
        $(BUILDDEPS)
@@ -3348,16 +3368,6 @@ regexp/syntax/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: regexp/syntax/check
 
-@go_include@ rpc/jsonrpc.lo.dep
-rpc/jsonrpc.lo.dep: $(go_rpc_jsonrpc_files)
-       $(BUILDDEPS)
-rpc/jsonrpc.lo: $(go_rpc_jsonrpc_files)
-       $(BUILDPACKAGE)
-rpc/jsonrpc/check: $(CHECK_DEPS)
-       @$(MKDIR_P) rpc/jsonrpc
-       @$(CHECK)
-.PHONY: rpc/jsonrpc/check
-
 @go_include@ runtime/debug.lo.dep
 runtime/debug.lo.dep: $(go_runtime_debug_files)
        $(BUILDDEPS)
@@ -3390,15 +3400,34 @@ sync/atomic/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: sync/atomic/check
 
-@go_include@ template/parse.lo.dep
-template/parse.lo.dep: $(go_template_parse_files)
+@go_include@ text/tabwriter.lo.dep
+text/tabwriter.lo.dep: $(go_text_tabwriter_files)
+       $(BUILDDEPS)
+text/tabwriter.lo: $(go_text_tabwriter_files)
+       $(BUILDPACKAGE)
+text/tabwriter/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/tabwriter
+       @$(CHECK)
+.PHONY: text/tabwriter/check
+
+@go_include@ text/template.lo.dep
+text/template.lo.dep: $(go_text_template_files)
        $(BUILDDEPS)
-template/parse.lo: $(go_template_parse_files)
+text/template.lo: $(go_text_template_files)
        $(BUILDPACKAGE)
-template/parse/check: $(CHECK_DEPS)
-       @$(MKDIR_P) template/parse
+text/template/check: $(CHECK_DEPS)
        @$(CHECK)
-.PHONY: template/parse/check
+.PHONY: text/template/check
+
+@go_include@ text/template/parse.lo.dep
+text/template/parse.lo.dep: $(go_text_template_parse_files)
+       $(BUILDDEPS)
+text/template/parse.lo: $(go_text_template_parse_files)
+       $(BUILDPACKAGE)
+text/template/parse/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/template/parse
+       @$(CHECK)
+.PHONY: text/template/parse/check
 
 @go_include@ testing/iotest.lo.dep
 testing/iotest.lo.dep: $(go_testing_iotest_files)
@@ -3430,6 +3459,26 @@ testing/script/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: testing/script/check
 
+@go_include@ unicode/utf16.lo.dep
+unicode/utf16.lo.dep: $(go_unicode_utf16_files)
+       $(BUILDDEPS)
+unicode/utf16.lo: $(go_unicode_utf16_files)
+       $(BUILDPACKAGE)
+unicode/utf16/check: $(CHECK_DEPS)
+       @$(MKDIR_P) unicode/utf16
+       @$(CHECK)
+.PHONY: unicode/utf16/check
+
+@go_include@ unicode/utf8.lo.dep
+unicode/utf8.lo.dep: $(go_unicode_utf8_files)
+       $(BUILDDEPS)
+unicode/utf8.lo: $(go_unicode_utf8_files)
+       $(BUILDPACKAGE)
+unicode/utf8/check: $(CHECK_DEPS)
+       @$(MKDIR_P) unicode/utf8
+       @$(CHECK)
+.PHONY: unicode/utf8/check
+
 @go_include@ syscall/syscall.lo.dep
 syscall/syscall.lo.dep: $(go_syscall_files)
        $(BUILDDEPS)
@@ -3445,50 +3494,32 @@ BUILDGOX = \
        f=`echo $< | sed -e 's/.lo$$/.o/'`; \
        $(OBJCOPY) -j .go_export $$f $@.tmp && mv -f $@.tmp $@
 
-asn1.gox: asn1/asn1.lo
-       $(BUILDGOX)
-big.gox: big/big.lo
-       $(BUILDGOX)
 bufio.gox: bufio/bufio.lo
        $(BUILDGOX)
 bytes.gox: bytes/bytes.lo
        $(BUILDGOX)
-cmath.gox: cmath/cmath.lo
-       $(BUILDGOX)
 crypto.gox: crypto/crypto.lo
        $(BUILDGOX)
-csv.gox: csv/csv.lo
-       $(BUILDGOX)
 errors.gox: errors/errors.lo
        $(BUILDGOX)
-exec.gox: exec/exec.lo
-       $(BUILDGOX)
 expvar.gox: expvar/expvar.lo
        $(BUILDGOX)
 flag.gox: flag/flag.lo
        $(BUILDGOX)
 fmt.gox: fmt/fmt.lo
        $(BUILDGOX)
-gob.gox: gob/gob.lo
-       $(BUILDGOX)
 hash.gox: hash/hash.lo
        $(BUILDGOX)
 html.gox: html/html.lo
        $(BUILDGOX)
-http.gox: http/http.lo
-       $(BUILDGOX)
 image.gox: image/image.lo
        $(BUILDGOX)
 io.gox: io/io.lo
        $(BUILDGOX)
-json.gox: json/json.lo
-       $(BUILDGOX)
 log.gox: log/log.lo
        $(BUILDGOX)
 math.gox: math/math.lo
        $(BUILDGOX)
-mail.gox: mail/mail.lo
-       $(BUILDGOX)
 mime.gox: mime/mime.lo
        $(BUILDGOX)
 net.gox: net/net.lo
@@ -3499,20 +3530,12 @@ patch.gox: patch/patch.lo
        $(BUILDGOX)
 path.gox: path/path.lo
        $(BUILDGOX)
-rand.gox: rand/rand.lo
-       $(BUILDGOX)
 reflect.gox: reflect/reflect.lo
        $(BUILDGOX)
 regexp.gox: regexp/regexp.lo
        $(BUILDGOX)
-rpc.gox: rpc/rpc.lo
-       $(BUILDGOX)
 runtime.gox: runtime/runtime.lo
        $(BUILDGOX)
-scanner.gox: scanner/scanner.lo
-       $(BUILDGOX)
-smtp.gox: smtp/smtp.lo
-       $(BUILDGOX)
 sort.gox: sort/sort.lo
        $(BUILDGOX)
 strconv.gox: strconv/strconv.lo
@@ -3521,30 +3544,16 @@ strings.gox: strings/strings.lo
        $(BUILDGOX)
 sync.gox: sync/sync.lo
        $(BUILDGOX)
-syslog.gox: syslog/syslog.lo
-       $(BUILDGOX)
 syscall.gox: syscall/syscall.lo
        $(BUILDGOX)
-tabwriter.gox: tabwriter/tabwriter.lo
-       $(BUILDGOX)
-template.gox: template/template.lo
-       $(BUILDGOX)
 testing.gox: testing/testing.lo
        $(BUILDGOX)
 time.gox: time/time.lo
        $(BUILDGOX)
 unicode.gox: unicode/unicode.lo
        $(BUILDGOX)
-url.gox: url/url.lo
-       $(BUILDGOX)
-utf16.gox: utf16/utf16.lo
-       $(BUILDGOX)
-utf8.gox: utf8/utf8.lo
-       $(BUILDGOX)
 websocket.gox: websocket/websocket.lo
        $(BUILDGOX)
-xml.gox: xml/xml.lo
-       $(BUILDGOX)
 
 archive/tar.gox: archive/tar.lo
        $(BUILDGOX)
@@ -3649,18 +3658,28 @@ debug/pe.gox: debug/pe.lo
 
 encoding/ascii85.gox: encoding/ascii85.lo
        $(BUILDGOX)
+encoding/asn1.gox: encoding/asn1.lo
+       $(BUILDGOX)
 encoding/base32.gox: encoding/base32.lo
        $(BUILDGOX)
 encoding/base64.gox: encoding/base64.lo
        $(BUILDGOX)
 encoding/binary.gox: encoding/binary.lo
        $(BUILDGOX)
+encoding/csv.gox: encoding/csv.lo
+       $(BUILDGOX)
 encoding/git85.gox: encoding/git85.lo
        $(BUILDGOX)
+encoding/gob.gox: encoding/gob.lo
+       $(BUILDGOX)
 encoding/hex.gox: encoding/hex.lo
        $(BUILDGOX)
+encoding/json.gox: encoding/json.lo
+       $(BUILDGOX)
 encoding/pem.gox: encoding/pem.lo
        $(BUILDGOX)
+encoding/xml.gox: encoding/xml.lo
+       $(BUILDGOX)
 
 exp/ebnf.gox: exp/ebnf.lo
        $(BUILDGOX)
@@ -3687,7 +3706,7 @@ exp/gui/x11.gox: exp/gui/x11.lo
 exp/sql/driver.gox: exp/sql/driver.lo
        $(BUILDGOX)
 
-exp/template/html.gox: exp/template/html.lo
+html/template.gox: html/template.lo
        $(BUILDGOX)
 
 go/ast.gox: go/ast.lo
@@ -3714,15 +3733,6 @@ hash/crc64.gox: hash/crc64.lo
 hash/fnv.gox: hash/fnv.lo
        $(BUILDGOX)
 
-http/cgi.gox: http/cgi.lo
-       $(BUILDGOX)
-http/fcgi.gox: http/fcgi.lo
-       $(BUILDGOX)
-http/httptest.gox: http/httptest.lo
-       $(BUILDGOX)
-http/pprof.gox: http/pprof.lo
-       $(BUILDGOX)
-
 image/bmp.gox: image/bmp.lo
        $(BUILDGOX)
 image/color.gox: image/color.lo
@@ -3746,13 +3756,47 @@ index/suffixarray.gox: index/suffixarray.lo
 io/ioutil.gox: io/ioutil.lo
        $(BUILDGOX)
 
+log/syslog.gox: log/syslog.lo
+       $(BUILDGOX)
+
+math/big.gox: math/big.lo
+       $(BUILDGOX)
+math/cmplx.gox: math/cmplx.lo
+       $(BUILDGOX)
+math/rand.gox: math/rand.lo
+       $(BUILDGOX)
+
 mime/multipart.gox: mime/multipart.lo
        $(BUILDGOX)
 
 net/dict.gox: net/dict.lo
        $(BUILDGOX)
+net/http.gox: net/http.lo
+       $(BUILDGOX)
+net/mail.gox: net/mail.lo
+       $(BUILDGOX)
+net/rpc.gox: net/rpc.lo
+       $(BUILDGOX)
+net/smtp.gox: net/smtp.lo
+       $(BUILDGOX)
 net/textproto.gox: net/textproto.lo
        $(BUILDGOX)
+net/url.gox: net/url.lo
+       $(BUILDGOX)
+
+net/http/cgi.gox: net/http/cgi.lo
+       $(BUILDGOX)
+net/http/fcgi.gox: net/http/fcgi.lo
+       $(BUILDGOX)
+net/http/httptest.gox: net/http/httptest.lo
+       $(BUILDGOX)
+net/http/httputil.gox: net/http/httputil.lo
+       $(BUILDGOX)
+net/http/pprof.gox: net/http/pprof.lo
+       $(BUILDGOX)
+
+net/rpc/jsonrpc.gox: net/rpc/jsonrpc.lo
+       $(BUILDGOX)
 
 old/netchan.gox: old/netchan.lo
        $(BUILDGOX)
@@ -3761,6 +3805,8 @@ old/regexp.gox: old/regexp.lo
 old/template.gox: old/template.lo
        $(BUILDGOX)
 
+os/exec.gox: os/exec.lo
+       $(BUILDGOX)
 os/user.gox: os/user.lo
        $(BUILDGOX)
 os/signal.gox: os/signal.lo
@@ -3772,9 +3818,6 @@ path/filepath.gox: path/filepath.lo
 regexp/syntax.gox: regexp/syntax.lo
        $(BUILDGOX)
 
-rpc/jsonrpc.gox: rpc/jsonrpc.lo
-       $(BUILDGOX)
-
 runtime/debug.gox: runtime/debug.lo
        $(BUILDGOX)
 runtime/pprof.gox: runtime/pprof.lo
@@ -3783,7 +3826,13 @@ runtime/pprof.gox: runtime/pprof.lo
 sync/atomic.gox: sync/atomic.lo
        $(BUILDGOX)
 
-template/parse.gox: template/parse.lo
+text/scanner.gox: text/scanner.lo
+       $(BUILDGOX)
+text/tabwriter.gox: text/tabwriter.lo
+       $(BUILDGOX)
+text/template.gox: text/template.lo
+       $(BUILDGOX)
+text/template/parse.gox: text/template/parse.lo
        $(BUILDGOX)
 
 testing/iotest.gox: testing/iotest.lo
@@ -3793,6 +3842,11 @@ testing/quick.gox: testing/quick.lo
 testing/script.gox: testing/script.lo
        $(BUILDGOX)
 
+unicode/utf16.gox: unicode/utf16.lo
+       $(BUILDGOX)
+unicode/utf8.gox: unicode/utf8.lo
+       $(BUILDGOX)
+
 if LIBGO_IS_LINUX
 # exp_inotify_check = exp/inotify/check
 exp_inotify_check =
@@ -3801,52 +3855,32 @@ exp_inotify_check =
 endif
 
 TEST_PACKAGES = \
-       asn1/check \
-       big/check \
        bufio/check \
        bytes/check \
-       cmath/check \
-       csv/check \
        errors/check \
-       exec/check \
        expvar/check \
        flag/check \
        fmt/check \
-       gob/check \
        html/check \
-       http/check \
        image/check \
        io/check \
-       json/check \
        log/check \
        math/check \
-       mail/check \
        mime/check \
        net/check \
        os/check \
        patch/check \
        path/check \
-       rand/check \
        reflect/check \
        regexp/check \
-       rpc/check \
        runtime/check \
-       scanner/check \
-       smtp/check \
        sort/check \
        strconv/check \
        strings/check \
        sync/check \
-       syslog/check \
-       tabwriter/check \
-       template/check \
        time/check \
        unicode/check \
-       url/check \
-       utf16/check \
-       utf8/check \
        websocket/check \
-       xml/check \
        archive/tar/check \
        archive/zip/check \
        compress/bzip2/check \
@@ -3892,12 +3926,17 @@ TEST_PACKAGES = \
        debug/macho/check \
        debug/pe/check \
        encoding/ascii85/check \
+       encoding/asn1/check \
        encoding/base32/check \
        encoding/base64/check \
        encoding/binary/check \
+       encoding/csv/check \
        encoding/git85/check \
+       encoding/gob/check \
        encoding/hex/check \
+       encoding/json/check \
        encoding/pem/check \
+       encoding/xml/check \
        exp/ebnf/check \
        $(exp_inotify_check) \
        exp/norm/check \
@@ -3905,7 +3944,7 @@ TEST_PACKAGES = \
        exp/sql/check \
        exp/ssh/check \
        exp/terminal/check \
-       exp/template/html/check \
+       html/template/check \
        go/ast/check \
        $(go_build_check_omitted_since_it_calls_6g) \
        go/parser/check \
@@ -3917,8 +3956,6 @@ TEST_PACKAGES = \
        hash/crc32/check \
        hash/crc64/check \
        hash/fnv/check \
-       http/cgi/check \
-       http/fcgi/check \
        image/draw/check \
        image/jpeg/check \
        image/png/check \
@@ -3926,20 +3963,38 @@ TEST_PACKAGES = \
        image/ycbcr/check \
        index/suffixarray/check \
        io/ioutil/check \
+       log/syslog/check \
+       math/big/check \
+       math/cmplx/check \
+       math/rand/check \
        mime/multipart/check \
+       net/http/check \
+       net/http/cgi/check \
+       net/http/fcgi/check \
+       net/http/httputil/check \
+       net/mail/check \
+       net/rpc/check \
+       net/smtp/check \
        net/textproto/check \
+       net/url/check \
+       net/rpc/jsonrpc/check \
        old/netchan/check \
        old/regexp/check \
        old/template/check \
+       os/exec/check \
        os/user/check \
        os/signal/check \
        path/filepath/check \
        regexp/syntax/check \
-       rpc/jsonrpc/check \
        sync/atomic/check \
-       template/parse/check \
+       text/scanner/check \
+       text/tabwriter/check \
+       text/template/check \
+       text/template/parse/check \
        testing/quick/check \
-       testing/script/check
+       testing/script/check \
+       unicode/utf16/check \
+       unicode/utf8/check
 
 check: check-tail
 check-recursive: check-head
index 4cb4b5f..11b8650 100644 (file)
@@ -104,24 +104,28 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
        "$(DESTDIR)$(toolexeclibgoexpdir)" \
        "$(DESTDIR)$(toolexeclibgoexpguidir)" \
        "$(DESTDIR)$(toolexeclibgoexpsqldir)" \
-       "$(DESTDIR)$(toolexeclibgoexptemplatedir)" \
        "$(DESTDIR)$(toolexeclibgogodir)" \
        "$(DESTDIR)$(toolexeclibgohashdir)" \
-       "$(DESTDIR)$(toolexeclibgohttpdir)" \
+       "$(DESTDIR)$(toolexeclibgohtmldir)" \
        "$(DESTDIR)$(toolexeclibgoimagedir)" \
        "$(DESTDIR)$(toolexeclibgoindexdir)" \
        "$(DESTDIR)$(toolexeclibgoiodir)" \
+       "$(DESTDIR)$(toolexeclibgologdir)" \
+       "$(DESTDIR)$(toolexeclibgomathdir)" \
        "$(DESTDIR)$(toolexeclibgomimedir)" \
        "$(DESTDIR)$(toolexeclibgonetdir)" \
+       "$(DESTDIR)$(toolexeclibgonethttpdir)" \
+       "$(DESTDIR)$(toolexeclibgonetrpcdir)" \
        "$(DESTDIR)$(toolexeclibgoolddir)" \
        "$(DESTDIR)$(toolexeclibgoosdir)" \
        "$(DESTDIR)$(toolexeclibgopathdir)" \
        "$(DESTDIR)$(toolexeclibgoregexpdir)" \
-       "$(DESTDIR)$(toolexeclibgorpcdir)" \
        "$(DESTDIR)$(toolexeclibgoruntimedir)" \
        "$(DESTDIR)$(toolexeclibgosyncdir)" \
-       "$(DESTDIR)$(toolexeclibgotemplatedir)" \
-       "$(DESTDIR)$(toolexeclibgotestingdir)"
+       "$(DESTDIR)$(toolexeclibgotestingdir)" \
+       "$(DESTDIR)$(toolexeclibgotextdir)" \
+       "$(DESTDIR)$(toolexeclibgotexttemplatedir)" \
+       "$(DESTDIR)$(toolexeclibgounicodedir)"
 LIBRARIES = $(toolexeclib_LIBRARIES)
 ARFLAGS = cru
 libgobegin_a_AR = $(AR) $(ARFLAGS)
@@ -130,27 +134,22 @@ am_libgobegin_a_OBJECTS = go-main.$(OBJEXT)
 libgobegin_a_OBJECTS = $(am_libgobegin_a_OBJECTS)
 LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
 am__DEPENDENCIES_1 =
-am__DEPENDENCIES_2 = asn1/asn1.lo big/big.lo bufio/bufio.lo \
-       bytes/bytes.lo bytes/index.lo cmath/cmath.lo crypto/crypto.lo \
-       csv/csv.lo errors/errors.lo exec/exec.lo expvar/expvar.lo \
-       flag/flag.lo fmt/fmt.lo gob/gob.lo hash/hash.lo html/html.lo \
-       http/http.lo image/image.lo io/io.lo json/json.lo log/log.lo \
-       math/math.lo mail/mail.lo mime/mime.lo net/net.lo os/os.lo \
-       patch/patch.lo path/path.lo rand/rand.lo reflect/reflect.lo \
-       regexp/regexp.lo rpc/rpc.lo runtime/runtime.lo \
-       scanner/scanner.lo smtp/smtp.lo sort/sort.lo \
-       strconv/strconv.lo strings/strings.lo sync/sync.lo \
-       syslog/syslog.lo syslog/syslog_c.lo tabwriter/tabwriter.lo \
-       template/template.lo time/time.lo unicode/unicode.lo \
-       url/url.lo utf16/utf16.lo utf8/utf8.lo websocket/websocket.lo \
-       xml/xml.lo archive/tar.lo archive/zip.lo compress/bzip2.lo \
-       compress/flate.lo compress/gzip.lo compress/lzw.lo \
-       compress/zlib.lo container/heap.lo container/list.lo \
-       container/ring.lo crypto/aes.lo crypto/bcrypt.lo \
-       crypto/blowfish.lo crypto/cast5.lo crypto/cipher.lo \
-       crypto/des.lo crypto/dsa.lo crypto/ecdsa.lo crypto/elliptic.lo \
-       crypto/hmac.lo crypto/md4.lo crypto/md5.lo crypto/ocsp.lo \
-       crypto/openpgp.lo crypto/rand.lo crypto/rc4.lo \
+am__DEPENDENCIES_2 = bufio/bufio.lo bytes/bytes.lo bytes/index.lo \
+       crypto/crypto.lo errors/errors.lo expvar/expvar.lo \
+       flag/flag.lo fmt/fmt.lo hash/hash.lo html/html.lo \
+       image/image.lo io/io.lo log/log.lo math/math.lo net/net.lo \
+       os/exec.lo os/os.lo patch/patch.lo path/path.lo \
+       reflect/reflect.lo regexp/regexp.lo runtime/runtime.lo \
+       sort/sort.lo strconv/strconv.lo strings/strings.lo \
+       sync/sync.lo time/time.lo unicode/unicode.lo \
+       websocket/websocket.lo archive/tar.lo archive/zip.lo \
+       compress/bzip2.lo compress/flate.lo compress/gzip.lo \
+       compress/lzw.lo compress/zlib.lo container/heap.lo \
+       container/list.lo container/ring.lo crypto/aes.lo \
+       crypto/bcrypt.lo crypto/blowfish.lo crypto/cast5.lo \
+       crypto/cipher.lo crypto/des.lo crypto/dsa.lo crypto/ecdsa.lo \
+       crypto/elliptic.lo crypto/hmac.lo crypto/md4.lo crypto/md5.lo \
+       crypto/ocsp.lo crypto/openpgp.lo crypto/rand.lo crypto/rc4.lo \
        crypto/ripemd160.lo crypto/rsa.lo crypto/sha1.lo \
        crypto/sha256.lo crypto/sha512.lo crypto/subtle.lo \
        crypto/tls.lo crypto/twofish.lo crypto/x509.lo crypto/xtea.lo \
@@ -158,24 +157,31 @@ am__DEPENDENCIES_2 = asn1/asn1.lo big/big.lo bufio/bufio.lo \
        crypto/openpgp/error.lo crypto/openpgp/packet.lo \
        crypto/openpgp/s2k.lo crypto/x509/pkix.lo debug/dwarf.lo \
        debug/elf.lo debug/gosym.lo debug/macho.lo debug/pe.lo \
-       encoding/ascii85.lo encoding/base32.lo encoding/base64.lo \
-       encoding/binary.lo encoding/git85.lo encoding/hex.lo \
-       encoding/pem.lo exp/ebnf.lo exp/gui.lo exp/norm.lo exp/spdy.lo \
-       exp/sql.lo exp/ssh.lo exp/terminal.lo exp/types.lo \
-       exp/gui/x11.lo exp/sql/driver.lo exp/template/html.lo \
-       go/ast.lo go/build.lo go/doc.lo go/parser.lo go/printer.lo \
-       go/scanner.lo go/token.lo hash/adler32.lo hash/crc32.lo \
-       hash/crc64.lo hash/fnv.lo http/cgi.lo http/fcgi.lo \
-       http/httptest.lo http/pprof.lo image/bmp.lo image/color.lo \
-       image/draw.lo image/gif.lo image/jpeg.lo image/png.lo \
-       image/tiff.lo image/ycbcr.lo index/suffixarray.lo io/ioutil.lo \
-       mime/multipart.lo net/dict.lo net/textproto.lo old/netchan.lo \
-       old/regexp.lo old/template.lo $(am__DEPENDENCIES_1) os/user.lo \
-       os/signal.lo path/filepath.lo regexp/syntax.lo rpc/jsonrpc.lo \
-       runtime/debug.lo runtime/pprof.lo sync/atomic.lo \
-       sync/atomic_c.lo syscall/syscall.lo syscall/errno.lo \
-       syscall/wait.lo template/parse.lo testing/testing.lo \
-       testing/iotest.lo testing/quick.lo testing/script.lo
+       encoding/ascii85.lo encoding/asn1.lo encoding/base32.lo \
+       encoding/base64.lo encoding/binary.lo encoding/csv.lo \
+       encoding/git85.lo encoding/gob.lo encoding/hex.lo \
+       encoding/json.lo encoding/pem.lo encoding/xml.lo exp/ebnf.lo \
+       exp/gui.lo exp/norm.lo exp/spdy.lo exp/sql.lo exp/ssh.lo \
+       exp/terminal.lo exp/types.lo exp/gui/x11.lo exp/sql/driver.lo \
+       html/template.lo go/ast.lo go/build.lo go/doc.lo go/parser.lo \
+       go/printer.lo go/scanner.lo go/token.lo hash/adler32.lo \
+       hash/crc32.lo hash/crc64.lo hash/fnv.lo net/http/cgi.lo \
+       net/http/fcgi.lo net/http/httptest.lo net/http/httputil.lo \
+       net/http/pprof.lo image/bmp.lo image/color.lo image/draw.lo \
+       image/gif.lo image/jpeg.lo image/png.lo image/tiff.lo \
+       image/ycbcr.lo index/suffixarray.lo io/ioutil.lo log/syslog.lo \
+       log/syslog/syslog_c.lo math/big.lo math/cmplx.lo math/rand.lo \
+       mime/mime.lo mime/multipart.lo net/dict.lo net/http.lo \
+       net/mail.lo net/rpc.lo net/smtp.lo net/textproto.lo net/url.lo \
+       old/netchan.lo old/regexp.lo old/template.lo \
+       $(am__DEPENDENCIES_1) os/user.lo os/signal.lo path/filepath.lo \
+       regexp/syntax.lo net/rpc/jsonrpc.lo runtime/debug.lo \
+       runtime/pprof.lo sync/atomic.lo sync/atomic_c.lo \
+       syscall/syscall.lo syscall/errno.lo syscall/wait.lo \
+       text/scanner.lo text/tabwriter.lo text/template.lo \
+       text/template/parse.lo testing/testing.lo testing/iotest.lo \
+       testing/quick.lo testing/script.lo unicode/utf16.lo \
+       unicode/utf8.lo
 libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1)
@@ -216,7 +222,7 @@ am__libgo_la_SOURCES_DIST = runtime/go-append.c runtime/go-assert.c \
        runtime/mheap.c runtime/msize.c runtime/proc.c \
        runtime/runtime.c runtime/thread.c runtime/yield.c \
        runtime/rtems-task-variable-add.c iface.c malloc.c map.c \
-       mprof.c reflect.c runtime1.c sema.c sigqueue.c string.c
+       mprof.c reflect.c runtime1.c sema.c sigqueue.c string.c time.c
 @LIBGO_IS_LINUX_FALSE@am__objects_1 = lock_sema.lo thread-sema.lo
 @LIBGO_IS_LINUX_TRUE@am__objects_1 = lock_futex.lo thread-linux.lo
 @HAVE_SYS_MMAN_H_FALSE@am__objects_2 = mem_posix_memalign.lo
@@ -245,7 +251,7 @@ am__objects_4 = go-append.lo go-assert.lo go-assert-interface.lo \
        mfinal.lo mfixalloc.lo mgc0.lo mheap.lo msize.lo proc.lo \
        runtime.lo thread.lo yield.lo $(am__objects_3) iface.lo \
        malloc.lo map.lo mprof.lo reflect.lo runtime1.lo sema.lo \
-       sigqueue.lo string.lo
+       sigqueue.lo string.lo time.lo
 am_libgo_la_OBJECTS = $(am__objects_4)
 libgo_la_OBJECTS = $(am_libgo_la_OBJECTS)
 libgo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -285,15 +291,17 @@ DATA = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \
        $(toolexeclibgocryptox509_DATA) $(toolexeclibgodebug_DATA) \
        $(toolexeclibgoencoding_DATA) $(toolexeclibgoexp_DATA) \
        $(toolexeclibgoexpgui_DATA) $(toolexeclibgoexpsql_DATA) \
-       $(toolexeclibgoexptemplate_DATA) $(toolexeclibgogo_DATA) \
-       $(toolexeclibgohash_DATA) $(toolexeclibgohttp_DATA) \
-       $(toolexeclibgoimage_DATA) $(toolexeclibgoindex_DATA) \
-       $(toolexeclibgoio_DATA) $(toolexeclibgomime_DATA) \
-       $(toolexeclibgonet_DATA) $(toolexeclibgoold_DATA) \
-       $(toolexeclibgoos_DATA) $(toolexeclibgopath_DATA) \
-       $(toolexeclibgoregexp_DATA) $(toolexeclibgorpc_DATA) \
+       $(toolexeclibgogo_DATA) $(toolexeclibgohash_DATA) \
+       $(toolexeclibgohtml_DATA) $(toolexeclibgoimage_DATA) \
+       $(toolexeclibgoindex_DATA) $(toolexeclibgoio_DATA) \
+       $(toolexeclibgolog_DATA) $(toolexeclibgomath_DATA) \
+       $(toolexeclibgomime_DATA) $(toolexeclibgonet_DATA) \
+       $(toolexeclibgonethttp_DATA) $(toolexeclibgonetrpc_DATA) \
+       $(toolexeclibgoold_DATA) $(toolexeclibgoos_DATA) \
+       $(toolexeclibgopath_DATA) $(toolexeclibgoregexp_DATA) \
        $(toolexeclibgoruntime_DATA) $(toolexeclibgosync_DATA) \
-       $(toolexeclibgotemplate_DATA) $(toolexeclibgotesting_DATA)
+       $(toolexeclibgotesting_DATA) $(toolexeclibgotext_DATA) \
+       $(toolexeclibgotexttemplate_DATA) $(toolexeclibgounicode_DATA)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
   distclean-recursive maintainer-clean-recursive
 AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
@@ -561,56 +569,36 @@ toolexeclib_LTLIBRARIES = libgo.la
 toolexeclib_LIBRARIES = libgobegin.a
 toolexeclibgodir = $(toolexeclibdir)/go/$(gcc_version)/$(target_alias)
 toolexeclibgo_DATA = \
-       asn1.gox \
-       big.gox \
        bufio.gox \
        bytes.gox \
-       cmath.gox \
        crypto.gox \
-       csv.gox \
        errors.gox \
-       exec.gox \
        expvar.gox \
        flag.gox \
        fmt.gox \
-       gob.gox \
        hash.gox \
        html.gox \
-       http.gox \
        image.gox \
        io.gox \
-       json.gox \
        log.gox \
        math.gox \
-       mail.gox \
        mime.gox \
        net.gox \
        os.gox \
        patch.gox \
        path.gox \
-       rand.gox \
        reflect.gox \
        regexp.gox \
-       rpc.gox \
        runtime.gox \
-       scanner.gox \
-       smtp.gox \
        sort.gox \
        strconv.gox \
        strings.gox \
        sync.gox \
        syscall.gox \
-       syslog.gox \
-       tabwriter.gox \
-       template.gox \
        testing.gox \
        time.gox \
        unicode.gox \
-       url.gox \
-       utf16.gox \
-       utf8.gox \
-       websocket.gox \
-       xml.gox
+       websocket.gox
 
 toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
 toolexeclibgoarchive_DATA = \
@@ -683,12 +671,17 @@ toolexeclibgodebug_DATA = \
 toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
 toolexeclibgoencoding_DATA = \
        encoding/ascii85.gox \
+       encoding/asn1.gox \
        encoding/base32.gox \
        encoding/base64.gox \
        encoding/binary.gox \
+       encoding/csv.gox \
        encoding/git85.gox \
+       encoding/gob.gox \
        encoding/hex.gox \
-       encoding/pem.gox
+       encoding/json.gox \
+       encoding/pem.gox \
+       encoding/xml.gox
 
 @LIBGO_IS_LINUX_FALSE@exp_inotify_gox = 
 
@@ -714,10 +707,6 @@ toolexeclibgoexpsqldir = $(toolexeclibgoexpdir)/sql
 toolexeclibgoexpsql_DATA = \
        exp/sql/driver.gox
 
-toolexeclibgoexptemplatedir = $(toolexeclibgoexpdir)/template
-toolexeclibgoexptemplate_DATA = \
-       exp/template/html.gox
-
 toolexeclibgogodir = $(toolexeclibgodir)/go
 toolexeclibgogo_DATA = \
        go/ast.gox \
@@ -735,12 +724,9 @@ toolexeclibgohash_DATA = \
        hash/crc64.gox \
        hash/fnv.gox
 
-toolexeclibgohttpdir = $(toolexeclibgodir)/http
-toolexeclibgohttp_DATA = \
-       http/cgi.gox \
-       http/fcgi.gox \
-       http/httptest.gox \
-       http/pprof.gox
+toolexeclibgohtmldir = $(toolexeclibgodir)/html
+toolexeclibgohtml_DATA = \
+       html/template.gox
 
 toolexeclibgoimagedir = $(toolexeclibgodir)/image
 toolexeclibgoimage_DATA = \
@@ -761,6 +747,16 @@ toolexeclibgoiodir = $(toolexeclibgodir)/io
 toolexeclibgoio_DATA = \
        io/ioutil.gox
 
+toolexeclibgologdir = $(toolexeclibgodir)/log
+toolexeclibgolog_DATA = \
+       log/syslog.gox
+
+toolexeclibgomathdir = $(toolexeclibgodir)/math
+toolexeclibgomath_DATA = \
+       math/big.gox \
+       math/cmplx.gox \
+       math/rand.gox
+
 toolexeclibgomimedir = $(toolexeclibgodir)/mime
 toolexeclibgomime_DATA = \
        mime/multipart.gox
@@ -768,7 +764,24 @@ toolexeclibgomime_DATA = \
 toolexeclibgonetdir = $(toolexeclibgodir)/net
 toolexeclibgonet_DATA = \
        net/dict.gox \
-       net/textproto.gox
+       net/http.gox \
+       net/mail.gox \
+       net/rpc.gox \
+       net/smtp.gox \
+       net/textproto.gox \
+       net/url.gox
+
+toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http
+toolexeclibgonethttp_DATA = \
+       net/http/cgi.gox \
+       net/http/fcgi.gox \
+       net/http/httptest.gox \
+       net/http/httputil.gox \
+       net/http/pprof.gox
+
+toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc
+toolexeclibgonetrpc_DATA = \
+       net/rpc/jsonrpc.gox
 
 toolexeclibgoolddir = $(toolexeclibgodir)/old
 toolexeclibgoold_DATA = \
@@ -778,6 +791,7 @@ toolexeclibgoold_DATA = \
 
 toolexeclibgoosdir = $(toolexeclibgodir)/os
 toolexeclibgoos_DATA = \
+       os/exec.gox \
        os/user.gox \
        os/signal.gox
 
@@ -789,19 +803,11 @@ toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp
 toolexeclibgoregexp_DATA = \
        regexp/syntax.gox
 
-toolexeclibgorpcdir = $(toolexeclibgodir)/rpc
-toolexeclibgorpc_DATA = \
-       rpc/jsonrpc.gox
-
 toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
 toolexeclibgoruntime_DATA = \
        runtime/debug.gox \
        runtime/pprof.gox
 
-toolexeclibgotemplatedir = $(toolexeclibgodir)/template
-toolexeclibgotemplate_DATA = \
-       template/parse.gox
-
 toolexeclibgosyncdir = $(toolexeclibgodir)/sync
 toolexeclibgosync_DATA = \
        sync/atomic.gox
@@ -812,6 +818,21 @@ toolexeclibgotesting_DATA = \
        testing/quick.gox \
        testing/script.gox
 
+toolexeclibgotextdir = $(toolexeclibgodir)/text
+toolexeclibgotext_DATA = \
+       text/scanner.gox \
+       text/tabwriter.gox \
+       text/template.gox
+
+toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
+toolexeclibgotexttemplate_DATA = \
+       text/template/parse.gox
+
+toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
+toolexeclibgounicode_DATA = \
+       unicode/utf16.gox \
+       unicode/utf8.gox
+
 @HAVE_SYS_MMAN_H_FALSE@runtime_mem_file = runtime/mem_posix_memalign.c
 @HAVE_SYS_MMAN_H_TRUE@runtime_mem_file = runtime/mem.c
 @LIBGO_IS_RTEMS_FALSE@rtems_task_variable_add_file = 
@@ -901,18 +922,8 @@ runtime_files = \
        runtime1.c \
        sema.c \
        sigqueue.c \
-       string.c
-
-go_asn1_files = \
-       go/asn1/asn1.go \
-       go/asn1/common.go \
-       go/asn1/marshal.go
-
-go_big_files = \
-       go/big/arith.go \
-       go/big/int.go \
-       go/big/nat.go \
-       go/big/rat.go
+       string.c \
+       time.c
 
 go_bufio_files = \
        go/bufio/bufio.go
@@ -925,36 +936,12 @@ go_bytes_files = \
 go_bytes_c_files = \
        go/bytes/indexbyte.c
 
-go_cmath_files = \
-       go/cmath/abs.go \
-       go/cmath/asin.go \
-       go/cmath/conj.go \
-       go/cmath/exp.go \
-       go/cmath/isinf.go \
-       go/cmath/isnan.go \
-       go/cmath/log.go \
-       go/cmath/phase.go \
-       go/cmath/polar.go \
-       go/cmath/pow.go \
-       go/cmath/rect.go \
-       go/cmath/sin.go \
-       go/cmath/sqrt.go \
-       go/cmath/tan.go
-
 go_crypto_files = \
        go/crypto/crypto.go
 
-go_csv_files = \
-       go/csv/reader.go \
-       go/csv/writer.go
-
 go_errors_files = \
        go/errors/errors.go
 
-go_exec_files = \
-       go/exec/exec.go \
-       go/exec/lp_unix.go
-
 go_expvar_files = \
        go/expvar/expvar.go
 
@@ -967,15 +954,6 @@ go_fmt_files = \
        go/fmt/print.go \
        go/fmt/scan.go
 
-go_gob_files = \
-       go/gob/decode.go \
-       go/gob/decoder.go \
-       go/gob/doc.go \
-       go/gob/encode.go \
-       go/gob/encoder.go \
-       go/gob/error.go \
-       go/gob/type.go
-
 go_hash_files = \
        go/hash/hash.go
 
@@ -989,25 +967,6 @@ go_html_files = \
        go/html/render.go \
        go/html/token.go
 
-go_http_files = \
-       go/http/chunked.go \
-       go/http/client.go \
-       go/http/cookie.go \
-       go/http/dump.go \
-       go/http/filetransport.go \
-       go/http/fs.go \
-       go/http/header.go \
-       go/http/lex.go \
-       go/http/persist.go \
-       go/http/request.go \
-       go/http/response.go \
-       go/http/reverseproxy.go \
-       go/http/server.go \
-       go/http/sniff.go \
-       go/http/status.go \
-       go/http/transfer.go \
-       go/http/transport.go
-
 go_image_files = \
        go/image/format.go \
        go/image/geom.go \
@@ -1019,14 +978,6 @@ go_io_files = \
        go/io/io.go \
        go/io/pipe.go
 
-go_json_files = \
-       go/json/decode.go \
-       go/json/encode.go \
-       go/json/indent.go \
-       go/json/scanner.go \
-       go/json/stream.go \
-       go/json/tags.go
-
 go_log_files = \
        go/log/log.go
 
@@ -1078,9 +1029,6 @@ go_math_files = \
        go/math/tanh.go \
        go/math/unsafe.go
 
-go_mail_files = \
-       go/mail/message.go
-
 go_mime_files = \
        go/mime/grammar.go \
        go/mime/mediatype.go \
@@ -1185,13 +1133,6 @@ go_path_files = \
        go/path/match.go \
        go/path/path.go
 
-go_rand_files = \
-       go/rand/exp.go \
-       go/rand/normal.go \
-       go/rand/rand.go \
-       go/rand/rng.go \
-       go/rand/zipf.go
-
 go_reflect_files = \
        go/reflect/deepequal.go \
        go/reflect/type.go \
@@ -1201,10 +1142,10 @@ go_regexp_files = \
        go/regexp/exec.go \
        go/regexp/regexp.go
 
-go_rpc_files = \
-       go/rpc/client.go \
-       go/rpc/debug.go \
-       go/rpc/server.go
+go_net_rpc_files = \
+       go/net/rpc/client.go \
+       go/net/rpc/debug.go \
+       go/net/rpc/server.go
 
 go_runtime_files = \
        go/runtime/debug.go \
@@ -1216,13 +1157,6 @@ go_runtime_files = \
        go/runtime/type.go \
        version.go
 
-go_scanner_files = \
-       go/scanner/scanner.go
-
-go_smtp_files = \
-       go/smtp/auth.go \
-       go/smtp/smtp.go
-
 go_sort_files = \
        go/sort/search.go \
        go/sort/sort.go
@@ -1248,26 +1182,15 @@ go_sync_files = \
        go/sync/rwmutex.go \
        go/sync/waitgroup.go
 
-@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/syslog/syslog_unix.go
-@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/syslog/syslog_libc.go
-@LIBGO_IS_SOLARIS_TRUE@go_syslog_file = go/syslog/syslog_libc.go
-go_syslog_files = \
-       go/syslog/syslog.go \
+@LIBGO_IS_IRIX_FALSE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/log/syslog/syslog_unix.go
+@LIBGO_IS_IRIX_TRUE@@LIBGO_IS_SOLARIS_FALSE@go_syslog_file = go/log/syslog/syslog_libc.go
+@LIBGO_IS_SOLARIS_TRUE@go_syslog_file = go/log/syslog/syslog_libc.go
+go_log_syslog_files = \
+       go/log/syslog/syslog.go \
        $(go_syslog_file)
 
 go_syslog_c_files = \
-       go/syslog/syslog_c.c
-
-go_tabwriter_files = \
-       go/tabwriter/tabwriter.go
-
-go_template_files = \
-       go/template/doc.go \
-       go/template/exec.go \
-       go/template/funcs.go \
-       go/template/helper.go \
-       go/template/parse.go \
-       go/template/set.go
+       go/log/syslog/syslog_c.c
 
 go_testing_files = \
        go/testing/benchmark.go \
@@ -1291,16 +1214,6 @@ go_unicode_files = \
        go/unicode/letter.go \
        go/unicode/tables.go
 
-go_url_files = \
-       go/url/url.go
-
-go_utf16_files = \
-       go/utf16/utf16.go
-
-go_utf8_files = \
-       go/utf8/string.go \
-       go/utf8/utf8.go
-
 go_websocket_files = \
        go/websocket/client.go \
        go/websocket/hixie.go \
@@ -1308,11 +1221,6 @@ go_websocket_files = \
        go/websocket/server.go \
        go/websocket/websocket.go
 
-go_xml_files = \
-       go/xml/marshal.go \
-       go/xml/read.go \
-       go/xml/xml.go
-
 go_archive_tar_files = \
        go/archive/tar/common.go \
        go/archive/tar/reader.go \
@@ -1533,6 +1441,11 @@ go_debug_pe_files = \
 go_encoding_ascii85_files = \
        go/encoding/ascii85/ascii85.go
 
+go_encoding_asn1_files = \
+       go/encoding/asn1/asn1.go \
+       go/encoding/asn1/common.go \
+       go/encoding/asn1/marshal.go
+
 go_encoding_base32_files = \
        go/encoding/base32/base32.go
 
@@ -1543,15 +1456,41 @@ go_encoding_binary_files = \
        go/encoding/binary/binary.go \
        go/encoding/binary/varint.go
 
+go_encoding_csv_files = \
+       go/encoding/csv/reader.go \
+       go/encoding/csv/writer.go
+
 go_encoding_git85_files = \
        go/encoding/git85/git.go
 
+go_encoding_gob_files = \
+       go/encoding/gob/decode.go \
+       go/encoding/gob/decoder.go \
+       go/encoding/gob/doc.go \
+       go/encoding/gob/encode.go \
+       go/encoding/gob/encoder.go \
+       go/encoding/gob/error.go \
+       go/encoding/gob/type.go
+
 go_encoding_hex_files = \
        go/encoding/hex/hex.go
 
+go_encoding_json_files = \
+       go/encoding/json/decode.go \
+       go/encoding/json/encode.go \
+       go/encoding/json/indent.go \
+       go/encoding/json/scanner.go \
+       go/encoding/json/stream.go \
+       go/encoding/json/tags.go
+
 go_encoding_pem_files = \
        go/encoding/pem/pem.go
 
+go_encoding_xml_files = \
+       go/encoding/xml/marshal.go \
+       go/encoding/xml/read.go \
+       go/encoding/xml/xml.go
+
 go_exp_ebnf_files = \
        go/exp/ebnf/ebnf.go \
        go/exp/ebnf/parser.go
@@ -1583,6 +1522,7 @@ go_exp_sql_files = \
 go_exp_ssh_files = \
        go/exp/ssh/channel.go \
        go/exp/ssh/client.go \
+       go/exp/ssh/client_auth.go \
        go/exp/ssh/common.go \
        go/exp/ssh/doc.go \
        go/exp/ssh/messages.go \
@@ -1611,23 +1551,10 @@ go_exp_sql_driver_files = \
        go/exp/sql/driver/driver.go \
        go/exp/sql/driver/types.go
 
-go_exp_template_html_files = \
-       go/exp/template/html/attr.go \
-       go/exp/template/html/clone.go \
-       go/exp/template/html/content.go \
-       go/exp/template/html/context.go \
-       go/exp/template/html/css.go \
-       go/exp/template/html/doc.go \
-       go/exp/template/html/error.go \
-       go/exp/template/html/escape.go \
-       go/exp/template/html/html.go \
-       go/exp/template/html/js.go \
-       go/exp/template/html/transition.go \
-       go/exp/template/html/url.go
-
 go_go_ast_files = \
        go/go/ast/ast.go \
        go/go/ast/filter.go \
+       go/go/ast/import.go \
        go/go/ast/print.go \
        go/go/ast/resolve.go \
        go/go/ast/scope.go \
@@ -1674,20 +1601,20 @@ go_hash_crc64_files = \
 go_hash_fnv_files = \
        go/hash/fnv/fnv.go
 
-go_http_cgi_files = \
-       go/http/cgi/child.go \
-       go/http/cgi/host.go
-
-go_http_fcgi_files = \
-       go/http/fcgi/child.go \
-       go/http/fcgi/fcgi.go
-
-go_http_httptest_files = \
-       go/http/httptest/recorder.go \
-       go/http/httptest/server.go
-
-go_http_pprof_files = \
-       go/http/pprof/pprof.go
+go_html_template_files = \
+       go/html/template/attr.go \
+       go/html/template/clone.go \
+       go/html/template/content.go \
+       go/html/template/context.go \
+       go/html/template/css.go \
+       go/html/template/doc.go \
+       go/html/template/error.go \
+       go/html/template/escape.go \
+       go/html/template/html.go \
+       go/html/template/js.go \
+       go/html/template/template.go \
+       go/html/template/transition.go \
+       go/html/template/url.go
 
 go_image_bmp_files = \
        go/image/bmp/reader.go
@@ -1729,6 +1656,35 @@ go_io_ioutil_files = \
        go/io/ioutil/ioutil.go \
        go/io/ioutil/tempfile.go
 
+go_math_big_files = \
+       go/math/big/arith.go \
+       go/math/big/int.go \
+       go/math/big/nat.go \
+       go/math/big/rat.go
+
+go_math_cmplx_files = \
+       go/math/cmplx/abs.go \
+       go/math/cmplx/asin.go \
+       go/math/cmplx/conj.go \
+       go/math/cmplx/exp.go \
+       go/math/cmplx/isinf.go \
+       go/math/cmplx/isnan.go \
+       go/math/cmplx/log.go \
+       go/math/cmplx/phase.go \
+       go/math/cmplx/polar.go \
+       go/math/cmplx/pow.go \
+       go/math/cmplx/rect.go \
+       go/math/cmplx/sin.go \
+       go/math/cmplx/sqrt.go \
+       go/math/cmplx/tan.go
+
+go_math_rand_files = \
+       go/math/rand/exp.go \
+       go/math/rand/normal.go \
+       go/math/rand/rand.go \
+       go/math/rand/rng.go \
+       go/math/rand/zipf.go
+
 go_mime_multipart_files = \
        go/mime/multipart/formdata.go \
        go/mime/multipart/multipart.go \
@@ -1737,6 +1693,29 @@ go_mime_multipart_files = \
 go_net_dict_files = \
        go/net/dict/dict.go
 
+go_net_http_files = \
+       go/net/http/chunked.go \
+       go/net/http/client.go \
+       go/net/http/cookie.go \
+       go/net/http/filetransport.go \
+       go/net/http/fs.go \
+       go/net/http/header.go \
+       go/net/http/lex.go \
+       go/net/http/request.go \
+       go/net/http/response.go \
+       go/net/http/server.go \
+       go/net/http/sniff.go \
+       go/net/http/status.go \
+       go/net/http/transfer.go \
+       go/net/http/transport.go
+
+go_net_mail_files = \
+       go/net/mail/message.go
+
+go_net_smtp_files = \
+       go/net/smtp/auth.go \
+       go/net/smtp/smtp.go
+
 go_net_textproto_files = \
        go/net/textproto/header.go \
        go/net/textproto/pipeline.go \
@@ -1744,6 +1723,30 @@ go_net_textproto_files = \
        go/net/textproto/textproto.go \
        go/net/textproto/writer.go
 
+go_net_url_files = \
+       go/net/url/url.go
+
+go_net_http_cgi_files = \
+       go/net/http/cgi/child.go \
+       go/net/http/cgi/host.go
+
+go_net_http_fcgi_files = \
+       go/net/http/fcgi/child.go \
+       go/net/http/fcgi/fcgi.go
+
+go_net_http_httptest_files = \
+       go/net/http/httptest/recorder.go \
+       go/net/http/httptest/server.go
+
+go_net_http_pprof_files = \
+       go/net/http/pprof/pprof.go
+
+go_net_http_httputil_files = \
+       go/net/http/httputil/chunked.go \
+       go/net/http/httputil/dump.go \
+       go/net/http/httputil/persist.go \
+       go/net/http/httputil/reverseproxy.go
+
 go_old_netchan_files = \
        go/old/netchan/common.go \
        go/old/netchan/export.go \
@@ -1758,6 +1761,10 @@ go_old_template_files = \
        go/old/template/format.go \
        go/old/template/parse.go
 
+go_os_exec_files = \
+       go/os/exec/exec.go \
+       go/os/exec/lp_unix.go
+
 go_os_user_files = \
        go/os/user/user.go \
        go/os/user/lookup_unix.go
@@ -1778,9 +1785,9 @@ go_regexp_syntax_files = \
        go/regexp/syntax/regexp.go \
        go/regexp/syntax/simplify.go
 
-go_rpc_jsonrpc_files = \
-       go/rpc/jsonrpc/client.go \
-       go/rpc/jsonrpc/server.go
+go_net_rpc_jsonrpc_files = \
+       go/net/rpc/jsonrpc/client.go \
+       go/net/rpc/jsonrpc/server.go
 
 go_runtime_debug_files = \
        go/runtime/debug/stack.go
@@ -1788,11 +1795,22 @@ go_runtime_debug_files = \
 go_runtime_pprof_files = \
        go/runtime/pprof/pprof.go
 
-go_template_parse_files = \
-       go/template/parse/lex.go \
-       go/template/parse/node.go \
-       go/template/parse/parse.go \
-       go/template/parse/set.go
+go_text_tabwriter_files = \
+       go/text/tabwriter/tabwriter.go
+
+go_text_template_files = \
+       go/text/template/doc.go \
+       go/text/template/exec.go \
+       go/text/template/funcs.go \
+       go/text/template/helper.go \
+       go/text/template/parse.go \
+       go/text/template/set.go
+
+go_text_template_parse_files = \
+       go/text/template/parse/lex.go \
+       go/text/template/parse/node.go \
+       go/text/template/parse/parse.go \
+       go/text/template/parse/set.go
 
 go_sync_atomic_files = \
        go/sync/atomic/doc.go
@@ -1811,6 +1829,16 @@ go_testing_quick_files = \
 go_testing_script_files = \
        go/testing/script/script.go
 
+go_text_scanner_files = \
+       go/text/scanner/scanner.go
+
+go_unicode_utf16_files = \
+       go/unicode/utf16/utf16.go
+
+go_unicode_utf8_files = \
+       go/unicode/utf8/string.go \
+       go/unicode/utf8/utf8.go
+
 @LIBGO_IS_RTEMS_FALSE@syscall_syscall_file = go/syscall/syscall_unix.go
 
 # Define Syscall and Syscall6.
@@ -1896,56 +1924,35 @@ go_syscall_c_files = \
 # os_lib_inotify_lo = os/inotify.lo
 @LIBGO_IS_LINUX_TRUE@os_lib_inotify_lo = 
 libgo_go_objs = \
-       asn1/asn1.lo \
-       big/big.lo \
        bufio/bufio.lo \
        bytes/bytes.lo \
        bytes/index.lo \
-       cmath/cmath.lo \
        crypto/crypto.lo \
-       csv/csv.lo \
        errors/errors.lo \
-       exec/exec.lo \
        expvar/expvar.lo \
        flag/flag.lo \
        fmt/fmt.lo \
-       gob/gob.lo \
        hash/hash.lo \
        html/html.lo \
-       http/http.lo \
        image/image.lo \
        io/io.lo \
-       json/json.lo \
        log/log.lo \
        math/math.lo \
-       mail/mail.lo \
-       mime/mime.lo \
        net/net.lo \
+       os/exec.lo \
        os/os.lo \
        patch/patch.lo \
        path/path.lo \
-       rand/rand.lo \
        reflect/reflect.lo \
        regexp/regexp.lo \
-       rpc/rpc.lo \
        runtime/runtime.lo \
-       scanner/scanner.lo \
-       smtp/smtp.lo \
        sort/sort.lo \
        strconv/strconv.lo \
        strings/strings.lo \
        sync/sync.lo \
-       syslog/syslog.lo \
-       syslog/syslog_c.lo \
-       tabwriter/tabwriter.lo \
-       template/template.lo \
        time/time.lo \
        unicode/unicode.lo \
-       url/url.lo \
-       utf16/utf16.lo \
-       utf8/utf8.lo \
        websocket/websocket.lo \
-       xml/xml.lo \
        archive/tar.lo \
        archive/zip.lo \
        compress/bzip2.lo \
@@ -1994,12 +2001,17 @@ libgo_go_objs = \
        debug/macho.lo \
        debug/pe.lo \
        encoding/ascii85.lo \
+       encoding/asn1.lo \
        encoding/base32.lo \
        encoding/base64.lo \
        encoding/binary.lo \
+       encoding/csv.lo \
        encoding/git85.lo \
+       encoding/gob.lo \
        encoding/hex.lo \
+       encoding/json.lo \
        encoding/pem.lo \
+       encoding/xml.lo \
        exp/ebnf.lo \
        exp/gui.lo \
        exp/norm.lo \
@@ -2010,7 +2022,7 @@ libgo_go_objs = \
        exp/types.lo \
        exp/gui/x11.lo \
        exp/sql/driver.lo \
-       exp/template/html.lo \
+       html/template.lo \
        go/ast.lo \
        go/build.lo \
        go/doc.lo \
@@ -2022,10 +2034,11 @@ libgo_go_objs = \
        hash/crc32.lo \
        hash/crc64.lo \
        hash/fnv.lo \
-       http/cgi.lo \
-       http/fcgi.lo \
-       http/httptest.lo \
-       http/pprof.lo \
+       net/http/cgi.lo \
+       net/http/fcgi.lo \
+       net/http/httptest.lo \
+       net/http/httputil.lo \
+       net/http/pprof.lo \
        image/bmp.lo \
        image/color.lo \
        image/draw.lo \
@@ -2036,9 +2049,20 @@ libgo_go_objs = \
        image/ycbcr.lo \
        index/suffixarray.lo \
        io/ioutil.lo \
+       log/syslog.lo \
+       log/syslog/syslog_c.lo \
+       math/big.lo \
+       math/cmplx.lo \
+       math/rand.lo \
+       mime/mime.lo \
        mime/multipart.lo \
        net/dict.lo \
+       net/http.lo \
+       net/mail.lo \
+       net/rpc.lo \
+       net/smtp.lo \
        net/textproto.lo \
+       net/url.lo \
        old/netchan.lo \
        old/regexp.lo \
        old/template.lo \
@@ -2047,7 +2071,7 @@ libgo_go_objs = \
        os/signal.lo \
        path/filepath.lo \
        regexp/syntax.lo \
-       rpc/jsonrpc.lo \
+       net/rpc/jsonrpc.lo \
        runtime/debug.lo \
        runtime/pprof.lo \
        sync/atomic.lo \
@@ -2055,11 +2079,16 @@ libgo_go_objs = \
        syscall/syscall.lo \
        syscall/errno.lo \
        syscall/wait.lo \
-       template/parse.lo \
+       text/scanner.lo \
+       text/tabwriter.lo \
+       text/template.lo \
+       text/template/parse.lo \
        testing/testing.lo \
        testing/iotest.lo \
        testing/quick.lo \
-       testing/script.lo
+       testing/script.lo \
+       unicode/utf16.lo \
+       unicode/utf8.lo
 
 libgo_la_SOURCES = $(runtime_files)
 libgo_la_LDFLAGS = $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
@@ -2142,18 +2171,23 @@ CHECK_DEPS = libgo.la libgobegin.a \
        $(toolexeclibgoexp_DATA) \
        $(toolexeclibgogo_DATA) \
        $(toolexeclibgohash_DATA) \
-       $(toolexeclibgohttp_DATA) \
        $(toolexeclibgoimage_DATA) \
        $(toolexeclibgoindex_DATA) \
        $(toolexeclibgoio_DATA) \
+       $(toolexeclibgolog_DATA) \
+       $(toolexeclibgomath_DATA) \
        $(toolexeclibgomime_DATA) \
        $(toolexeclibgonet_DATA) \
+       $(toolexeclibgonethttp_DATA) \
        $(toolexeclibgoos_DATA) \
        $(toolexeclibgopath_DATA) \
        $(toolexeclibgorpc_DATA) \
        $(toolexeclibgoruntime_DATA) \
        $(toolexeclibgosync_DATA) \
-       $(toolexeclibgotesting_DATA)
+       $(toolexeclibgotesting_DATA) \
+       $(toolexeclibgotext_DATA) \
+       $(toolexeclibgotexttemplate_DATA) \
+       $(toolexeclibgounicode_DATA)
 
 
 # How to build a .gox file from a .lo file.
@@ -2166,52 +2200,32 @@ BUILDGOX = \
 # exp_inotify_check = exp/inotify/check
 @LIBGO_IS_LINUX_TRUE@exp_inotify_check = 
 TEST_PACKAGES = \
-       asn1/check \
-       big/check \
        bufio/check \
        bytes/check \
-       cmath/check \
-       csv/check \
        errors/check \
-       exec/check \
        expvar/check \
        flag/check \
        fmt/check \
-       gob/check \
        html/check \
-       http/check \
        image/check \
        io/check \
-       json/check \
        log/check \
        math/check \
-       mail/check \
        mime/check \
        net/check \
        os/check \
        patch/check \
        path/check \
-       rand/check \
        reflect/check \
        regexp/check \
-       rpc/check \
        runtime/check \
-       scanner/check \
-       smtp/check \
        sort/check \
        strconv/check \
        strings/check \
        sync/check \
-       syslog/check \
-       tabwriter/check \
-       template/check \
        time/check \
        unicode/check \
-       url/check \
-       utf16/check \
-       utf8/check \
        websocket/check \
-       xml/check \
        archive/tar/check \
        archive/zip/check \
        compress/bzip2/check \
@@ -2257,12 +2271,17 @@ TEST_PACKAGES = \
        debug/macho/check \
        debug/pe/check \
        encoding/ascii85/check \
+       encoding/asn1/check \
        encoding/base32/check \
        encoding/base64/check \
        encoding/binary/check \
+       encoding/csv/check \
        encoding/git85/check \
+       encoding/gob/check \
        encoding/hex/check \
+       encoding/json/check \
        encoding/pem/check \
+       encoding/xml/check \
        exp/ebnf/check \
        $(exp_inotify_check) \
        exp/norm/check \
@@ -2270,7 +2289,7 @@ TEST_PACKAGES = \
        exp/sql/check \
        exp/ssh/check \
        exp/terminal/check \
-       exp/template/html/check \
+       html/template/check \
        go/ast/check \
        $(go_build_check_omitted_since_it_calls_6g) \
        go/parser/check \
@@ -2282,8 +2301,6 @@ TEST_PACKAGES = \
        hash/crc32/check \
        hash/crc64/check \
        hash/fnv/check \
-       http/cgi/check \
-       http/fcgi/check \
        image/draw/check \
        image/jpeg/check \
        image/png/check \
@@ -2291,20 +2308,38 @@ TEST_PACKAGES = \
        image/ycbcr/check \
        index/suffixarray/check \
        io/ioutil/check \
+       log/syslog/check \
+       math/big/check \
+       math/cmplx/check \
+       math/rand/check \
        mime/multipart/check \
+       net/http/check \
+       net/http/cgi/check \
+       net/http/fcgi/check \
+       net/http/httputil/check \
+       net/mail/check \
+       net/rpc/check \
+       net/smtp/check \
        net/textproto/check \
+       net/url/check \
+       net/rpc/jsonrpc/check \
        old/netchan/check \
        old/regexp/check \
        old/template/check \
+       os/exec/check \
        os/user/check \
        os/signal/check \
        path/filepath/check \
        regexp/syntax/check \
-       rpc/jsonrpc/check \
        sync/atomic/check \
-       template/parse/check \
+       text/scanner/check \
+       text/tabwriter/check \
+       text/template/check \
+       text/template/parse/check \
        testing/quick/check \
-       testing/script/check
+       testing/script/check \
+       unicode/utf16/check \
+       unicode/utf8/check
 
 MOSTLYCLEAN_FILES = libgo.head libgo.sum.sep libgo.log.sep
 CLEANFILES = *.go *.gox goc2c *.c s-version libgo.sum libgo.log
@@ -2527,6 +2562,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread-linux.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread-sema.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yield.Plo@am__quote@
 
 .c.o:
@@ -3375,26 +3411,6 @@ uninstall-toolexeclibgoexpsqlDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgoexpsqldir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgoexpsqldir)" && rm -f $$files
-install-toolexeclibgoexptemplateDATA: $(toolexeclibgoexptemplate_DATA)
-       @$(NORMAL_INSTALL)
-       test -z "$(toolexeclibgoexptemplatedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgoexptemplatedir)"
-       @list='$(toolexeclibgoexptemplate_DATA)'; test -n "$(toolexeclibgoexptemplatedir)" || list=; \
-       for p in $$list; do \
-         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         echo "$$d$$p"; \
-       done | $(am__base_list) | \
-       while read files; do \
-         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgoexptemplatedir)'"; \
-         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgoexptemplatedir)" || exit $$?; \
-       done
-
-uninstall-toolexeclibgoexptemplateDATA:
-       @$(NORMAL_UNINSTALL)
-       @list='$(toolexeclibgoexptemplate_DATA)'; test -n "$(toolexeclibgoexptemplatedir)" || list=; \
-       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-       test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(toolexeclibgoexptemplatedir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(toolexeclibgoexptemplatedir)" && rm -f $$files
 install-toolexeclibgogoDATA: $(toolexeclibgogo_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(toolexeclibgogodir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgogodir)"
@@ -3435,26 +3451,26 @@ uninstall-toolexeclibgohashDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgohashdir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgohashdir)" && rm -f $$files
-install-toolexeclibgohttpDATA: $(toolexeclibgohttp_DATA)
+install-toolexeclibgohtmlDATA: $(toolexeclibgohtml_DATA)
        @$(NORMAL_INSTALL)
-       test -z "$(toolexeclibgohttpdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgohttpdir)"
-       @list='$(toolexeclibgohttp_DATA)'; test -n "$(toolexeclibgohttpdir)" || list=; \
+       test -z "$(toolexeclibgohtmldir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgohtmldir)"
+       @list='$(toolexeclibgohtml_DATA)'; test -n "$(toolexeclibgohtmldir)" || list=; \
        for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          echo "$$d$$p"; \
        done | $(am__base_list) | \
        while read files; do \
-         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgohttpdir)'"; \
-         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgohttpdir)" || exit $$?; \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgohtmldir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgohtmldir)" || exit $$?; \
        done
 
-uninstall-toolexeclibgohttpDATA:
+uninstall-toolexeclibgohtmlDATA:
        @$(NORMAL_UNINSTALL)
-       @list='$(toolexeclibgohttp_DATA)'; test -n "$(toolexeclibgohttpdir)" || list=; \
+       @list='$(toolexeclibgohtml_DATA)'; test -n "$(toolexeclibgohtmldir)" || list=; \
        files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
        test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(toolexeclibgohttpdir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(toolexeclibgohttpdir)" && rm -f $$files
+       echo " ( cd '$(DESTDIR)$(toolexeclibgohtmldir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgohtmldir)" && rm -f $$files
 install-toolexeclibgoimageDATA: $(toolexeclibgoimage_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(toolexeclibgoimagedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgoimagedir)"
@@ -3515,6 +3531,46 @@ uninstall-toolexeclibgoioDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgoiodir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgoiodir)" && rm -f $$files
+install-toolexeclibgologDATA: $(toolexeclibgolog_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgologdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgologdir)"
+       @list='$(toolexeclibgolog_DATA)'; test -n "$(toolexeclibgologdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgologdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgologdir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgologDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgolog_DATA)'; test -n "$(toolexeclibgologdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgologdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgologdir)" && rm -f $$files
+install-toolexeclibgomathDATA: $(toolexeclibgomath_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgomathdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgomathdir)"
+       @list='$(toolexeclibgomath_DATA)'; test -n "$(toolexeclibgomathdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgomathdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgomathdir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgomathDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgomath_DATA)'; test -n "$(toolexeclibgomathdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgomathdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgomathdir)" && rm -f $$files
 install-toolexeclibgomimeDATA: $(toolexeclibgomime_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(toolexeclibgomimedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgomimedir)"
@@ -3555,6 +3611,46 @@ uninstall-toolexeclibgonetDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgonetdir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgonetdir)" && rm -f $$files
+install-toolexeclibgonethttpDATA: $(toolexeclibgonethttp_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgonethttpdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgonethttpdir)"
+       @list='$(toolexeclibgonethttp_DATA)'; test -n "$(toolexeclibgonethttpdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgonethttpdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgonethttpdir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgonethttpDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgonethttp_DATA)'; test -n "$(toolexeclibgonethttpdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgonethttpdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgonethttpdir)" && rm -f $$files
+install-toolexeclibgonetrpcDATA: $(toolexeclibgonetrpc_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgonetrpcdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgonetrpcdir)"
+       @list='$(toolexeclibgonetrpc_DATA)'; test -n "$(toolexeclibgonetrpcdir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgonetrpcdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgonetrpcdir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgonetrpcDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgonetrpc_DATA)'; test -n "$(toolexeclibgonetrpcdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgonetrpcdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgonetrpcdir)" && rm -f $$files
 install-toolexeclibgooldDATA: $(toolexeclibgoold_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(toolexeclibgoolddir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgoolddir)"
@@ -3635,26 +3731,6 @@ uninstall-toolexeclibgoregexpDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgoregexpdir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgoregexpdir)" && rm -f $$files
-install-toolexeclibgorpcDATA: $(toolexeclibgorpc_DATA)
-       @$(NORMAL_INSTALL)
-       test -z "$(toolexeclibgorpcdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgorpcdir)"
-       @list='$(toolexeclibgorpc_DATA)'; test -n "$(toolexeclibgorpcdir)" || list=; \
-       for p in $$list; do \
-         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         echo "$$d$$p"; \
-       done | $(am__base_list) | \
-       while read files; do \
-         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgorpcdir)'"; \
-         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgorpcdir)" || exit $$?; \
-       done
-
-uninstall-toolexeclibgorpcDATA:
-       @$(NORMAL_UNINSTALL)
-       @list='$(toolexeclibgorpc_DATA)'; test -n "$(toolexeclibgorpcdir)" || list=; \
-       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-       test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(toolexeclibgorpcdir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(toolexeclibgorpcdir)" && rm -f $$files
 install-toolexeclibgoruntimeDATA: $(toolexeclibgoruntime_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(toolexeclibgoruntimedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgoruntimedir)"
@@ -3695,46 +3771,86 @@ uninstall-toolexeclibgosyncDATA:
        test -n "$$files" || exit 0; \
        echo " ( cd '$(DESTDIR)$(toolexeclibgosyncdir)' && rm -f" $$files ")"; \
        cd "$(DESTDIR)$(toolexeclibgosyncdir)" && rm -f $$files
-install-toolexeclibgotemplateDATA: $(toolexeclibgotemplate_DATA)
+install-toolexeclibgotestingDATA: $(toolexeclibgotesting_DATA)
        @$(NORMAL_INSTALL)
-       test -z "$(toolexeclibgotemplatedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgotemplatedir)"
-       @list='$(toolexeclibgotemplate_DATA)'; test -n "$(toolexeclibgotemplatedir)" || list=; \
+       test -z "$(toolexeclibgotestingdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgotestingdir)"
+       @list='$(toolexeclibgotesting_DATA)'; test -n "$(toolexeclibgotestingdir)" || list=; \
        for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          echo "$$d$$p"; \
        done | $(am__base_list) | \
        while read files; do \
-         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotemplatedir)'"; \
-         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotemplatedir)" || exit $$?; \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotestingdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotestingdir)" || exit $$?; \
        done
 
-uninstall-toolexeclibgotemplateDATA:
+uninstall-toolexeclibgotestingDATA:
        @$(NORMAL_UNINSTALL)
-       @list='$(toolexeclibgotemplate_DATA)'; test -n "$(toolexeclibgotemplatedir)" || list=; \
+       @list='$(toolexeclibgotesting_DATA)'; test -n "$(toolexeclibgotestingdir)" || list=; \
        files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
        test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(toolexeclibgotemplatedir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(toolexeclibgotemplatedir)" && rm -f $$files
-install-toolexeclibgotestingDATA: $(toolexeclibgotesting_DATA)
+       echo " ( cd '$(DESTDIR)$(toolexeclibgotestingdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgotestingdir)" && rm -f $$files
+install-toolexeclibgotextDATA: $(toolexeclibgotext_DATA)
        @$(NORMAL_INSTALL)
-       test -z "$(toolexeclibgotestingdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgotestingdir)"
-       @list='$(toolexeclibgotesting_DATA)'; test -n "$(toolexeclibgotestingdir)" || list=; \
+       test -z "$(toolexeclibgotextdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgotextdir)"
+       @list='$(toolexeclibgotext_DATA)'; test -n "$(toolexeclibgotextdir)" || list=; \
        for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
          echo "$$d$$p"; \
        done | $(am__base_list) | \
        while read files; do \
-         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotestingdir)'"; \
-         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotestingdir)" || exit $$?; \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotextdir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotextdir)" || exit $$?; \
        done
 
-uninstall-toolexeclibgotestingDATA:
+uninstall-toolexeclibgotextDATA:
        @$(NORMAL_UNINSTALL)
-       @list='$(toolexeclibgotesting_DATA)'; test -n "$(toolexeclibgotestingdir)" || list=; \
+       @list='$(toolexeclibgotext_DATA)'; test -n "$(toolexeclibgotextdir)" || list=; \
        files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
        test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(toolexeclibgotestingdir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(toolexeclibgotestingdir)" && rm -f $$files
+       echo " ( cd '$(DESTDIR)$(toolexeclibgotextdir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgotextdir)" && rm -f $$files
+install-toolexeclibgotexttemplateDATA: $(toolexeclibgotexttemplate_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgotexttemplatedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgotexttemplatedir)"
+       @list='$(toolexeclibgotexttemplate_DATA)'; test -n "$(toolexeclibgotexttemplatedir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgotexttemplatedir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgotexttemplatedir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgotexttemplateDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgotexttemplate_DATA)'; test -n "$(toolexeclibgotexttemplatedir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgotexttemplatedir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgotexttemplatedir)" && rm -f $$files
+install-toolexeclibgounicodeDATA: $(toolexeclibgounicode_DATA)
+       @$(NORMAL_INSTALL)
+       test -z "$(toolexeclibgounicodedir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibgounicodedir)"
+       @list='$(toolexeclibgounicode_DATA)'; test -n "$(toolexeclibgounicodedir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(toolexeclibgounicodedir)'"; \
+         $(INSTALL_DATA) $$files "$(DESTDIR)$(toolexeclibgounicodedir)" || exit $$?; \
+       done
+
+uninstall-toolexeclibgounicodeDATA:
+       @$(NORMAL_UNINSTALL)
+       @list='$(toolexeclibgounicode_DATA)'; test -n "$(toolexeclibgounicodedir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(toolexeclibgounicodedir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(toolexeclibgounicodedir)" && rm -f $$files
 
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
@@ -4052,7 +4168,7 @@ all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) all-multi $(DATA) \
                config.h
 installdirs: installdirs-recursive
 installdirs-am:
-       for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgoexpguidir)" "$(DESTDIR)$(toolexeclibgoexpsqldir)" "$(DESTDIR)$(toolexeclibgoexptemplatedir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohttpdir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgoolddir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgorpcdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotemplatedir)" "$(DESTDIR)$(toolexeclibgotestingdir)"; do \
+       for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(toolexeclibgodir)" "$(DESTDIR)$(toolexeclibgoarchivedir)" "$(DESTDIR)$(toolexeclibgocompressdir)" "$(DESTDIR)$(toolexeclibgocontainerdir)" "$(DESTDIR)$(toolexeclibgocryptodir)" "$(DESTDIR)$(toolexeclibgocryptoopenpgpdir)" "$(DESTDIR)$(toolexeclibgocryptox509dir)" "$(DESTDIR)$(toolexeclibgodebugdir)" "$(DESTDIR)$(toolexeclibgoencodingdir)" "$(DESTDIR)$(toolexeclibgoexpdir)" "$(DESTDIR)$(toolexeclibgoexpguidir)" "$(DESTDIR)$(toolexeclibgoexpsqldir)" "$(DESTDIR)$(toolexeclibgogodir)" "$(DESTDIR)$(toolexeclibgohashdir)" "$(DESTDIR)$(toolexeclibgohtmldir)" "$(DESTDIR)$(toolexeclibgoimagedir)" "$(DESTDIR)$(toolexeclibgoindexdir)" "$(DESTDIR)$(toolexeclibgoiodir)" "$(DESTDIR)$(toolexeclibgologdir)" "$(DESTDIR)$(toolexeclibgomathdir)" "$(DESTDIR)$(toolexeclibgomimedir)" "$(DESTDIR)$(toolexeclibgonetdir)" "$(DESTDIR)$(toolexeclibgonethttpdir)" "$(DESTDIR)$(toolexeclibgonetrpcdir)" "$(DESTDIR)$(toolexeclibgoolddir)" "$(DESTDIR)$(toolexeclibgoosdir)" "$(DESTDIR)$(toolexeclibgopathdir)" "$(DESTDIR)$(toolexeclibgoregexpdir)" "$(DESTDIR)$(toolexeclibgoruntimedir)" "$(DESTDIR)$(toolexeclibgosyncdir)" "$(DESTDIR)$(toolexeclibgotestingdir)" "$(DESTDIR)$(toolexeclibgotextdir)" "$(DESTDIR)$(toolexeclibgotexttemplatedir)" "$(DESTDIR)$(toolexeclibgounicodedir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
        done
 install: install-recursive
@@ -4123,18 +4239,19 @@ install-exec-am: install-multi install-toolexeclibLIBRARIES \
        install-toolexeclibgodebugDATA \
        install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
        install-toolexeclibgoexpguiDATA \
-       install-toolexeclibgoexpsqlDATA \
-       install-toolexeclibgoexptemplateDATA \
-       install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
-       install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \
-       install-toolexeclibgoindexDATA install-toolexeclibgoioDATA \
-       install-toolexeclibgomimeDATA install-toolexeclibgonetDATA \
-       install-toolexeclibgooldDATA install-toolexeclibgoosDATA \
-       install-toolexeclibgopathDATA install-toolexeclibgoregexpDATA \
-       install-toolexeclibgorpcDATA install-toolexeclibgoruntimeDATA \
-       install-toolexeclibgosyncDATA \
-       install-toolexeclibgotemplateDATA \
-       install-toolexeclibgotestingDATA
+       install-toolexeclibgoexpsqlDATA install-toolexeclibgogoDATA \
+       install-toolexeclibgohashDATA install-toolexeclibgohtmlDATA \
+       install-toolexeclibgoimageDATA install-toolexeclibgoindexDATA \
+       install-toolexeclibgoioDATA install-toolexeclibgologDATA \
+       install-toolexeclibgomathDATA install-toolexeclibgomimeDATA \
+       install-toolexeclibgonetDATA install-toolexeclibgonethttpDATA \
+       install-toolexeclibgonetrpcDATA install-toolexeclibgooldDATA \
+       install-toolexeclibgoosDATA install-toolexeclibgopathDATA \
+       install-toolexeclibgoregexpDATA \
+       install-toolexeclibgoruntimeDATA install-toolexeclibgosyncDATA \
+       install-toolexeclibgotestingDATA install-toolexeclibgotextDATA \
+       install-toolexeclibgotexttemplateDATA \
+       install-toolexeclibgounicodeDATA
 
 install-html: install-html-recursive
 
@@ -4189,20 +4306,23 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
        uninstall-toolexeclibgoexpDATA \
        uninstall-toolexeclibgoexpguiDATA \
        uninstall-toolexeclibgoexpsqlDATA \
-       uninstall-toolexeclibgoexptemplateDATA \
        uninstall-toolexeclibgogoDATA uninstall-toolexeclibgohashDATA \
-       uninstall-toolexeclibgohttpDATA \
+       uninstall-toolexeclibgohtmlDATA \
        uninstall-toolexeclibgoimageDATA \
        uninstall-toolexeclibgoindexDATA uninstall-toolexeclibgoioDATA \
+       uninstall-toolexeclibgologDATA uninstall-toolexeclibgomathDATA \
        uninstall-toolexeclibgomimeDATA uninstall-toolexeclibgonetDATA \
+       uninstall-toolexeclibgonethttpDATA \
+       uninstall-toolexeclibgonetrpcDATA \
        uninstall-toolexeclibgooldDATA uninstall-toolexeclibgoosDATA \
        uninstall-toolexeclibgopathDATA \
        uninstall-toolexeclibgoregexpDATA \
-       uninstall-toolexeclibgorpcDATA \
        uninstall-toolexeclibgoruntimeDATA \
        uninstall-toolexeclibgosyncDATA \
-       uninstall-toolexeclibgotemplateDATA \
-       uninstall-toolexeclibgotestingDATA
+       uninstall-toolexeclibgotestingDATA \
+       uninstall-toolexeclibgotextDATA \
+       uninstall-toolexeclibgotexttemplateDATA \
+       uninstall-toolexeclibgounicodeDATA
 
 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all all-multi \
        clean-multi ctags-recursive distclean-multi install-am \
@@ -4233,18 +4353,19 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
        install-toolexeclibgodebugDATA \
        install-toolexeclibgoencodingDATA install-toolexeclibgoexpDATA \
        install-toolexeclibgoexpguiDATA \
-       install-toolexeclibgoexpsqlDATA \
-       install-toolexeclibgoexptemplateDATA \
-       install-toolexeclibgogoDATA install-toolexeclibgohashDATA \
-       install-toolexeclibgohttpDATA install-toolexeclibgoimageDATA \
-       install-toolexeclibgoindexDATA install-toolexeclibgoioDATA \
-       install-toolexeclibgomimeDATA install-toolexeclibgonetDATA \
-       install-toolexeclibgooldDATA install-toolexeclibgoosDATA \
-       install-toolexeclibgopathDATA install-toolexeclibgoregexpDATA \
-       install-toolexeclibgorpcDATA install-toolexeclibgoruntimeDATA \
-       install-toolexeclibgosyncDATA \
-       install-toolexeclibgotemplateDATA \
-       install-toolexeclibgotestingDATA installcheck installcheck-am \
+       install-toolexeclibgoexpsqlDATA install-toolexeclibgogoDATA \
+       install-toolexeclibgohashDATA install-toolexeclibgohtmlDATA \
+       install-toolexeclibgoimageDATA install-toolexeclibgoindexDATA \
+       install-toolexeclibgoioDATA install-toolexeclibgologDATA \
+       install-toolexeclibgomathDATA install-toolexeclibgomimeDATA \
+       install-toolexeclibgonetDATA install-toolexeclibgonethttpDATA \
+       install-toolexeclibgonetrpcDATA install-toolexeclibgooldDATA \
+       install-toolexeclibgoosDATA install-toolexeclibgopathDATA \
+       install-toolexeclibgoregexpDATA \
+       install-toolexeclibgoruntimeDATA install-toolexeclibgosyncDATA \
+       install-toolexeclibgotestingDATA install-toolexeclibgotextDATA \
+       install-toolexeclibgotexttemplateDATA \
+       install-toolexeclibgounicodeDATA installcheck installcheck-am \
        installdirs installdirs-am maintainer-clean \
        maintainer-clean-generic maintainer-clean-multi mostlyclean \
        mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
@@ -4263,20 +4384,23 @@ uninstall-am: uninstall-toolexeclibLIBRARIES \
        uninstall-toolexeclibgoexpDATA \
        uninstall-toolexeclibgoexpguiDATA \
        uninstall-toolexeclibgoexpsqlDATA \
-       uninstall-toolexeclibgoexptemplateDATA \
        uninstall-toolexeclibgogoDATA uninstall-toolexeclibgohashDATA \
-       uninstall-toolexeclibgohttpDATA \
+       uninstall-toolexeclibgohtmlDATA \
        uninstall-toolexeclibgoimageDATA \
        uninstall-toolexeclibgoindexDATA uninstall-toolexeclibgoioDATA \
+       uninstall-toolexeclibgologDATA uninstall-toolexeclibgomathDATA \
        uninstall-toolexeclibgomimeDATA uninstall-toolexeclibgonetDATA \
+       uninstall-toolexeclibgonethttpDATA \
+       uninstall-toolexeclibgonetrpcDATA \
        uninstall-toolexeclibgooldDATA uninstall-toolexeclibgoosDATA \
        uninstall-toolexeclibgopathDATA \
        uninstall-toolexeclibgoregexpDATA \
-       uninstall-toolexeclibgorpcDATA \
        uninstall-toolexeclibgoruntimeDATA \
        uninstall-toolexeclibgosyncDATA \
-       uninstall-toolexeclibgotemplateDATA \
-       uninstall-toolexeclibgotestingDATA
+       uninstall-toolexeclibgotestingDATA \
+       uninstall-toolexeclibgotextDATA \
+       uninstall-toolexeclibgotexttemplateDATA \
+       uninstall-toolexeclibgounicodeDATA
 
 
 goc2c.$(OBJEXT): runtime/goc2c.c
@@ -4309,6 +4433,10 @@ sigqueue.c: $(srcdir)/runtime/sigqueue.goc goc2c
        ./goc2c --gcc --go-prefix libgo_runtime $< > $@.tmp
        mv -f $@.tmp $@
 
+time.c: $(srcdir)/runtime/time.goc goc2c
+       ./goc2c --gcc --go-prefix libgo_time $< > $@.tmp
+       mv -f $@.tmp $@
+
 %.c: $(srcdir)/runtime/%.goc goc2c
        ./goc2c --gcc $< > $@.tmp
        mv -f $@.tmp $@
@@ -4375,24 +4503,6 @@ s-epoll: Makefile
        $(SHELL) $(srcdir)/../move-if-change epoll.go.tmp epoll.go
        $(STAMP) $@
 
-@go_include@ asn1/asn1.lo.dep
-asn1/asn1.lo.dep: $(go_asn1_files)
-       $(BUILDDEPS)
-asn1/asn1.lo: $(go_asn1_files)
-       $(BUILDPACKAGE)
-asn1/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: asn1/check
-
-@go_include@ big/big.lo.dep
-big/big.lo.dep: $(go_big_files)
-       $(BUILDDEPS)
-big/big.lo: $(go_big_files)
-       $(BUILDPACKAGE)
-big/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: big/check
-
 @go_include@ bufio/bufio.lo.dep
 bufio/bufio.lo.dep: $(go_bufio_files)
        $(BUILDDEPS)
@@ -4413,15 +4523,6 @@ bytes/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: bytes/check
 
-@go_include@ cmath/cmath.lo.dep
-cmath/cmath.lo.dep: $(go_cmath_files)
-       $(BUILDDEPS)
-cmath/cmath.lo: $(go_cmath_files)
-       $(BUILDPACKAGE)
-cmath/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: cmath/check
-
 @go_include@ crypto/crypto.lo.dep
 crypto/crypto.lo.dep: $(go_crypto_files)
        $(BUILDDEPS)
@@ -4431,15 +4532,6 @@ crypto/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: crypto/check
 
-@go_include@ csv/csv.lo.dep
-csv/csv.lo.dep: $(go_csv_files)
-       $(BUILDDEPS)
-csv/csv.lo: $(go_csv_files)
-       $(BUILDPACKAGE)
-csv/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: csv/check
-
 @go_include@ errors/errors.lo.dep
 errors/errors.lo.dep: $(go_errors_files)
        $(BUILDDEPS)
@@ -4449,15 +4541,6 @@ errors/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: errors/check
 
-@go_include@ exec/exec.lo.dep
-exec/exec.lo.dep: $(go_exec_files)
-       $(BUILDDEPS)
-exec/exec.lo: $(go_exec_files)
-       $(BUILDPACKAGE)
-exec/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: exec/check
-
 @go_include@ expvar/expvar.lo.dep
 expvar/expvar.lo.dep: $(go_expvar_files)
        $(BUILDDEPS)
@@ -4485,15 +4568,6 @@ fmt/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: fmt/check
 
-@go_include@ gob/gob.lo.dep
-gob/gob.lo.dep: $(go_gob_files)
-       $(BUILDDEPS)
-gob/gob.lo: $(go_gob_files)
-       $(BUILDPACKAGE)
-gob/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: gob/check
-
 @go_include@ hash/hash.lo.dep
 hash/hash.lo.dep: $(go_hash_files)
        $(BUILDDEPS)
@@ -4512,15 +4586,6 @@ html/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: html/check
 
-@go_include@ http/http.lo.dep
-http/http.lo.dep: $(go_http_files)
-       $(BUILDDEPS)
-http/http.lo: $(go_http_files)
-       $(BUILDPACKAGE)
-http/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: http/check
-
 @go_include@ image/image.lo.dep
 image/image.lo.dep: $(go_image_files)
        $(BUILDDEPS)
@@ -4539,15 +4604,6 @@ io/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: io/check
 
-@go_include@ json/json.lo.dep
-json/json.lo.dep: $(go_json_files)
-       $(BUILDDEPS)
-json/json.lo: $(go_json_files)
-       $(BUILDPACKAGE)
-json/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: json/check
-
 @go_include@ log/log.lo.dep
 log/log.lo.dep: $(go_log_files)
        $(BUILDDEPS)
@@ -4566,15 +4622,6 @@ math/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: math/check
 
-@go_include@ mail/mail.lo.dep
-mail/mail.lo.dep: $(go_mail_files)
-       $(BUILDDEPS)
-mail/mail.lo: $(go_mail_files)
-       $(BUILDPACKAGE)
-mail/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: mail/check
-
 @go_include@ mime/mime.lo.dep
 mime/mime.lo.dep: $(go_mime_files)
        $(BUILDDEPS)
@@ -4624,15 +4671,6 @@ path/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: path/check
 
-@go_include@ rand/rand.lo.dep
-rand/rand.lo.dep: $(go_rand_files)
-       $(BUILDDEPS)
-rand/rand.lo: $(go_rand_files)
-       $(BUILDPACKAGE)
-rand/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: rand/check
-
 @go_include@ reflect/reflect.lo.dep
 reflect/reflect.lo.dep: $(go_reflect_files)
        $(BUILDDEPS)
@@ -4651,15 +4689,6 @@ regexp/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: regexp/check
 
-@go_include@ rpc/rpc.lo.dep
-rpc/rpc.lo.dep: $(go_rpc_files)
-       $(BUILDDEPS)
-rpc/rpc.lo: $(go_rpc_files)
-       $(BUILDPACKAGE)
-rpc/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: rpc/check
-
 @go_include@ runtime/runtime.lo.dep
 runtime/runtime.lo.dep: $(go_runtime_files)
        $(BUILDDEPS)
@@ -4669,23 +4698,15 @@ runtime/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: runtime/check
 
-@go_include@ scanner/scanner.lo.dep
-scanner/scanner.lo.dep: $(go_scanner_files)
-       $(BUILDDEPS)
-scanner/scanner.lo: $(go_scanner_files)
-       $(BUILDPACKAGE)
-scanner/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: scanner/check
-
-@go_include@ smtp/smtp.lo.dep
-smtp/smtp.lo.dep: $(go_smtp_files)
+@go_include@ text/scanner.lo.dep
+text/scanner.lo.dep: $(go_text_scanner_files)
        $(BUILDDEPS)
-smtp/smtp.lo: $(go_smtp_files)
+text/scanner.lo: $(go_text_scanner_files)
        $(BUILDPACKAGE)
-smtp/check: $(CHECK_DEPS)
+text/scanner/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/scanner
        @$(CHECK)
-.PHONY: smtp/check
+.PHONY: text/scanner/check
 
 @go_include@ sort/sort.lo.dep
 sort/sort.lo.dep: $(go_sort_files)
@@ -4723,35 +4744,6 @@ sync/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: sync/check
 
-@go_include@ syslog/syslog.lo.dep
-syslog/syslog.lo.dep: $(go_syslog_files)
-       $(BUILDDEPS)
-syslog/syslog.lo: $(go_syslog_files)
-       $(BUILDPACKAGE)
-syslog/syslog_c.lo: $(go_syslog_c_files) syslog/syslog.lo
-       $(LTCOMPILE) -c -o $@ $(srcdir)/go/syslog/syslog_c.c
-syslog/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: syslog/check
-
-@go_include@ tabwriter/tabwriter.lo.dep
-tabwriter/tabwriter.lo.dep: $(go_tabwriter_files)
-       $(BUILDDEPS)
-tabwriter/tabwriter.lo: $(go_tabwriter_files)
-       $(BUILDPACKAGE)
-tabwriter/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: tabwriter/check
-
-@go_include@ template/template.lo.dep
-template/template.lo.dep: $(go_template_files)
-       $(BUILDDEPS)
-template/template.lo: $(go_template_files)
-       $(BUILDPACKAGE)
-template/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: template/check
-
 @go_include@ testing/testing.lo.dep
 testing/testing.lo.dep: $(go_testing_files)
        $(BUILDDEPS)
@@ -4779,33 +4771,6 @@ unicode/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: unicode/check
 
-@go_include@ url/url.lo.dep
-url/url.lo.dep: $(go_url_files)
-       $(BUILDDEPS)
-url/url.lo: $(go_url_files)
-       $(BUILDPACKAGE)
-url/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: url/check
-
-@go_include@ utf16/utf16.lo.dep
-utf16/utf16.lo.dep: $(go_utf16_files)
-       $(BUILDDEPS)
-utf16/utf16.lo: $(go_utf16_files)
-       $(BUILDPACKAGE)
-utf16/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: utf16/check
-
-@go_include@ utf8/utf8.lo.dep
-utf8/utf8.lo.dep: $(go_utf8_files)
-       $(BUILDDEPS)
-utf8/utf8.lo: $(go_utf8_files)
-       $(BUILDPACKAGE)
-utf8/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: utf8/check
-
 @go_include@ websocket/websocket.lo.dep
 websocket/websocket.lo.dep: $(go_websocket_files)
        $(BUILDDEPS)
@@ -4815,15 +4780,6 @@ websocket/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: websocket/check
 
-@go_include@ xml/xml.lo.dep
-xml/xml.lo.dep: $(go_xml_files)
-       $(BUILDDEPS)
-xml/xml.lo: $(go_xml_files)
-       $(BUILDPACKAGE)
-xml/check: $(CHECK_DEPS)
-       @$(CHECK)
-.PHONY: xml/check
-
 @go_include@ archive/tar.lo.dep
 archive/tar.lo.dep: $(go_archive_tar_files)
        $(BUILDDEPS)
@@ -5294,6 +5250,16 @@ debug/pe/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: debug/pe/check
 
+@go_include@ encoding/asn1.lo.dep
+encoding/asn1.lo.dep: $(go_encoding_asn1_files)
+       $(BUILDDEPS)
+encoding/asn1.lo: $(go_encoding_asn1_files)
+       $(BUILDPACKAGE)
+encoding/asn1/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/asn1
+       @$(CHECK)
+.PHONY: encoding/asn1/check
+
 @go_include@ encoding/ascii85.lo.dep
 encoding/ascii85.lo.dep: $(go_encoding_ascii85_files)
        $(BUILDDEPS)
@@ -5334,6 +5300,16 @@ encoding/binary/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/binary/check
 
+@go_include@ encoding/csv.lo.dep
+encoding/csv.lo.dep: $(go_encoding_csv_files)
+       $(BUILDDEPS)
+encoding/csv.lo: $(go_encoding_csv_files)
+       $(BUILDPACKAGE)
+encoding/csv/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/csv
+       @$(CHECK)
+.PHONY: encoding/csv/check
+
 @go_include@ encoding/git85.lo.dep
 encoding/git85.lo.dep: $(go_encoding_git85_files)
        $(BUILDDEPS)
@@ -5344,6 +5320,16 @@ encoding/git85/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/git85/check
 
+@go_include@ encoding/gob.lo.dep
+encoding/gob.lo.dep: $(go_encoding_gob_files)
+       $(BUILDDEPS)
+encoding/gob.lo: $(go_encoding_gob_files)
+       $(BUILDPACKAGE)
+encoding/gob/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/gob
+       @$(CHECK)
+.PHONY: encoding/gob/check
+
 @go_include@ encoding/hex.lo.dep
 encoding/hex.lo.dep: $(go_encoding_hex_files)
        $(BUILDDEPS)
@@ -5354,6 +5340,16 @@ encoding/hex/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/hex/check
 
+@go_include@ encoding/json.lo.dep
+encoding/json.lo.dep: $(go_encoding_json_files)
+       $(BUILDDEPS)
+encoding/json.lo: $(go_encoding_json_files)
+       $(BUILDPACKAGE)
+encoding/json/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/json
+       @$(CHECK)
+.PHONY: encoding/json/check
+
 @go_include@ encoding/pem.lo.dep
 encoding/pem.lo.dep: $(go_encoding_pem_files)
        $(BUILDDEPS)
@@ -5364,6 +5360,16 @@ encoding/pem/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: encoding/pem/check
 
+@go_include@ encoding/xml.lo.dep
+encoding/xml.lo.dep: $(go_encoding_xml_files)
+       $(BUILDDEPS)
+encoding/xml.lo: $(go_encoding_xml_files)
+       $(BUILDPACKAGE)
+encoding/xml/check: $(CHECK_DEPS)
+       @$(MKDIR_P) encoding/xml
+       @$(CHECK)
+.PHONY: encoding/xml/check
+
 @go_include@ exp/ebnf.lo.dep
 exp/ebnf.lo.dep: $(go_exp_ebnf_files)
        $(BUILDDEPS)
@@ -5474,15 +5480,15 @@ exp/sql/driver/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: exp/sql/driver/check
 
-@go_include@ exp/template/html.lo.dep
-exp/template/html.lo.dep: $(go_exp_template_html_files)
+@go_include@ html/template.lo.dep
+html/template.lo.dep: $(go_html_template_files)
        $(BUILDDEPS)
-exp/template/html.lo: $(go_exp_template_html_files)
+html/template.lo: $(go_html_template_files)
        $(BUILDPACKAGE)
-exp/template/html/check: $(CHECK_DEPS)
-       @$(MKDIR_P) exp/template/html
+html/template/check: $(CHECK_DEPS)
+       @$(MKDIR_P) html/template
        @$(CHECK)
-.PHONY: exp/template/html/check
+.PHONY: html/template/check
 
 @go_include@ go/ast.lo.dep
 go/ast.lo.dep: $(go_go_ast_files)
@@ -5603,46 +5609,6 @@ hash/fnv/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: hash/fnv/check
 
-@go_include@ http/cgi.lo.dep
-http/cgi.lo.dep: $(go_http_cgi_files)
-       $(BUILDDEPS)
-http/cgi.lo: $(go_http_cgi_files)
-       $(BUILDPACKAGE)
-http/cgi/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/cgi
-       @$(CHECK)
-.PHONY: http/cgi/check
-
-@go_include@ http/fcgi.lo.dep
-http/fcgi.lo.dep: $(go_http_fcgi_files)
-       $(BUILDDEPS)
-http/fcgi.lo: $(go_http_fcgi_files)
-       $(BUILDPACKAGE)
-http/fcgi/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/fcgi
-       @$(CHECK)
-.PHONY: http/fcgi/check
-
-@go_include@ http/httptest.lo.dep
-http/httptest.lo.dep: $(go_http_httptest_files)
-       $(BUILDDEPS)
-http/httptest.lo: $(go_http_httptest_files)
-       $(BUILDPACKAGE)
-http/httptest/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/httptest
-       @$(CHECK)
-.PHONY: http/httptest/check
-
-@go_include@ http/pprof.lo.dep
-http/pprof.lo.dep: $(go_http_pprof_files)
-       $(BUILDDEPS)
-http/pprof.lo: $(go_http_pprof_files)
-       $(BUILDPACKAGE)
-http/pprof/check: $(CHECK_DEPS)
-       @$(MKDIR_P) http/pprof
-       @$(CHECK)
-.PHONY: http/pprof/check
-
 @go_include@ image/bmp.lo.dep
 image/bmp.lo.dep: $(go_image_bmp_files)
        $(BUILDDEPS)
@@ -5743,6 +5709,48 @@ io/ioutil/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: io/ioutil/check
 
+@go_include@ log/syslog.lo.dep
+log/syslog.lo.dep: $(go_log_syslog_files)
+       $(BUILDDEPS)
+log/syslog.lo: $(go_log_syslog_files)
+       $(BUILDPACKAGE)
+log/syslog/syslog_c.lo: $(go_syslog_c_files) log/syslog.lo
+       $(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c
+log/syslog/check: $(CHECK_DEPS)
+       @$(MKDIR_P) log/syslog
+       @$(CHECK)
+.PHONY: log/syslog/check
+
+@go_include@ math/big.lo.dep
+math/big.lo.dep: $(go_math_big_files)
+       $(BUILDDEPS)
+math/big.lo: $(go_math_big_files)
+       $(BUILDPACKAGE)
+math/big/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/big
+       @$(CHECK)
+.PHONY: math/big/check
+
+@go_include@ math/cmplx.lo.dep
+math/cmplx.lo.dep: $(go_math_cmplx_files)
+       $(BUILDDEPS)
+math/cmplx.lo: $(go_math_cmplx_files)
+       $(BUILDPACKAGE)
+math/cmplx/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/cmplx
+       @$(CHECK)
+.PHONY: math/cmplx/check
+
+@go_include@ math/rand.lo.dep
+math/rand.lo.dep: $(go_math_rand_files)
+       $(BUILDDEPS)
+math/rand.lo: $(go_math_rand_files)
+       $(BUILDPACKAGE)
+math/rand/check: $(CHECK_DEPS)
+       @$(MKDIR_P) math/rand
+       @$(CHECK)
+.PHONY: math/rand/check
+
 @go_include@ mime/multipart.lo.dep
 mime/multipart.lo.dep: $(go_mime_multipart_files)
        $(BUILDDEPS)
@@ -5759,6 +5767,56 @@ net/dict.lo.dep: $(go_net_dict_files)
 net/dict.lo: $(go_net_dict_files)
        $(BUILDPACKAGE)
 
+@go_include@ net/http.lo.dep
+net/http.lo.dep: $(go_net_http_files)
+       $(BUILDDEPS)
+net/http.lo: $(go_net_http_files)
+       $(BUILDPACKAGE)
+net/http/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http
+       @$(CHECK)
+.PHONY: net/http/check
+
+@go_include@ net/mail.lo.dep
+net/mail.lo.dep: $(go_net_mail_files)
+       $(BUILDDEPS)
+net/mail.lo: $(go_net_mail_files)
+       $(BUILDPACKAGE)
+net/mail/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/mail
+       @$(CHECK)
+.PHONY: net/mail/check
+
+@go_include@ net/rpc.lo.dep
+net/rpc.lo.dep: $(go_net_rpc_files)
+       $(BUILDDEPS)
+net/rpc.lo: $(go_net_rpc_files)
+       $(BUILDPACKAGE)
+net/rpc/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/rpc
+       @$(CHECK)
+.PHONY: net/rpc/check
+
+@go_include@ net/smtp.lo.dep
+net/smtp.lo.dep: $(go_net_smtp_files)
+       $(BUILDDEPS)
+net/smtp.lo: $(go_net_smtp_files)
+       $(BUILDPACKAGE)
+net/smtp/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/smtp
+       @$(CHECK)
+.PHONY: net/smtp/check
+
+@go_include@ net/url.lo.dep
+net/url.lo.dep: $(go_net_url_files)
+       $(BUILDDEPS)
+net/url.lo: $(go_net_url_files)
+       $(BUILDPACKAGE)
+net/url/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/url
+       @$(CHECK)
+.PHONY: net/url/check
+
 @go_include@ net/textproto.lo.dep
 net/textproto.lo.dep: $(go_net_textproto_files)
        $(BUILDDEPS)
@@ -5769,6 +5827,66 @@ net/textproto/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: net/textproto/check
 
+@go_include@ net/http/cgi.lo.dep
+net/http/cgi.lo.dep: $(go_net_http_cgi_files)
+       $(BUILDDEPS)
+net/http/cgi.lo: $(go_net_http_cgi_files)
+       $(BUILDPACKAGE)
+net/http/cgi/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/cgi
+       @$(CHECK)
+.PHONY: net/http/cgi/check
+
+@go_include@ net/http/fcgi.lo.dep
+net/http/fcgi.lo.dep: $(go_net_http_fcgi_files)
+       $(BUILDDEPS)
+net/http/fcgi.lo: $(go_net_http_fcgi_files)
+       $(BUILDPACKAGE)
+net/http/fcgi/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/fcgi
+       @$(CHECK)
+.PHONY: net/http/fcgi/check
+
+@go_include@ net/http/httptest.lo.dep
+net/http/httptest.lo.dep: $(go_net_http_httptest_files)
+       $(BUILDDEPS)
+net/http/httptest.lo: $(go_net_http_httptest_files)
+       $(BUILDPACKAGE)
+net/http/httptest/check: $(check_deps)
+       @$(MKDIR_P) net/http/httptest
+       @$(CHECK)
+.PHONY: net/http/httptest/check
+
+@go_include@ net/http/httputil.lo.dep
+net/http/httputil.lo.dep: $(go_net_http_httputil_files)
+       $(BUILDDEPS)
+net/http/httputil.lo: $(go_net_http_httputil_files)
+       $(BUILDPACKAGE)
+net/http/httputil/check: $(check_deps)
+       @$(MKDIR_P) net/http/httputil
+       @$(CHECK)
+.PHONY: net/http/httputil/check
+
+@go_include@ net/http/pprof.lo.dep
+net/http/pprof.lo.dep: $(go_net_http_pprof_files)
+       $(BUILDDEPS)
+net/http/pprof.lo: $(go_net_http_pprof_files)
+       $(BUILDPACKAGE)
+net/http/pprof/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/http/pprof
+       @$(CHECK)
+.PHONY: net/http/pprof/check
+
+@go_include@ net/rpc/jsonrpc.lo.dep
+net/rpc/jsonrpc.lo.dep: $(go_net_rpc_jsonrpc_files)
+       $(BUILDDEPS)
+net/rpc/jsonrpc.lo: $(go_net_rpc_jsonrpc_files)
+       $(BUILDPACKAGE)
+net/rpc/jsonrpc/check: $(CHECK_DEPS)
+       @$(MKDIR_P) net/rpc/jsonrpc
+       @$(CHECK)
+.PHONY: net/rpc/jsonrpc/check
+
 @go_include@ old/netchan.lo.dep
 old/netchan.lo.dep: $(go_old_netchan_files)
        $(BUILDDEPS)
@@ -5799,6 +5917,16 @@ old/template/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: old/template/check
 
+@go_include@ os/exec.lo.dep
+os/exec.lo.dep: $(go_os_exec_files)
+       $(BUILDDEPS)
+os/exec.lo: $(go_os_exec_files)
+       $(BUILDPACKAGE)
+os/exec/check: $(CHECK_DEPS)
+       @$(MKDIR_P) os/exec
+       @$(CHECK)
+.PHONY: os/exec/check
+
 @go_include@ os/user.lo.dep
 os/user.lo.dep: $(go_os_user_files)
        $(BUILDDEPS)
@@ -5839,16 +5967,6 @@ regexp/syntax/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: regexp/syntax/check
 
-@go_include@ rpc/jsonrpc.lo.dep
-rpc/jsonrpc.lo.dep: $(go_rpc_jsonrpc_files)
-       $(BUILDDEPS)
-rpc/jsonrpc.lo: $(go_rpc_jsonrpc_files)
-       $(BUILDPACKAGE)
-rpc/jsonrpc/check: $(CHECK_DEPS)
-       @$(MKDIR_P) rpc/jsonrpc
-       @$(CHECK)
-.PHONY: rpc/jsonrpc/check
-
 @go_include@ runtime/debug.lo.dep
 runtime/debug.lo.dep: $(go_runtime_debug_files)
        $(BUILDDEPS)
@@ -5881,15 +5999,34 @@ sync/atomic/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: sync/atomic/check
 
-@go_include@ template/parse.lo.dep
-template/parse.lo.dep: $(go_template_parse_files)
+@go_include@ text/tabwriter.lo.dep
+text/tabwriter.lo.dep: $(go_text_tabwriter_files)
+       $(BUILDDEPS)
+text/tabwriter.lo: $(go_text_tabwriter_files)
+       $(BUILDPACKAGE)
+text/tabwriter/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/tabwriter
+       @$(CHECK)
+.PHONY: text/tabwriter/check
+
+@go_include@ text/template.lo.dep
+text/template.lo.dep: $(go_text_template_files)
        $(BUILDDEPS)
-template/parse.lo: $(go_template_parse_files)
+text/template.lo: $(go_text_template_files)
        $(BUILDPACKAGE)
-template/parse/check: $(CHECK_DEPS)
-       @$(MKDIR_P) template/parse
+text/template/check: $(CHECK_DEPS)
        @$(CHECK)
-.PHONY: template/parse/check
+.PHONY: text/template/check
+
+@go_include@ text/template/parse.lo.dep
+text/template/parse.lo.dep: $(go_text_template_parse_files)
+       $(BUILDDEPS)
+text/template/parse.lo: $(go_text_template_parse_files)
+       $(BUILDPACKAGE)
+text/template/parse/check: $(CHECK_DEPS)
+       @$(MKDIR_P) text/template/parse
+       @$(CHECK)
+.PHONY: text/template/parse/check
 
 @go_include@ testing/iotest.lo.dep
 testing/iotest.lo.dep: $(go_testing_iotest_files)
@@ -5921,6 +6058,26 @@ testing/script/check: $(CHECK_DEPS)
        @$(CHECK)
 .PHONY: testing/script/check
 
+@go_include@ unicode/utf16.lo.dep
+unicode/utf16.lo.dep: $(go_unicode_utf16_files)
+       $(BUILDDEPS)
+unicode/utf16.lo: $(go_unicode_utf16_files)
+       $(BUILDPACKAGE)
+unicode/utf16/check: $(CHECK_DEPS)
+       @$(MKDIR_P) unicode/utf16
+       @$(CHECK)
+.PHONY: unicode/utf16/check
+
+@go_include@ unicode/utf8.lo.dep
+unicode/utf8.lo.dep: $(go_unicode_utf8_files)
+       $(BUILDDEPS)
+unicode/utf8.lo: $(go_unicode_utf8_files)
+       $(BUILDPACKAGE)
+unicode/utf8/check: $(CHECK_DEPS)
+       @$(MKDIR_P) unicode/utf8
+       @$(CHECK)
+.PHONY: unicode/utf8/check
+
 @go_include@ syscall/syscall.lo.dep
 syscall/syscall.lo.dep: $(go_syscall_files)
        $(BUILDDEPS)
@@ -5931,50 +6088,32 @@ syscall/errno.lo: go/syscall/errno.c
 syscall/wait.lo: go/syscall/wait.c
        $(LTCOMPILE) -c -o $@ $<
 
-asn1.gox: asn1/asn1.lo
-       $(BUILDGOX)
-big.gox: big/big.lo
-       $(BUILDGOX)
 bufio.gox: bufio/bufio.lo
        $(BUILDGOX)
 bytes.gox: bytes/bytes.lo
        $(BUILDGOX)
-cmath.gox: cmath/cmath.lo
-       $(BUILDGOX)
 crypto.gox: crypto/crypto.lo
        $(BUILDGOX)
-csv.gox: csv/csv.lo
-       $(BUILDGOX)
 errors.gox: errors/errors.lo
        $(BUILDGOX)
-exec.gox: exec/exec.lo
-       $(BUILDGOX)
 expvar.gox: expvar/expvar.lo
        $(BUILDGOX)
 flag.gox: flag/flag.lo
        $(BUILDGOX)
 fmt.gox: fmt/fmt.lo
        $(BUILDGOX)
-gob.gox: gob/gob.lo
-       $(BUILDGOX)
 hash.gox: hash/hash.lo
        $(BUILDGOX)
 html.gox: html/html.lo
        $(BUILDGOX)
-http.gox: http/http.lo
-       $(BUILDGOX)
 image.gox: image/image.lo
        $(BUILDGOX)
 io.gox: io/io.lo
        $(BUILDGOX)
-json.gox: json/json.lo
-       $(BUILDGOX)
 log.gox: log/log.lo
        $(BUILDGOX)
 math.gox: math/math.lo
        $(BUILDGOX)
-mail.gox: mail/mail.lo
-       $(BUILDGOX)
 mime.gox: mime/mime.lo
        $(BUILDGOX)
 net.gox: net/net.lo
@@ -5985,20 +6124,12 @@ patch.gox: patch/patch.lo
        $(BUILDGOX)
 path.gox: path/path.lo
        $(BUILDGOX)
-rand.gox: rand/rand.lo
-       $(BUILDGOX)
 reflect.gox: reflect/reflect.lo
        $(BUILDGOX)
 regexp.gox: regexp/regexp.lo
        $(BUILDGOX)
-rpc.gox: rpc/rpc.lo
-       $(BUILDGOX)
 runtime.gox: runtime/runtime.lo
        $(BUILDGOX)
-scanner.gox: scanner/scanner.lo
-       $(BUILDGOX)
-smtp.gox: smtp/smtp.lo
-       $(BUILDGOX)
 sort.gox: sort/sort.lo
        $(BUILDGOX)
 strconv.gox: strconv/strconv.lo
@@ -6007,30 +6138,16 @@ strings.gox: strings/strings.lo
        $(BUILDGOX)
 sync.gox: sync/sync.lo
        $(BUILDGOX)
-syslog.gox: syslog/syslog.lo
-       $(BUILDGOX)
 syscall.gox: syscall/syscall.lo
        $(BUILDGOX)
-tabwriter.gox: tabwriter/tabwriter.lo
-       $(BUILDGOX)
-template.gox: template/template.lo
-       $(BUILDGOX)
 testing.gox: testing/testing.lo
        $(BUILDGOX)
 time.gox: time/time.lo
        $(BUILDGOX)
 unicode.gox: unicode/unicode.lo
        $(BUILDGOX)
-url.gox: url/url.lo
-       $(BUILDGOX)
-utf16.gox: utf16/utf16.lo
-       $(BUILDGOX)
-utf8.gox: utf8/utf8.lo
-       $(BUILDGOX)
 websocket.gox: websocket/websocket.lo
        $(BUILDGOX)
-xml.gox: xml/xml.lo
-       $(BUILDGOX)
 
 archive/tar.gox: archive/tar.lo
        $(BUILDGOX)
@@ -6135,18 +6252,28 @@ debug/pe.gox: debug/pe.lo
 
 encoding/ascii85.gox: encoding/ascii85.lo
        $(BUILDGOX)
+encoding/asn1.gox: encoding/asn1.lo
+       $(BUILDGOX)
 encoding/base32.gox: encoding/base32.lo
        $(BUILDGOX)
 encoding/base64.gox: encoding/base64.lo
        $(BUILDGOX)
 encoding/binary.gox: encoding/binary.lo
        $(BUILDGOX)
+encoding/csv.gox: encoding/csv.lo
+       $(BUILDGOX)
 encoding/git85.gox: encoding/git85.lo
        $(BUILDGOX)
+encoding/gob.gox: encoding/gob.lo
+       $(BUILDGOX)
 encoding/hex.gox: encoding/hex.lo
        $(BUILDGOX)
+encoding/json.gox: encoding/json.lo
+       $(BUILDGOX)
 encoding/pem.gox: encoding/pem.lo
        $(BUILDGOX)
+encoding/xml.gox: encoding/xml.lo
+       $(BUILDGOX)
 
 exp/ebnf.gox: exp/ebnf.lo
        $(BUILDGOX)
@@ -6173,7 +6300,7 @@ exp/gui/x11.gox: exp/gui/x11.lo
 exp/sql/driver.gox: exp/sql/driver.lo
        $(BUILDGOX)
 
-exp/template/html.gox: exp/template/html.lo
+html/template.gox: html/template.lo
        $(BUILDGOX)
 
 go/ast.gox: go/ast.lo
@@ -6200,15 +6327,6 @@ hash/crc64.gox: hash/crc64.lo
 hash/fnv.gox: hash/fnv.lo
        $(BUILDGOX)
 
-http/cgi.gox: http/cgi.lo
-       $(BUILDGOX)
-http/fcgi.gox: http/fcgi.lo
-       $(BUILDGOX)
-http/httptest.gox: http/httptest.lo
-       $(BUILDGOX)
-http/pprof.gox: http/pprof.lo
-       $(BUILDGOX)
-
 image/bmp.gox: image/bmp.lo
        $(BUILDGOX)
 image/color.gox: image/color.lo
@@ -6232,13 +6350,47 @@ index/suffixarray.gox: index/suffixarray.lo
 io/ioutil.gox: io/ioutil.lo
        $(BUILDGOX)
 
+log/syslog.gox: log/syslog.lo
+       $(BUILDGOX)
+
+math/big.gox: math/big.lo
+       $(BUILDGOX)
+math/cmplx.gox: math/cmplx.lo
+       $(BUILDGOX)
+math/rand.gox: math/rand.lo
+       $(BUILDGOX)
+
 mime/multipart.gox: mime/multipart.lo
        $(BUILDGOX)
 
 net/dict.gox: net/dict.lo
        $(BUILDGOX)
+net/http.gox: net/http.lo
+       $(BUILDGOX)
+net/mail.gox: net/mail.lo
+       $(BUILDGOX)
+net/rpc.gox: net/rpc.lo
+       $(BUILDGOX)
+net/smtp.gox: net/smtp.lo
+       $(BUILDGOX)
 net/textproto.gox: net/textproto.lo
        $(BUILDGOX)
+net/url.gox: net/url.lo
+       $(BUILDGOX)
+
+net/http/cgi.gox: net/http/cgi.lo
+       $(BUILDGOX)
+net/http/fcgi.gox: net/http/fcgi.lo
+       $(BUILDGOX)
+net/http/httptest.gox: net/http/httptest.lo
+       $(BUILDGOX)
+net/http/httputil.gox: net/http/httputil.lo
+       $(BUILDGOX)
+net/http/pprof.gox: net/http/pprof.lo
+       $(BUILDGOX)
+
+net/rpc/jsonrpc.gox: net/rpc/jsonrpc.lo
+       $(BUILDGOX)
 
 old/netchan.gox: old/netchan.lo
        $(BUILDGOX)
@@ -6247,6 +6399,8 @@ old/regexp.gox: old/regexp.lo
 old/template.gox: old/template.lo
        $(BUILDGOX)
 
+os/exec.gox: os/exec.lo
+       $(BUILDGOX)
 os/user.gox: os/user.lo
        $(BUILDGOX)
 os/signal.gox: os/signal.lo
@@ -6258,9 +6412,6 @@ path/filepath.gox: path/filepath.lo
 regexp/syntax.gox: regexp/syntax.lo
        $(BUILDGOX)
 
-rpc/jsonrpc.gox: rpc/jsonrpc.lo
-       $(BUILDGOX)
-
 runtime/debug.gox: runtime/debug.lo
        $(BUILDGOX)
 runtime/pprof.gox: runtime/pprof.lo
@@ -6269,7 +6420,13 @@ runtime/pprof.gox: runtime/pprof.lo
 sync/atomic.gox: sync/atomic.lo
        $(BUILDGOX)
 
-template/parse.gox: template/parse.lo
+text/scanner.gox: text/scanner.lo
+       $(BUILDGOX)
+text/tabwriter.gox: text/tabwriter.lo
+       $(BUILDGOX)
+text/template.gox: text/template.lo
+       $(BUILDGOX)
+text/template/parse.gox: text/template/parse.lo
        $(BUILDGOX)
 
 testing/iotest.gox: testing/iotest.lo
@@ -6279,6 +6436,11 @@ testing/quick.gox: testing/quick.lo
 testing/script.gox: testing/script.lo
        $(BUILDGOX)
 
+unicode/utf16.gox: unicode/utf16.lo
+       $(BUILDGOX)
+unicode/utf8.gox: unicode/utf8.lo
+       $(BUILDGOX)
+
 check: check-tail
 check-recursive: check-head
 
index 65bf120..facba2c 100644 (file)
@@ -29,7 +29,7 @@ var (
 //     tr := tar.NewReader(r)
 //     for {
 //             hdr, err := tr.Next()
-//             if err == os.EOF {
+//             if err == io.EOF {
 //                     // end of tar archive
 //                     break
 //             }
@@ -200,7 +200,7 @@ func (tr *Reader) readHeader() *Header {
 }
 
 // Read reads from the current entry in the tar archive.
-// It returns 0, os.EOF when it reaches the end of that entry,
+// It returns 0, io.EOF when it reaches the end of that entry,
 // until Next is called to advance to the next entry.
 func (tr *Reader) Read(b []byte) (n int, err error) {
        if tr.nb == 0 {
index 64152b4..cfbe549 100644 (file)
@@ -7,10 +7,10 @@ package zip
 import (
        "bufio"
        "compress/flate"
+       "encoding/binary"
        "errors"
        "hash"
        "hash/crc32"
-       "encoding/binary"
        "io"
        "io/ioutil"
        "os"
@@ -60,6 +60,7 @@ func OpenReader(name string) (*ReadCloser, error) {
                f.Close()
                return nil, err
        }
+       r.f = f
        return r, nil
 }
 
index 4d80aab..ca0b04e 100644 (file)
@@ -98,7 +98,11 @@ func readTestZip(t *testing.T, zt ZipTest) {
        if err == FormatError {
                return
        }
-       defer z.Close()
+       defer func() {
+               if err := z.Close(); err != nil {
+                       t.Errorf("error %q when closing zip file", err)
+               }
+       }()
 
        // bail here if no Files expected to be tested
        // (there may actually be files in the zip, but we don't care)
index b562f84..25491dc 100644 (file)
@@ -7,7 +7,7 @@ package zip
 import (
        "bytes"
        "io/ioutil"
-       "rand"
+       "math/rand"
        "testing"
 )
 
index f4ed91b..61e338b 100644 (file)
@@ -11,7 +11,7 @@ import (
        "bytes"
        "io"
        "strconv"
-       "utf8"
+       "unicode/utf8"
 )
 
 const (
@@ -135,7 +135,7 @@ func (b *Reader) Peek(n int) ([]byte, error) {
 // It returns the number of bytes read into p.
 // It calls Read at most once on the underlying Reader,
 // hence n may be less than len(p).
-// At EOF, the count will be zero and err will be os.EOF.
+// At EOF, the count will be zero and err will be io.EOF.
 func (b *Reader) Read(p []byte) (n int, err error) {
        n = len(p)
        if n == 0 {
@@ -246,7 +246,7 @@ func (b *Reader) Buffered() int { return b.w - b.r }
 // returning a slice pointing at the bytes in the buffer.
 // The bytes stop being valid at the next read call.
 // If ReadSlice encounters an error before finding a delimiter,
-// it returns all the data in the buffer and the error itself (often os.EOF).
+// it returns all the data in the buffer and the error itself (often io.EOF).
 // ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
 // Because the data returned from ReadSlice will be overwritten
 // by the next I/O operation, most clients should use
@@ -312,6 +312,9 @@ func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error) {
        }
 
        if len(line) == 0 {
+               if err != nil {
+                       line = nil
+               }
                return
        }
        err = nil
@@ -329,7 +332,7 @@ func (b *Reader) ReadLine() (line []byte, isPrefix bool, err error) {
 // ReadBytes reads until the first occurrence of delim in the input,
 // returning a slice containing the data up to and including the delimiter.
 // If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
 // ReadBytes returns err != nil if and only if the returned data does not end in
 // delim.
 func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
@@ -376,7 +379,7 @@ func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
 // ReadString reads until the first occurrence of delim in the input,
 // returning a string containing the data up to and including the delimiter.
 // If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
 // ReadString returns err != nil if and only if the returned data does not end in
 // delim.
 func (b *Reader) ReadString(delim byte) (line string, err error) {
index 0285dee..1f89395 100644 (file)
@@ -14,7 +14,7 @@ import (
        "strings"
        "testing"
        "testing/iotest"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Reads from a reader and rot13s the result.
@@ -698,6 +698,17 @@ func TestLinesAfterRead(t *testing.T) {
        }
 }
 
+func TestReadLineNonNilLineOrError(t *testing.T) {
+       r := NewReader(strings.NewReader("line 1\n"))
+       for i := 0; i < 2; i++ {
+               l, _, err := r.ReadLine()
+               if l != nil && err != nil {
+                       t.Fatalf("on line %d/2; ReadLine=%#v, %v; want non-nil line or Error, but not both",
+                               i+1, l, err)
+               }
+       }
+}
+
 type readLineResult struct {
        line     []byte
        isPrefix bool
index 07acce4..5a7aaf3 100644 (file)
@@ -3,13 +3,89 @@
 // license that can be found in the LICENSE file.
 
 /*
-       Package builtin provides documentation for Go's built-in functions.
-       The functions documented here are not actually in package builtin
+       Package builtin provides documentation for Go's predeclared identifiers.
+       The items documented here are not actually in package builtin
        but their descriptions here allow godoc to present documentation
-       for the language's special functions.
+       for the language's special identifiers.
 */
 package builtin
 
+// bool is the set of boolean values, true and false.
+type bool bool
+
+// uint8 is the set of all unsigned 8-bit integers.
+// Range: 0 through 255.
+type uint8 uint8
+
+// uint16 is the set of all unsigned 16-bit integers.
+// Range: 0 through 65535.
+type uint16 uint16
+
+// uint32 is the set of all unsigned 32-bit integers.
+// Range: 0 through 4294967295.
+type uint32 uint32
+
+// uint64 is the set of all unsigned 64-bit integers.
+// Range: 0 through 18446744073709551615.
+type uint64 uint64
+
+// int8 is the set of all signed 8-bit integers.
+// Range: -128 through 127.
+type int8 int8
+
+// int16 is the set of all signed 16-bit integers.
+// Range: -32768 through 32767.
+type int16 int16
+
+// int32 is the set of all signed 32-bit integers.
+// Range: -2147483648 through 2147483647.
+type int32 int32
+
+// int64 is the set of all signed 64-bit integers.
+// Range: -9223372036854775808 through 9223372036854775807.
+type int64 int64
+
+// float32 is the set of all IEEE-754 32-bit floating-point numbers.
+type float32 float32
+
+// float64 is the set of all IEEE-754 64-bit floating-point numbers.
+type float64 float64
+
+// complex64 is the set of all complex numbers with float32 real and
+// imaginary parts.
+type complex64 complex64
+
+// complex128 is the set of all complex numbers with float64 real and
+// imaginary parts.
+type complex128 complex128
+
+// string is the set of all strings of 8-bit bytes, conventionally but not
+// necessarily representing UTF-8-encoded text. A string may be empty, but
+// not nil. Values of string type are immutable.
+type string string
+
+// int is a signed integer type that is at least 32 bits in size. It is a
+// distinct type, however, and not an alias for, say, int32.
+type int int
+
+// uint is an unsigned integer type that is at least 32 bits in size. It is a
+// distinct type, however, and not an alias for, say, uint32.
+type uint uint
+
+// uintptr is an integer type that is large enough to hold the bit pattern of
+// any pointer.
+type uintptr uintptr
+
+// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
+// used, by convention, to distinguish byte values from 8-bit unsigned
+// integer values.
+type byte byte
+
+// rune is an alias for int and is equivalent to int in all ways. It is
+// used, by convention, to distinguish character values from integer values.
+// In a future version of Go, it will change to an alias of int32.
+type rune rune
+
 // Type is here for the purposes of documentation only. It is a stand-in
 // for any Go type, but represents the same type for any given function
 // invocation.
@@ -21,11 +97,11 @@ type IntegerType int
 
 // FloatType is here for the purposes of documentation only. It is a stand-in
 // for either float type: float32 or float64.
-type FloatType int
+type FloatType float32
 
 // ComplexType is here for the purposes of documentation only. It is a
 // stand-in for either complex type: complex64 or complex128.
-type ComplexType int
+type ComplexType complex64
 
 // The append built-in function appends elements to the end of a slice. If
 // it has sufficient capacity, the destination is resliced to accommodate the
@@ -133,3 +209,9 @@ func panic(v interface{})
 // nil. Thus the return value from recover reports whether the goroutine is
 // panicking.
 func recover() interface{}
+
+// The error built-in interface type is the conventional interface for
+// representing an error condition, with the nil value representing no error.
+type error interface {
+       Error() string
+}
index fbfd621..e66ac02 100644 (file)
@@ -9,7 +9,7 @@ package bytes
 import (
        "errors"
        "io"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A Buffer is a variable-sized buffer of bytes with Read and Write methods.
@@ -117,7 +117,7 @@ const MinRead = 512
 
 // ReadFrom reads data from r until EOF and appends it to the buffer.
 // The return value n is the number of bytes read.
-// Any error except os.EOF encountered during the read
+// Any error except io.EOF encountered during the read
 // is also returned.
 func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
        b.lastRead = opInvalid
@@ -200,7 +200,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) {
 
 // Read reads the next len(p) bytes from the buffer or until the buffer
 // is drained.  The return value n is the number of bytes read.  If the
-// buffer has no data to return, err is os.EOF even if len(p) is zero;
+// buffer has no data to return, err is io.EOF even if len(p) is zero;
 // otherwise it is nil.
 func (b *Buffer) Read(p []byte) (n int, err error) {
        b.lastRead = opInvalid
@@ -236,7 +236,7 @@ func (b *Buffer) Next(n int) []byte {
 }
 
 // ReadByte reads and returns the next byte from the buffer.
-// If no byte is available, it returns error os.EOF.
+// If no byte is available, it returns error io.EOF.
 func (b *Buffer) ReadByte() (c byte, err error) {
        b.lastRead = opInvalid
        if b.off >= len(b.buf) {
@@ -252,7 +252,7 @@ func (b *Buffer) ReadByte() (c byte, err error) {
 
 // ReadRune reads and returns the next UTF-8-encoded
 // Unicode code point from the buffer.
-// If no bytes are available, the error returned is os.EOF.
+// If no bytes are available, the error returned is io.EOF.
 // If the bytes are an erroneous UTF-8 encoding, it
 // consumes one byte and returns U+FFFD, 1.
 func (b *Buffer) ReadRune() (r rune, size int, err error) {
@@ -307,7 +307,7 @@ func (b *Buffer) UnreadByte() error {
 // ReadBytes reads until the first occurrence of delim in the input,
 // returning a slice containing the data up to and including the delimiter.
 // If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
 // ReadBytes returns err != nil if and only if the returned data does not end in
 // delim.
 func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
@@ -326,7 +326,7 @@ func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
 // ReadString reads until the first occurrence of delim in the input,
 // returning a string containing the data up to and including the delimiter.
 // If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
 // ReadString returns err != nil if and only if the returned data does not end
 // in delim.
 func (b *Buffer) ReadString(delim byte) (line string, err error) {
index c271b48..5235970 100644 (file)
@@ -7,9 +7,9 @@ package bytes_test
 import (
        . "bytes"
        "io"
-       "rand"
+       "math/rand"
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 const N = 10000  // make this bigger for a larger (and slower) test
index ac8320f..9bfd88f 100644 (file)
@@ -8,7 +8,7 @@ package bytes
 
 import (
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Compare returns an integer comparing the two byte arrays lexicographically.
@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
        return n
 }
 
+// Contains returns whether subslice is within b.
+func Contains(b, subslice []byte) bool {
+       return Index(b, subslice) != -1
+}
+
 // Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
 func Index(s, sep []byte) int {
        n := len(sep)
index 62f258d..9256b18 100644 (file)
@@ -9,7 +9,7 @@ import (
        "reflect"
        "testing"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 func eq(a, b []string) bool {
index d058c14..b2c13e5 100644 (file)
@@ -37,7 +37,7 @@ func newBitReader(r io.Reader) bitReader {
 
 // ReadBits64 reads the given number of bits and returns them in the
 // least-significant part of a uint64. In the event of an error, it returns 0
-// and the error can be obtained by calling Error().
+// and the error can be obtained by calling Err().
 func (br *bitReader) ReadBits64(bits uint) (n uint64) {
        for bits > br.bits {
                b, err := br.r.ReadByte()
@@ -82,6 +82,6 @@ func (br *bitReader) ReadBit() bool {
        return n != 0
 }
 
-func (br *bitReader) Error() error {
+func (br *bitReader) Err() error {
        return br.err
 }
index 343cca0..3dc8c62 100644 (file)
@@ -80,7 +80,7 @@ func (bz2 *reader) Read(buf []byte) (n int, err error) {
 
        if !bz2.setupDone {
                err = bz2.setup()
-               brErr := bz2.br.Error()
+               brErr := bz2.br.Err()
                if brErr != nil {
                        err = brErr
                }
@@ -91,7 +91,7 @@ func (bz2 *reader) Read(buf []byte) (n int, err error) {
        }
 
        n, err = bz2.read(buf)
-       brErr := bz2.br.Error()
+       brErr := bz2.br.Err()
        if brErr != nil {
                err = brErr
        }
diff --git a/libgo/go/compress/zlib/testdata/e.txt b/libgo/go/compress/zlib/testdata/e.txt
deleted file mode 100644 (file)
index 76cf2a7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531952510190115738341879307021540891499348841675092447614606680822648001684774118537423454424371075390777449920695517027618386062613313845830007520449338265602976067371132007093287091274437470472306969772093101416928368190255151086574637721112523897844250569536967707854499699679468644549059879316368892300987931277361782154249992295763514822082698951936680331825288693984964651058209392398294887933203625094431173012381970684161403970198376793206832823764648042953118023287825098194558153017567173613320698112509961818815930416903515988885193458072738667385894228792284998920868058257492796104841984443634632449684875602336248270419786232090021609902353043699418491463140934317381436405462531520961836908887070167683964243781405927145635490613031072085103837505101157477041718986106873969655212671546889570350354021234078498193343210681701210056278802351930332247450158539047304199577770935036604169973297250886876966403555707162268447162560798826517871341951246652010305921236677194325278675398558944896970964097545918569563802363701621120477427228364896134225164450781824423529486363721417402388934412479635743702637552944483379980161254922785092577825620926226483262779333865664816277251640191059004916449982893150566047258027786318641551956532442586982946959308019152987211725563475463964479101459040905862984967912874068705048958586717479854667757573205681288459205413340539220001137863009455606881667400169842055804033637953764520304024322566135278369511778838638744396625322498506549958862342818997077332761717839280349465014345588970719425863987727547109629537415211151368350627526023264847287039207643100595841166120545297030236472549296669381151373227536450988890313602057248176585118063036442812314965507047510254465011727211555194866850800368532281831521960037356252794495158284188294787610852639813955990067376482922443752871846245780361929819713991475644882626039033814418232625150974827987779964373089970388867782271383605772978824125611907176639465070633045279546618550966661856647097113444740160704626215680717481877844371436988218559670959102596862002353718588748569652200050311734392073211390803293634479727355955277349071783793421637012050054513263835440001863239914907054797780566978533580489669062951194324730995876552368128590413832411607226029983305353708761389396391779574540161372236187893652605381558415871869255386061647798340254351284396129460352913325942794904337299085731580290958631382683291477116396337092400316894586360606458459251269946557248391865642097526850823075442545993769170419777800853627309417101634349076964237222943523661255725088147792231519747780605696725380171807763603462459278778465850656050780844211529697521890874019660906651803516501792504619501366585436632712549639908549144200014574760819302212066024330096412704894390397177195180699086998606636583232278709376502260149291011517177635944602023249300280401867723910288097866605651183260043688508817157238669842242201024950551881694803221002515426494639812873677658927688163598312477886520141174110913601164995076629077943646005851941998560162647907615321038727557126992518275687989302761761146162549356495903798045838182323368612016243736569846703785853305275833337939907521660692380533698879565137285593883499894707416181550125397064648171946708348197214488898790676503795903669672494992545279033729636162658976039498576741397359441023744329709355477982629614591442936451428617158587339746791897571211956187385783644758448423555581050025611492391518893099463428413936080383091662818811503715284967059741625628236092168075150177725387402564253470879089137291722828611515915683725241630772254406337875931059826760944203261924285317018781772960235413060672136046000389661093647095141417185777014180606443636815464440053316087783143174440811949422975599314011888683314832802706553833004693290115744147563139997221703804617092894579096271662260740718749975359212756084414737823303270330168237193648002173285734935947564334129943024850235732214597843282641421684878721673367010615094243456984401873312810107945127223737886126058165668053714396127888732527373890392890506865324138062796025930387727697783792868409325365880733988457218746021005311483351323850047827169376218004904795597959290591655470505777514308175112698985188408718564026035305583737832422924185625644255022672155980274012617971928047139600689163828665277009752767069777036439260224372841840883251848770472638440379530166905465937461619323840363893131364327137688841026811219891275223056256756254701725086349765367288605966752740868627407912856576996313789753034660616669804218267724560530660773899624218340859882071864682623215080288286359746839654358856685503773131296587975810501214916207656769950659715344763470320853215603674828608378656803073062657633469774295634643716709397193060876963495328846833613038829431040800296873869117066666146800015121143442256023874474325250769387077775193299942137277211258843608715834835626961661980572526612206797540621062080649882918454395301529982092503005498257043390553570168653120526495614857249257386206917403695213533732531666345466588597286659451136441370331393672118569553952108458407244323835586063106806964924851232632699514603596037297253198368423363904632136710116192821711150282801604488058802382031981493096369596735832742024988245684941273860566491352526706046234450549227581151709314921879592718001940968866986837037302200475314338181092708030017205935530520700706072233999463990571311587099635777359027196285061146514837526209565346713290025994397663114545902685898979115837093419370441155121920117164880566945938131183843765620627846310490346293950029458341164824114969758326011800731699437393506966295712410273239138741754923071862454543222039552735295240245903805744502892246886285336542213815722131163288112052146489805180092024719391710555390113943316681515828843687606961102505171007392762385553386272553538830960671644662370922646809671254061869502143176211668140097595281493907222601112681153108387317617323235263605838173151034595736538223534992935822836851007810884634349983518404451704270189381994243410090575376257767571118090088164183319201962623416288166521374717325477727783488774366518828752156685719506371936565390389449366421764003121527870222366463635755503565576948886549500270853923617105502131147413744106134445544192101336172996285694899193369184729478580729156088510396781959429833186480756083679551496636448965592948187851784038773326247051945050419847742014183947731202815886845707290544057510601285258056594703046836344592652552137008068752009593453607316226118728173928074623094685367823106097921599360019946237993434210687813497346959246469752506246958616909178573976595199392993995567542714654910456860702099012606818704984178079173924071945996323060254707901774527513186809982284730860766536866855516467702911336827563107223346726113705490795365834538637196235856312618387156774118738527722922594743373785695538456246801013905727871016512966636764451872465653730402443684140814488732957847348490003019477888020460324660842875351848364959195082888323206522128104190448047247949291342284951970022601310430062410717971502793433263407995960531446053230488528972917659876016667811937932372453857209607582277178483361613582612896226118129455927462767137794487586753657544861407611931125958512655759734573015333642630767985443385761715333462325270572005303988289499034259566232975782488735029259166825894456894655992658454762694528780516501720674785417887982276806536650641910973434528878338621726156269582654478205672987756426325321594294418039943217000090542650763095588465895171709147607437136893319469090981904501290307099566226620303182649365733698419555776963787624918852865686607600566025605445711337286840205574416030837052312242587223438854123179481388550075689381124935386318635287083799845692619981794523364087429591180747453419551420351726184200845509170845682368200897739455842679214273477560879644279202708312150156406341341617166448069815483764491573900121217041547872591998943825364950514771379399147205219529079396137621107238494290616357604596231253506068537651423115349665683715116604220796394466621163255157729070978473156278277598788136491951257483328793771571459091064841642678309949723674420175862269402159407924480541255360431317992696739157542419296607312393763542139230617876753958711436104089409966089471418340698362993675362621545247298464213752891079884381306095552622720837518629837066787224430195793793786072107254277289071732854874374355781966511716618330881129120245204048682200072344035025448202834254187884653602591506445271657700044521097735585897622655484941621714989532383421600114062950718490427789258552743035221396835679018076406042138307308774460170842688272261177180842664333651780002171903449234264266292261456004337383868335555343453004264818473989215627086095650629340405264943244261445665921291225648893569655009154306426134252668472594914314239398845432486327461842846655985332312210466259890141712103446084271616619001257195870793217569698544013397622096749454185407118446433946990162698351607848924514058940946395267807354579700307051163682519487701189764002827648414160587206184185297189154019688253289309149665345753571427318482016384644832499037886069008072709327673127581966563941148961716832980455139729506687604740915420428429993541025829113502241690769431668574242522509026939034814856451303069925199590436384028429267412573422447765584177886171737265462085498294498946787350929581652632072258992368768457017823038096567883112289305809140572610865884845873101658151167533327674887014829167419701512559782572707406431808601428149024146780472327597684269633935773542930186739439716388611764209004068663398856841681003872389214483176070116684503887212364367043314091155733280182977988736590916659612402021778558854876176161989370794380056663364884365089144805571039765214696027662583599051987042300179465536788
diff --git a/libgo/go/compress/zlib/testdata/pi.txt b/libgo/go/compress/zlib/testdata/pi.txt
deleted file mode 100644 (file)
index 58d8f3b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632788659361533818279682303019520353018529689957736225994138912497217752834791315155748572424541506959508295331168617278558890750983817546374649393192550604009277016711390098488240128583616035637076601047101819429555961989467678374494482553797747268471040475346462080466842590694912933136770289891521047521620569660240580381501935112533824300355876402474964732639141992726042699227967823547816360093417216412199245863150302861829745557067498385054945885869269956909272107975093029553211653449872027559602364806654991198818347977535663698074265425278625518184175746728909777727938000816470600161452491921732172147723501414419735685481613611573525521334757418494684385233239073941433345477624168625189835694855620992192221842725502542568876717904946016534668049886272327917860857843838279679766814541009538837863609506800642251252051173929848960841284886269456042419652850222106611863067442786220391949450471237137869609563643719172874677646575739624138908658326459958133904780275900994657640789512694683983525957098258226205224894077267194782684826014769909026401363944374553050682034962524517493996514314298091906592509372216964615157098583874105978859597729754989301617539284681382686838689427741559918559252459539594310499725246808459872736446958486538367362226260991246080512438843904512441365497627807977156914359977001296160894416948685558484063534220722258284886481584560285060168427394522674676788952521385225499546667278239864565961163548862305774564980355936345681743241125150760694794510965960940252288797108931456691368672287489405601015033086179286809208747609178249385890097149096759852613655497818931297848216829989487226588048575640142704775551323796414515237462343645428584447952658678210511413547357395231134271661021359695362314429524849371871101457654035902799344037420073105785390621983874478084784896833214457138687519435064302184531910484810053706146806749192781911979399520614196634287544406437451237181921799983910159195618146751426912397489409071864942319615679452080951465502252316038819301420937621378559566389377870830390697920773467221825625996615014215030680384477345492026054146659252014974428507325186660021324340881907104863317346496514539057962685610055081066587969981635747363840525714591028970641401109712062804390397595156771577004203378699360072305587631763594218731251471205329281918261861258673215791984148488291644706095752706957220917567116722910981690915280173506712748583222871835209353965725121083579151369882091444210067510334671103141267111369908658516398315019701651511685171437657618351556508849099898599823873455283316355076479185358932261854896321329330898570642046752590709154814165498594616371802709819943099244889575712828905923233260972997120844335732654893823911932597463667305836041428138830320382490375898524374417029132765618093773444030707469211201913020330380197621101100449293215160842444859637669838952286847831235526582131449576857262433441893039686426243410773226978028073189154411010446823252716201052652272111660396665573092547110557853763466820653109896526918620564769312570586356620185581007293606598764861179104533488503461136576867532494416680396265797877185560845529654126654085306143444318586769751456614068007002378776591344017127494704205622305389945613140711270004078547332699390814546646458807972708266830634328587856983052358089330657574067954571637752542021149557615814002501262285941302164715509792592309907965473761255176567513575178296664547791745011299614890304639947132962107340437518957359614589019389713111790429782856475032031986915140287080859904801094121472213179476477726224142548545403321571853061422881375850430633217518297986622371721591607716692547487389866549494501146540628433663937900397692656721463853067360965712091807638327166416274888800786925602902284721040317211860820419000422966171196377921337575114959501566049631862947265473642523081770367515906735023507283540567040386743513622224771589150495309844489333096340878076932599397805419341447377441842631298608099888687413260472156951623965864573021631598193195167353812974167729478672422924654366800980676928238280689964004824354037014163149658979409243237896907069779422362508221688957383798623001593776471651228935786015881617557829735233446042815126272037343146531977774160319906655418763979293344195215413418994854447345673831624993419131814809277771038638773431772075456545322077709212019051660962804909263601975988281613323166636528619326686336062735676303544776280350450777235547105859548702790814356240145171806246436267945612753181340783303362542327839449753824372058353114771199260638133467768796959703098339130771098704085913374641442822772634659470474587847787201927715280731767907707157213444730605700733492436931138350493163128404251219256517980694113528013147013047816437885185290928545201165839341965621349143415956258658655705526904965209858033850722426482939728584783163057777560688876446248246857926039535277348030480290058760758251047470916439613626760449256274204208320856611906254543372131535958450687724602901618766795240616342522577195429162991930645537799140373404328752628889639958794757291746426357455254079091451357111369410911939325191076020825202618798531887705842972591677813149699009019211697173727847684726860849003377024242916513005005168323364350389517029893922334517220138128069650117844087451960121228599371623130171144484640903890644954440061986907548516026327505298349187407866808818338510228334508504860825039302133219715518430635455007668282949304137765527939751754613953984683393638304746119966538581538420568533862186725233402830871123282789212507712629463229563989898935821167456270102183564622013496715188190973038119800497340723961036854066431939509790190699639552453005450580685501956730229219139339185680344903982059551002263535361920419947455385938102343955449597783779023742161727111723643435439478221818528624085140066604433258885698670543154706965747458550332323342107301545940516553790686627333799585115625784322988273723198987571415957811196358330059408730681216028764962867446047746491599505497374256269010490377819868359381465741268049256487985561453723478673303904688383436346553794986419270563872931748723320837601123029911367938627089438799362016295154133714248928307220126901475466847653576164773794675200490757155527819653621323926406160136358155907422020203187277605277219005561484255518792530343513984425322341576233610642506390497500865627109535919465897514131034822769306247435363256916078154781811528436679570611086153315044521274739245449454236828860613408414863776700961207151249140430272538607648236341433462351897576645216413767969031495019108575984423919862916421939949072362346468441173940326591840443780513338945257423995082965912285085558215725031071257012668302402929525220118726767562204154205161841634847565169998116141010029960783869092916030288400269104140792886215078424516709087000699282120660418371806535567252532567532861291042487761825829765157959847035622262934860034158722980534989650226291748788202734209222245339856264766914905562842503912757710284027998066365825488926488025456610172967026640765590429099456815065265305371829412703369313785178609040708667114965583434347693385781711386455873678123014587687126603489139095620099393610310291616152881384379099042317473363948045759314931405297634757481193567091101377517210080315590248530906692037671922033229094334676851422144773793937517034436619910403375111735471918550464490263655128162288244625759163330391072253837421821408835086573917715096828874782656995995744906617583441375223970968340800535598491754173818839994469748676265516582765848358845314277568790029095170283529716344562129640435231176006651012412006597558512761785838292041974844236080071930457618932349229279650198751872127267507981255470958904556357921221033346697499235630254947802490114195212382815309114079073860251522742995818072471625916685451333123948049470791191532673430282441860414263639548000448002670496248201792896476697583183271314251702969234889627668440323260927524960357996469256504936818360900323809293459588970695365349406034021665443755890045632882250545255640564482465151875471196218443965825337543885690941130315095261793780029741207665147939425902989695946995565761218656196733786236256125216320862869222103274889218654364802296780705765615144632046927906821207388377814233562823608963208068222468012248261177185896381409183903673672220888321513755600372798394004152970028783076670944474560134556417254370906979396122571429894671543578468788614445812314593571984922528471605049221242470141214780573455105008019086996033027634787081081754501193071412233908663938339529425786905076431006383519834389341596131854347546495569781038293097164651438407007073604112373599843452251610507027056235266012764848308407611830130527932054274628654036036745328651057065874882256981579367897669742205750596834408697350201410206723585020072452256326513410559240190274216248439140359989535394590944070469120914093870012645600162374288021092764579310657922955249887275846101264836999892256959688159205600101655256375678
index 2dfe5b4..ca91139 100644 (file)
@@ -11,14 +11,17 @@ import "sort"
 
 // Any type that implements heap.Interface may be used as a
 // min-heap with the following invariants (established after
-// Init has been called):
+// Init has been called or if the data is empty or sorted):
 //
 //     !h.Less(j, i) for 0 <= i < h.Len() and j = 2*i+1 or 2*i+2 and j < h.Len()
 //
+// Note that Push and Pop in this interface are for package heap's
+// implementation to call.  To add and remove things from the heap,
+// use heap.Push and heap.Pop.
 type Interface interface {
        sort.Interface
-       Push(x interface{})
-       Pop() interface{}
+       Push(x interface{}) // add x as element Len()
+       Pop() interface{}   // remove and return element Len() - 1.
 }
 
 // A heap must be initialized before any of the heap operations
index 6625e3a..cb31ef6 100644 (file)
@@ -5,8 +5,8 @@
 package heap_test
 
 import (
-       "testing"
        . "container/heap"
+       "testing"
 )
 
 type myHeap []int
index 692d62a..a2adc7e 100644 (file)
@@ -6,9 +6,9 @@
 package dsa
 
 import (
-       "big"
        "errors"
        "io"
+       "math/big"
 )
 
 // Parameters represents the domain parameters for a key. These parameters can
index deec08d..177aa44 100644 (file)
@@ -5,8 +5,8 @@
 package dsa
 
 import (
-       "big"
        "crypto/rand"
+       "math/big"
        "testing"
 )
 
index b7f235b..2f19999 100644 (file)
@@ -13,9 +13,9 @@ package ecdsa
 //     http://www.secg.org/download/aid-780/sec1-v2.pdf
 
 import (
-       "big"
        "crypto/elliptic"
        "io"
+       "math/big"
 )
 
 // PublicKey represents an ECDSA public key.
index d6b4039..22360b5 100644 (file)
@@ -5,11 +5,11 @@
 package ecdsa
 
 import (
-       "big"
        "crypto/elliptic"
-       "crypto/sha1"
        "crypto/rand"
+       "crypto/sha1"
        "encoding/hex"
+       "math/big"
        "testing"
 )
 
index 3c3327f..b7232a2 100644 (file)
@@ -14,8 +14,8 @@ package elliptic
 // reverse the transform than to operate in affine coordinates.
 
 import (
-       "big"
        "io"
+       "math/big"
        "sync"
 )
 
index 9578364..a68a380 100644 (file)
@@ -5,9 +5,9 @@
 package elliptic
 
 import (
-       "big"
        "crypto/rand"
        "fmt"
+       "math/big"
        "testing"
 )
 
index bcae63b..03431c9 100644 (file)
@@ -5,8 +5,8 @@
 package hmac
 
 import (
-       "hash"
        "fmt"
+       "hash"
        "testing"
 )
 
index f697fa1..a04b5bd 100644 (file)
@@ -8,12 +8,12 @@
 package ocsp
 
 import (
-       "asn1"
        "crypto"
        "crypto/rsa"
        _ "crypto/sha1"
        "crypto/x509"
        "crypto/x509/pkix"
+       "encoding/asn1"
        "time"
 )
 
index 707bdf3..3bbb5dc 100644 (file)
@@ -151,7 +151,7 @@ func (r *openpgpReader) Read(p []byte) (n int, err error) {
 }
 
 // Decode reads a PGP armored block from the given Reader. It will ignore
-// leading garbage. If it doesn't find a block, it will return nil, os.EOF. The
+// leading garbage. If it doesn't find a block, it will return nil, io.EOF. The
 // given Reader is not usable after calling this function: an arbitrary amount
 // of data may have been read past the end of the block.
 func Decode(in io.Reader) (p *Block, err error) {
index 2ed49f6..a553bde 100644 (file)
 package elgamal
 
 import (
-       "big"
        "crypto/rand"
        "crypto/subtle"
        "errors"
        "io"
+       "math/big"
 )
 
 // PublicKey represents an ElGamal public key.
index 101121a..c4f99f5 100644 (file)
@@ -5,9 +5,9 @@
 package elgamal
 
 import (
-       "big"
        "bytes"
        "crypto/rand"
+       "math/big"
        "testing"
 )
 
index d05103f..b24fa3a 100644 (file)
@@ -5,13 +5,13 @@
 package packet
 
 import (
-       "big"
        "crypto/openpgp/elgamal"
        error_ "crypto/openpgp/error"
        "crypto/rand"
        "crypto/rsa"
        "encoding/binary"
        "io"
+       "math/big"
        "strconv"
 )
 
index b402245..2b8eff7 100644 (file)
@@ -5,11 +5,11 @@
 package packet
 
 import (
-       "big"
        "bytes"
        "crypto/rand"
        "crypto/rsa"
        "fmt"
+       "math/big"
        "testing"
 )
 
index f7ed353..778df15 100644 (file)
@@ -7,12 +7,12 @@
 package packet
 
 import (
-       "big"
        "crypto/aes"
        "crypto/cast5"
        "crypto/cipher"
        error_ "crypto/openpgp/error"
        "io"
+       "math/big"
 )
 
 // readFull is the same as io.ReadFull except that reading zero bytes returns
index 742ac51..c0ff82b 100644 (file)
@@ -5,7 +5,6 @@
 package packet
 
 import (
-       "big"
        "bytes"
        "crypto/cipher"
        "crypto/dsa"
@@ -16,6 +15,7 @@ import (
        "crypto/sha1"
        "io"
        "io/ioutil"
+       "math/big"
        "strconv"
 )
 
index af0bc22..7d71dc4 100644 (file)
@@ -5,7 +5,6 @@
 package packet
 
 import (
-       "big"
        "crypto/dsa"
        "crypto/openpgp/elgamal"
        error_ "crypto/openpgp/error"
@@ -15,6 +14,7 @@ import (
        "fmt"
        "hash"
        "io"
+       "math/big"
        "strconv"
 )
 
index ec4012c..3a094a1 100644 (file)
@@ -6,8 +6,8 @@ package s2k
 
 import (
        "bytes"
-       "crypto/sha1"
        "crypto/rand"
+       "crypto/sha1"
        "encoding/hex"
        "testing"
 )
index 322da4a..b44ae98 100644 (file)
@@ -5,8 +5,8 @@
 package rand
 
 import (
-       "big"
        "io"
+       "math/big"
        "os"
 )
 
index 901539d..d7b053f 100644 (file)
@@ -5,11 +5,11 @@
 package rsa
 
 import (
-       "big"
        "crypto"
        "crypto/subtle"
        "errors"
        "io"
+       "math/big"
 )
 
 // This file implements encryption and decryption using PKCS#1 v1.5 padding.
index d69bacf..66188ac 100644 (file)
@@ -5,7 +5,6 @@
 package rsa
 
 import (
-       "big"
        "bytes"
        "crypto"
        "crypto/rand"
@@ -13,6 +12,7 @@ import (
        "encoding/base64"
        "encoding/hex"
        "io"
+       "math/big"
        "testing"
        "testing/quick"
 )
index c9344ff..27ccf61 100644 (file)
@@ -8,12 +8,12 @@ package rsa
 // TODO(agl): Add support for PSS padding.
 
 import (
-       "big"
        "crypto/rand"
        "crypto/subtle"
        "errors"
        "hash"
        "io"
+       "math/big"
 )
 
 var bigZero = big.NewInt(0)
index c36bca1..0fb9875 100644 (file)
@@ -5,10 +5,10 @@
 package rsa
 
 import (
-       "big"
        "bytes"
        "crypto/rand"
        "crypto/sha1"
+       "math/big"
        "testing"
 )
 
index 6312c34..f4178e3 100644 (file)
@@ -471,7 +471,7 @@ Again:
                // RFC suggests that EOF without an alertCloseNotify is
                // an error, but popular web sites seem to do this,
                // so we can't make it an error.
-               // if err == os.EOF {
+               // if err == io.EOF {
                //      err = io.ErrUnexpectedEOF
                // }
                if e, ok := err.(net.Error); !ok || !e.Temporary() {
index 41206e2..c4463ff 100644 (file)
@@ -8,14 +8,14 @@
 package main
 
 import (
-       "big"
-       "crypto/x509/pkix"
        "crypto/rand"
        "crypto/rsa"
        "crypto/x509"
+       "crypto/x509/pkix"
        "encoding/pem"
        "flag"
        "log"
+       "math/big"
        "os"
        "time"
 )
index dc68a12..87e8f7e 100644 (file)
@@ -5,7 +5,7 @@
 package tls
 
 import (
-       "rand"
+       "math/rand"
        "reflect"
        "testing"
        "testing/quick"
index f2b0a14..bc37979 100644 (file)
@@ -5,12 +5,12 @@
 package tls
 
 import (
-       "big"
        "bytes"
        "crypto/rsa"
        "encoding/hex"
        "flag"
        "io"
+       "math/big"
        "net"
        "strconv"
        "strings"
index ba34606..08fb852 100644 (file)
@@ -5,7 +5,6 @@
 package tls
 
 import (
-       "big"
        "crypto"
        "crypto/elliptic"
        "crypto/md5"
@@ -14,6 +13,7 @@ import (
        "crypto/x509"
        "errors"
        "io"
+       "math/big"
 )
 
 // rsaKeyAgreement implements the standard TLS key agreement where the client
index 0d3ade3..31d0dd0 100644 (file)
@@ -5,10 +5,10 @@
 package x509
 
 import (
-       "asn1"
-       "big"
-       "errors"
        "crypto/rsa"
+       "encoding/asn1"
+       "errors"
+       "math/big"
 )
 
 // pkcs1PrivateKey is a structure which mirrors the PKCS#1 ASN.1 for an RSA private key.
index 332a394..b35274c 100644 (file)
@@ -7,8 +7,8 @@
 package pkix
 
 import (
-       "asn1"
-       "big"
+       "encoding/asn1"
+       "math/big"
        "time"
 )
 
index da8b283..9ff7db9 100644 (file)
@@ -6,17 +6,17 @@
 package x509
 
 import (
-       "asn1"
-       "big"
        "bytes"
        "crypto"
        "crypto/dsa"
        "crypto/rsa"
        "crypto/sha1"
        "crypto/x509/pkix"
+       "encoding/asn1"
        "encoding/pem"
        "errors"
        "io"
+       "math/big"
        "time"
 )
 
index d113f85..c424715 100644 (file)
@@ -5,16 +5,16 @@
 package x509
 
 import (
-       "asn1"
-       "big"
        "bytes"
        "crypto/dsa"
        "crypto/rand"
        "crypto/rsa"
        "crypto/x509/pkix"
+       "encoding/asn1"
        "encoding/base64"
        "encoding/hex"
        "encoding/pem"
+       "math/big"
        "testing"
        "time"
 )
index c83e64e..562e7a0 100644 (file)
@@ -7,8 +7,8 @@ package gosym
 import (
        "debug/elf"
        "os"
-       "testing"
        "syscall"
+       "testing"
 )
 
 func dotest() bool {
similarity index 99%
rename from libgo/go/asn1/asn1.go
rename to libgo/go/encoding/asn1/asn1.go
index 73e733e..a006665 100644 (file)
@@ -20,8 +20,8 @@ package asn1
 // everything by any means.
 
 import (
-       "big"
        "fmt"
+       "math/big"
        "reflect"
        "time"
 )
similarity index 99%
rename from libgo/go/asn1/marshal.go
rename to libgo/go/encoding/asn1/marshal.go
index 583d010..89c50a7 100644 (file)
@@ -5,10 +5,10 @@
 package asn1
 
 import (
-       "big"
        "bytes"
        "fmt"
        "io"
+       "math/big"
        "reflect"
        "time"
 )
index 65b9f01..d2f8b1e 100644 (file)
@@ -9,8 +9,8 @@ package binary
 
 import (
        "errors"
-       "math"
        "io"
+       "math"
        "reflect"
 )
 
index e753aa0..fd4fdb0 100644 (file)
@@ -7,7 +7,6 @@ package binary
 import (
        "bytes"
        "io"
-       "bytes"
        "math"
        "reflect"
        "testing"
similarity index 99%
rename from libgo/go/csv/writer.go
rename to libgo/go/encoding/csv/writer.go
index 5ea20e1..c4dcba5 100644 (file)
@@ -9,7 +9,7 @@ import (
        "io"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A Writer writes records to a CSV encoded file.
diff --git a/libgo/go/encoding/gob/debug.go b/libgo/go/encoding/gob/debug.go
new file mode 100644 (file)
index 0000000..b21c7fa
--- /dev/null
@@ -0,0 +1,687 @@
+package gob
+
+// This file is not normally included in the gob package.  Used only for debugging the package itself.
+// Add debug.go to the files listed in the Makefile to add Debug to the gob package.
+// Except for reading uints, it is an implementation of a reader that is independent of
+// the one implemented by Decoder.
+
+import (
+       "bytes"
+       "fmt"
+       "io"
+       "os"
+       "strings"
+       "sync"
+)
+
+var dumpBytes = false // If true, print the remaining bytes in the input buffer at each item.
+
+// Init installs the debugging facility. If this file is not compiled in the
+// package, the tests in codec_test.go are no-ops.
+func init() {
+       debugFunc = Debug
+}
+
+var (
+       blanks = bytes.Repeat([]byte{' '}, 3*10)
+       empty  = []byte(": <empty>\n")
+       tabs   = strings.Repeat("\t", 100)
+)
+
+// tab indents itself when printed.
+type tab int
+
+func (t tab) String() string {
+       n := int(t)
+       if n > len(tabs) {
+               n = len(tabs)
+       }
+       return tabs[0:n]
+}
+
+func (t tab) print() {
+       fmt.Fprint(os.Stderr, t)
+}
+
+// A peekReader wraps an io.Reader, allowing one to peek ahead to see
+// what's coming without stealing the data from the client of the Reader.
+type peekReader struct {
+       r    io.Reader
+       data []byte // read-ahead data
+}
+
+// newPeekReader returns a peekReader that wraps r.
+func newPeekReader(r io.Reader) *peekReader {
+       return &peekReader{r: r}
+}
+
+// Read is the usual method. It will first take data that has been read ahead.
+func (p *peekReader) Read(b []byte) (n int, err error) {
+       if len(p.data) == 0 {
+               return p.r.Read(b)
+       }
+       // Satisfy what's possible from the read-ahead data.
+       n = copy(b, p.data)
+       // Move data down to beginning of slice, to avoid endless growth
+       copy(p.data, p.data[n:])
+       p.data = p.data[:len(p.data)-n]
+       return
+}
+
+// peek returns as many bytes as possible from the unread
+// portion of the stream, up to the length of b.
+func (p *peekReader) peek(b []byte) (n int, err error) {
+       if len(p.data) > 0 {
+               n = copy(b, p.data)
+               if n == len(b) {
+                       return
+               }
+               b = b[n:]
+       }
+       if len(b) == 0 {
+               return
+       }
+       m, e := io.ReadFull(p.r, b)
+       if m > 0 {
+               p.data = append(p.data, b[:m]...)
+       }
+       n += m
+       if e == io.ErrUnexpectedEOF {
+               // That means m > 0 but we reached EOF. If we got data
+               // we won't complain about not being able to peek enough.
+               if n > 0 {
+                       e = nil
+               } else {
+                       e = io.EOF
+               }
+       }
+       return n, e
+}
+
+type debugger struct {
+       mutex          sync.Mutex
+       remain         int  // the number of bytes known to remain in the input
+       remainingKnown bool // the value of 'remain' is valid
+       r              *peekReader
+       wireType       map[typeId]*wireType
+       tmp            []byte // scratch space for decoding uints.
+}
+
+// dump prints the next nBytes of the input.
+// It arranges to print the output aligned from call to
+// call, to make it easy to see what has been consumed.
+func (deb *debugger) dump(format string, args ...interface{}) {
+       if !dumpBytes {
+               return
+       }
+       fmt.Fprintf(os.Stderr, format+" ", args...)
+       if !deb.remainingKnown {
+               return
+       }
+       if deb.remain < 0 {
+               fmt.Fprintf(os.Stderr, "remaining byte count is negative! %d\n", deb.remain)
+               return
+       }
+       data := make([]byte, deb.remain)
+       n, _ := deb.r.peek(data)
+       if n == 0 {
+               os.Stderr.Write(empty)
+               return
+       }
+       b := new(bytes.Buffer)
+       fmt.Fprintf(b, "[%d]{\n", deb.remain)
+       // Blanks until first byte
+       lineLength := 0
+       if n := len(data); n%10 != 0 {
+               lineLength = 10 - n%10
+               fmt.Fprintf(b, "\t%s", blanks[:lineLength*3])
+       }
+       // 10 bytes per line
+       for len(data) > 0 {
+               if lineLength == 0 {
+                       fmt.Fprint(b, "\t")
+               }
+               m := 10 - lineLength
+               lineLength = 0
+               if m > len(data) {
+                       m = len(data)
+               }
+               fmt.Fprintf(b, "% x\n", data[:m])
+               data = data[m:]
+       }
+       fmt.Fprint(b, "}\n")
+       os.Stderr.Write(b.Bytes())
+}
+
+// Debug prints a human-readable representation of the gob data read from r.
+// It is a no-op unless debugging was enabled when the package was built.
+func Debug(r io.Reader) {
+       err := debug(r)
+       if err != nil {
+               fmt.Fprintf(os.Stderr, "gob debug: %s\n", err)
+       }
+}
+
+// debug implements Debug, but catches panics and returns
+// them as errors to be printed by Debug.
+func debug(r io.Reader) (err error) {
+       defer catchError(&err)
+       fmt.Fprintln(os.Stderr, "Start of debugging")
+       deb := &debugger{
+               r:        newPeekReader(r),
+               wireType: make(map[typeId]*wireType),
+               tmp:      make([]byte, 16),
+       }
+       if b, ok := r.(*bytes.Buffer); ok {
+               deb.remain = b.Len()
+               deb.remainingKnown = true
+       }
+       deb.gobStream()
+       return
+}
+
+// note that we've consumed some bytes
+func (deb *debugger) consumed(n int) {
+       if deb.remainingKnown {
+               deb.remain -= n
+       }
+}
+
+// int64 decodes and returns the next integer, which must be present.
+// Don't call this if you could be at EOF.
+func (deb *debugger) int64() int64 {
+       return toInt(deb.uint64())
+}
+
+// uint64 returns and decodes the next unsigned integer, which must be present.
+// Don't call this if you could be at EOF.
+// TODO: handle errors better.
+func (deb *debugger) uint64() uint64 {
+       n, w, err := decodeUintReader(deb.r, deb.tmp)
+       if err != nil {
+               errorf("debug: read error: %s", err)
+       }
+       deb.consumed(w)
+       return n
+}
+
+// GobStream:
+//     DelimitedMessage* (until EOF)
+func (deb *debugger) gobStream() {
+       // Make sure we're single-threaded through here.
+       deb.mutex.Lock()
+       defer deb.mutex.Unlock()
+
+       for deb.delimitedMessage(0) {
+       }
+}
+
+// DelimitedMessage:
+//     uint(lengthOfMessage) Message
+func (deb *debugger) delimitedMessage(indent tab) bool {
+       for {
+               n := deb.loadBlock(true)
+               if n < 0 {
+                       return false
+               }
+               deb.dump("Delimited message of length %d", n)
+               deb.message(indent)
+       }
+       return true
+}
+
+// loadBlock preps us to read a message
+// of the length specified next in the input. It returns
+// the length of the block. The argument tells whether
+// an EOF is acceptable now.  If it is and one is found,
+// the return value is negative.
+func (deb *debugger) loadBlock(eofOK bool) int {
+       n64, w, err := decodeUintReader(deb.r, deb.tmp) // deb.uint64 will error at EOF
+       if err != nil {
+               if eofOK && err == io.EOF {
+                       return -1
+               }
+               errorf("debug: unexpected error: %s", err)
+       }
+       deb.consumed(w)
+       n := int(n64)
+       if n < 0 {
+               errorf("huge value for message length: %d", n64)
+       }
+       return int(n)
+}
+
+// Message:
+//     TypeSequence TypedValue
+// TypeSequence
+//     (TypeDefinition DelimitedTypeDefinition*)?
+// DelimitedTypeDefinition:
+//     uint(lengthOfTypeDefinition) TypeDefinition
+// TypedValue:
+//     int(typeId) Value
+func (deb *debugger) message(indent tab) bool {
+       for {
+               // Convert the uint64 to a signed integer typeId
+               uid := deb.int64()
+               id := typeId(uid)
+               deb.dump("type id=%d", id)
+               if id < 0 {
+                       deb.typeDefinition(indent, -id)
+                       n := deb.loadBlock(false)
+                       deb.dump("Message of length %d", n)
+                       continue
+               } else {
+                       deb.value(indent, id)
+                       break
+               }
+       }
+       return true
+}
+
+// Helper methods to make it easy to scan a type descriptor.
+
+// common returns the CommonType at the input point.
+func (deb *debugger) common() CommonType {
+       fieldNum := -1
+       name := ""
+       id := typeId(0)
+       for {
+               delta := deb.delta(-1)
+               if delta == 0 {
+                       break
+               }
+               fieldNum += delta
+               switch fieldNum {
+               case 0:
+                       name = deb.string()
+               case 1:
+                       // Id typeId
+                       id = deb.typeId()
+               default:
+                       errorf("corrupted CommonType")
+               }
+       }
+       return CommonType{name, id}
+}
+
+// uint returns the unsigned int at the input point, as a uint (not uint64).
+func (deb *debugger) uint() uint {
+       return uint(deb.uint64())
+}
+
+// int returns the signed int at the input point, as an int (not int64).
+func (deb *debugger) int() int {
+       return int(deb.int64())
+}
+
+// typeId returns the type id at the input point.
+func (deb *debugger) typeId() typeId {
+       return typeId(deb.int64())
+}
+
+// string returns the string at the input point.
+func (deb *debugger) string() string {
+       x := int(deb.uint64())
+       b := make([]byte, x)
+       nb, _ := deb.r.Read(b)
+       if nb != x {
+               errorf("corrupted type")
+       }
+       deb.consumed(nb)
+       return string(b)
+}
+
+// delta returns the field delta at the input point.  The expect argument,
+// if non-negative, identifies what the value should be.
+func (deb *debugger) delta(expect int) int {
+       delta := int(deb.uint64())
+       if delta < 0 || (expect >= 0 && delta != expect) {
+               errorf("decode: corrupted type: delta %d expected %d", delta, expect)
+       }
+       return delta
+}
+
+// TypeDefinition:
+//     [int(-typeId) (already read)] encodingOfWireType
+func (deb *debugger) typeDefinition(indent tab, id typeId) {
+       deb.dump("type definition for id %d", id)
+       // Encoding is of a wireType. Decode the structure as usual
+       fieldNum := -1
+       wire := new(wireType)
+       // A wireType defines a single field.
+       delta := deb.delta(-1)
+       fieldNum += delta
+       switch fieldNum {
+       case 0: // array type, one field of {{Common}, elem, length}
+               // Field number 0 is CommonType
+               deb.delta(1)
+               com := deb.common()
+               // Field number 1 is type Id of elem
+               deb.delta(1)
+               id := deb.typeId()
+               // Field number 3 is length
+               deb.delta(1)
+               length := deb.int()
+               wire.ArrayT = &arrayType{com, id, length}
+
+       case 1: // slice type, one field of {{Common}, elem}
+               // Field number 0 is CommonType
+               deb.delta(1)
+               com := deb.common()
+               // Field number 1 is type Id of elem
+               deb.delta(1)
+               id := deb.typeId()
+               wire.SliceT = &sliceType{com, id}
+
+       case 2: // struct type, one field of {{Common}, []fieldType}
+               // Field number 0 is CommonType
+               deb.delta(1)
+               com := deb.common()
+               // Field number 1 is slice of FieldType
+               deb.delta(1)
+               numField := int(deb.uint())
+               field := make([]*fieldType, numField)
+               for i := 0; i < numField; i++ {
+                       field[i] = new(fieldType)
+                       deb.delta(1) // field 0 of fieldType: name
+                       field[i].Name = deb.string()
+                       deb.delta(1) // field 1 of fieldType: id
+                       field[i].Id = deb.typeId()
+                       deb.delta(0) // end of fieldType
+               }
+               wire.StructT = &structType{com, field}
+
+       case 3: // map type, one field of {{Common}, key, elem}
+               // Field number 0 is CommonType
+               deb.delta(1)
+               com := deb.common()
+               // Field number 1 is type Id of key
+               deb.delta(1)
+               keyId := deb.typeId()
+               // Field number 2 is type Id of elem
+               deb.delta(1)
+               elemId := deb.typeId()
+               wire.MapT = &mapType{com, keyId, elemId}
+       case 4: // GobEncoder type, one field of {{Common}}
+               // Field number 0 is CommonType
+               deb.delta(1)
+               com := deb.common()
+               wire.GobEncoderT = &gobEncoderType{com}
+       default:
+               errorf("bad field in type %d", fieldNum)
+       }
+       deb.printWireType(indent, wire)
+       deb.delta(0) // end inner type (arrayType, etc.)
+       deb.delta(0) // end wireType
+       // Remember we've seen this type.
+       deb.wireType[id] = wire
+}
+
+// Value:
+//     SingletonValue | StructValue
+func (deb *debugger) value(indent tab, id typeId) {
+       wire, ok := deb.wireType[id]
+       if ok && wire.StructT != nil {
+               deb.structValue(indent, id)
+       } else {
+               deb.singletonValue(indent, id)
+       }
+}
+
+// SingletonValue:
+//     uint(0) FieldValue
+func (deb *debugger) singletonValue(indent tab, id typeId) {
+       deb.dump("Singleton value")
+       // is it a builtin type?
+       wire := deb.wireType[id]
+       _, ok := builtinIdToType[id]
+       if !ok && wire == nil {
+               errorf("type id %d not defined", id)
+       }
+       m := deb.uint64()
+       if m != 0 {
+               errorf("expected zero; got %d", m)
+       }
+       deb.fieldValue(indent, id)
+}
+
+// InterfaceValue:
+//     NilInterfaceValue | NonNilInterfaceValue
+func (deb *debugger) interfaceValue(indent tab) {
+       deb.dump("Start of interface value")
+       if nameLen := deb.uint64(); nameLen == 0 {
+               deb.nilInterfaceValue(indent)
+       } else {
+               deb.nonNilInterfaceValue(indent, int(nameLen))
+       }
+}
+
+// NilInterfaceValue:
+//     uint(0) [already read]
+func (deb *debugger) nilInterfaceValue(indent tab) int {
+       fmt.Fprintf(os.Stderr, "%snil interface\n", indent)
+       return 0
+}
+
+// NonNilInterfaceValue:
+//     ConcreteTypeName TypeSequence InterfaceContents
+// ConcreteTypeName:
+//     uint(lengthOfName) [already read=n] name
+// InterfaceContents:
+//     int(concreteTypeId) DelimitedValue
+// DelimitedValue:
+//     uint(length) Value
+func (deb *debugger) nonNilInterfaceValue(indent tab, nameLen int) {
+       // ConcreteTypeName
+       b := make([]byte, nameLen)
+       deb.r.Read(b) // TODO: CHECK THESE READS!!
+       deb.consumed(nameLen)
+       name := string(b)
+
+       for {
+               id := deb.typeId()
+               if id < 0 {
+                       deb.typeDefinition(indent, -id)
+                       n := deb.loadBlock(false)
+                       deb.dump("Nested message of length %d", n)
+               } else {
+                       // DelimitedValue
+                       x := deb.uint64() // in case we want to ignore the value; we don't.
+                       fmt.Fprintf(os.Stderr, "%sinterface value, type %q id=%d; valueLength %d\n", indent, name, id, x)
+                       deb.value(indent, id)
+                       break
+               }
+       }
+}
+
+// printCommonType prints a common type; used by printWireType.
+func (deb *debugger) printCommonType(indent tab, kind string, common *CommonType) {
+       indent.print()
+       fmt.Fprintf(os.Stderr, "%s %q id=%d\n", kind, common.Name, common.Id)
+}
+
+// printWireType prints the contents of a wireType.
+func (deb *debugger) printWireType(indent tab, wire *wireType) {
+       fmt.Fprintf(os.Stderr, "%stype definition {\n", indent)
+       indent++
+       switch {
+       case wire.ArrayT != nil:
+               deb.printCommonType(indent, "array", &wire.ArrayT.CommonType)
+               fmt.Fprintf(os.Stderr, "%slen %d\n", indent+1, wire.ArrayT.Len)
+               fmt.Fprintf(os.Stderr, "%selemid %d\n", indent+1, wire.ArrayT.Elem)
+       case wire.MapT != nil:
+               deb.printCommonType(indent, "map", &wire.MapT.CommonType)
+               fmt.Fprintf(os.Stderr, "%skey id=%d\n", indent+1, wire.MapT.Key)
+               fmt.Fprintf(os.Stderr, "%selem id=%d\n", indent+1, wire.MapT.Elem)
+       case wire.SliceT != nil:
+               deb.printCommonType(indent, "slice", &wire.SliceT.CommonType)
+               fmt.Fprintf(os.Stderr, "%selem id=%d\n", indent+1, wire.SliceT.Elem)
+       case wire.StructT != nil:
+               deb.printCommonType(indent, "struct", &wire.StructT.CommonType)
+               for i, field := range wire.StructT.Field {
+                       fmt.Fprintf(os.Stderr, "%sfield %d:\t%s\tid=%d\n", indent+1, i, field.Name, field.Id)
+               }
+       case wire.GobEncoderT != nil:
+               deb.printCommonType(indent, "GobEncoder", &wire.GobEncoderT.CommonType)
+       }
+       indent--
+       fmt.Fprintf(os.Stderr, "%s}\n", indent)
+}
+
+// fieldValue prints a value of any type, such as a struct field.
+// FieldValue:
+//     builtinValue | ArrayValue | MapValue | SliceValue | StructValue | InterfaceValue
+func (deb *debugger) fieldValue(indent tab, id typeId) {
+       _, ok := builtinIdToType[id]
+       if ok {
+               if id == tInterface {
+                       deb.interfaceValue(indent)
+               } else {
+                       deb.printBuiltin(indent, id)
+               }
+               return
+       }
+       wire, ok := deb.wireType[id]
+       if !ok {
+               errorf("type id %d not defined", id)
+       }
+       switch {
+       case wire.ArrayT != nil:
+               deb.arrayValue(indent, wire)
+       case wire.MapT != nil:
+               deb.mapValue(indent, wire)
+       case wire.SliceT != nil:
+               deb.sliceValue(indent, wire)
+       case wire.StructT != nil:
+               deb.structValue(indent, id)
+       case wire.GobEncoderT != nil:
+               deb.gobEncoderValue(indent, id)
+       default:
+               panic("bad wire type for field")
+       }
+}
+
+// printBuiltin prints a value not of a fundamental type, that is,
+// one whose type is known to gobs at bootstrap time.
+func (deb *debugger) printBuiltin(indent tab, id typeId) {
+       switch id {
+       case tBool:
+               x := deb.int64()
+               if x == 0 {
+                       fmt.Fprintf(os.Stderr, "%sfalse\n", indent)
+               } else {
+                       fmt.Fprintf(os.Stderr, "%strue\n", indent)
+               }
+       case tInt:
+               x := deb.int64()
+               fmt.Fprintf(os.Stderr, "%s%d\n", indent, x)
+       case tUint:
+               x := deb.int64()
+               fmt.Fprintf(os.Stderr, "%s%d\n", indent, x)
+       case tFloat:
+               x := deb.uint64()
+               fmt.Fprintf(os.Stderr, "%s%g\n", indent, floatFromBits(x))
+       case tComplex:
+               r := deb.uint64()
+               i := deb.uint64()
+               fmt.Fprintf(os.Stderr, "%s%g+%gi\n", indent, floatFromBits(r), floatFromBits(i))
+       case tBytes:
+               x := int(deb.uint64())
+               b := make([]byte, x)
+               deb.r.Read(b)
+               deb.consumed(x)
+               fmt.Fprintf(os.Stderr, "%s{% x}=%q\n", indent, b, b)
+       case tString:
+               x := int(deb.uint64())
+               b := make([]byte, x)
+               deb.r.Read(b)
+               deb.consumed(x)
+               fmt.Fprintf(os.Stderr, "%s%q\n", indent, b)
+       default:
+               panic("unknown builtin")
+       }
+}
+
+// ArrayValue:
+//     uint(n) FieldValue*n
+func (deb *debugger) arrayValue(indent tab, wire *wireType) {
+       elemId := wire.ArrayT.Elem
+       u := deb.uint64()
+       length := int(u)
+       for i := 0; i < length; i++ {
+               deb.fieldValue(indent, elemId)
+       }
+       if length != wire.ArrayT.Len {
+               fmt.Fprintf(os.Stderr, "%s(wrong length for array: %d should be %d)\n", indent, length, wire.ArrayT.Len)
+       }
+}
+
+// MapValue:
+//     uint(n) (FieldValue FieldValue)*n  [n (key, value) pairs]
+func (deb *debugger) mapValue(indent tab, wire *wireType) {
+       keyId := wire.MapT.Key
+       elemId := wire.MapT.Elem
+       u := deb.uint64()
+       length := int(u)
+       for i := 0; i < length; i++ {
+               deb.fieldValue(indent+1, keyId)
+               deb.fieldValue(indent+1, elemId)
+       }
+}
+
+// SliceValue:
+//     uint(n) (n FieldValue)
+func (deb *debugger) sliceValue(indent tab, wire *wireType) {
+       elemId := wire.SliceT.Elem
+       u := deb.uint64()
+       length := int(u)
+       deb.dump("Start of slice of length %d", length)
+
+       for i := 0; i < length; i++ {
+               deb.fieldValue(indent, elemId)
+       }
+}
+
+// StructValue:
+//     (uint(fieldDelta) FieldValue)*
+func (deb *debugger) structValue(indent tab, id typeId) {
+       deb.dump("Start of struct value of %q id=%d\n<<\n", id.name(), id)
+       fmt.Fprintf(os.Stderr, "%s%s struct {\n", indent, id.name())
+       wire, ok := deb.wireType[id]
+       if !ok {
+               errorf("type id %d not defined", id)
+       }
+       strct := wire.StructT
+       fieldNum := -1
+       indent++
+       for {
+               delta := deb.uint64()
+               if delta == 0 { // struct terminator is zero delta fieldnum
+                       break
+               }
+               fieldNum += int(delta)
+               if fieldNum < 0 || fieldNum >= len(strct.Field) {
+                       deb.dump("field number out of range: prevField=%d delta=%d", fieldNum-int(delta), delta)
+                       break
+               }
+               fmt.Fprintf(os.Stderr, "%sfield %d:\t%s\n", indent, fieldNum, wire.StructT.Field[fieldNum].Name)
+               deb.fieldValue(indent+1, strct.Field[fieldNum].Id)
+       }
+       indent--
+       fmt.Fprintf(os.Stderr, "%s} // end %s struct\n", indent, id.name())
+       deb.dump(">> End of struct value of type %d %q", id, id.name())
+}
+
+// GobEncoderValue:
+//     uint(n) byte*n
+func (deb *debugger) gobEncoderValue(indent tab, id typeId) {
+       len := deb.uint64()
+       deb.dump("GobEncoder value of %q id=%d, length %d\n", id.name(), id, len)
+       fmt.Fprintf(os.Stderr, "%s%s (implements GobEncoder)\n", indent, id.name())
+       data := make([]byte, len)
+       _, err := deb.r.Read(data)
+       if err != nil {
+               errorf("gobEncoder data read: %s", err)
+       }
+       fmt.Fprintf(os.Stderr, "%s[% .2x]\n", indent+1, data)
+}
diff --git a/libgo/go/encoding/gob/dump.go b/libgo/go/encoding/gob/dump.go
new file mode 100644 (file)
index 0000000..0d0017c
--- /dev/null
@@ -0,0 +1,22 @@
+package main
+
+// Need to compile package gob with debug.go to build this program.
+
+import (
+       "encoding/gob"
+       "fmt"
+       "os"
+)
+
+func main() {
+       var err error
+       file := os.Stdin
+       if len(os.Args) > 1 {
+               file, err = os.Open(os.Args[1])
+               if err != nil {
+                       fmt.Fprintf(os.Stderr, "dump: %s\n", err)
+                       os.Exit(1)
+               }
+       }
+       gob.Debug(file)
+}
similarity index 97%
rename from libgo/go/gob/type.go
rename to libgo/go/encoding/gob/type.go
index c3bc7c7..1b20843 100644 (file)
@@ -11,7 +11,7 @@ import (
        "reflect"
        "sync"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // userTypeInfo stores the information associated with a type the user has handed
@@ -703,18 +703,19 @@ func RegisterName(name string, value interface{}) {
                // reserved for nil
                panic("attempt to register empty name")
        }
-       base := userType(reflect.TypeOf(value)).base
-       // Check for incompatible duplicates.
-       if t, ok := nameToConcreteType[name]; ok && t != base {
-               panic("gob: registering duplicate types for " + name)
+       ut := userType(reflect.TypeOf(value))
+       // Check for incompatible duplicates. The name must refer to the
+       // same user type, and vice versa.
+       if t, ok := nameToConcreteType[name]; ok && t != ut.user {
+               panic(fmt.Sprintf("gob: registering duplicate types for %q: %s != %s", name, t, ut.user))
        }
-       if n, ok := concreteTypeToName[base]; ok && n != name {
-               panic("gob: registering duplicate names for " + base.String())
+       if n, ok := concreteTypeToName[ut.base]; ok && n != name {
+               panic(fmt.Sprintf("gob: registering duplicate names for %s: %q != %q", ut.user, n, name))
        }
        // Store the name and type provided by the user....
        nameToConcreteType[name] = reflect.TypeOf(value)
        // but the flattened type in the type table, since that's what decode needs.
-       concreteTypeToName[base] = name
+       concreteTypeToName[ut.base] = name
 }
 
 // Register records a type, identified by a value for that type, under its
similarity index 95%
rename from libgo/go/gob/type_test.go
rename to libgo/go/encoding/gob/type_test.go
index a6ac9c4..42bdb4c 100644 (file)
@@ -151,3 +151,11 @@ func TestStructType(t *testing.T) {
                t.Errorf("struct printed as %q; expected %q", str, expected)
        }
 }
+
+// Should be OK to register the same type multiple times, as long as they're
+// at the same level of indirection.
+func TestRegistration(t *testing.T) {
+       type T struct{ a int }
+       Register(new(T))
+       Register(new(T))
+}
similarity index 99%
rename from libgo/go/json/decode.go
rename to libgo/go/encoding/json/decode.go
index 8abd7b4..41295d2 100644 (file)
@@ -15,8 +15,8 @@ import (
        "strconv"
        "strings"
        "unicode"
-       "utf16"
-       "utf8"
+       "unicode/utf16"
+       "unicode/utf8"
 )
 
 // Unmarshal parses the JSON-encoded data and stores the result
similarity index 99%
rename from libgo/go/json/encode.go
rename to libgo/go/encoding/json/encode.go
index aac8f91..35964c5 100644 (file)
@@ -17,7 +17,7 @@ import (
        "sort"
        "strconv"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Marshal returns the JSON encoding of v.
similarity index 99%
rename from libgo/go/json/scanner_test.go
rename to libgo/go/encoding/json/scanner_test.go
index 0b86cb5..a0a5995 100644 (file)
@@ -7,7 +7,7 @@ package json
 import (
        "bytes"
        "math"
-       "rand"
+       "math/rand"
        "reflect"
        "testing"
 )
@@ -147,7 +147,7 @@ var indentErrorTests = []indentErrorTest{
        {`{"X": "foo" "Y": "bar"}`, &SyntaxError{"invalid character '\"' after object key:value pair", 13}},
 }
 
-func TestIdentErrors(t *testing.T) {
+func TestIndentErrors(t *testing.T) {
        for i, tt := range indentErrorTests {
                slice := make([]uint8, 0)
                buf := bytes.NewBuffer(slice)
similarity index 100%
rename from libgo/go/xml/marshal_test.go
rename to libgo/go/encoding/xml/marshal_test.go
index 59007b3..a6f7d2d 100644 (file)
@@ -5,11 +5,11 @@
 package xml
 
 import (
-       "reflect"
-       "testing"
        "bytes"
-       "strings"
+       "reflect"
        "strconv"
+       "strings"
+       "testing"
 )
 
 type DriveType int
similarity index 99%
rename from libgo/go/xml/read.go
rename to libgo/go/encoding/xml/read.go
index a88941c..c6a3d75 100644 (file)
@@ -13,7 +13,7 @@ import (
        "strconv"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // BUG(rsc): Mapping between XML elements and data structures is inherently flawed:
@@ -201,8 +201,8 @@ func (p *Parser) Unmarshal(val interface{}, start *StartElement) error {
 func fieldName(original string) string {
 
        var i int
-       //remove leading underscores
-       for i = 0; i < len(original) && original[i] == '_'; i++ {
+       //remove leading underscores, without exhausting all characters
+       for i = 0; i < len(original)-1 && original[i] == '_'; i++ {
        }
 
        return strings.Map(
@@ -617,7 +617,7 @@ func (p *Parser) Skip() error {
                if err != nil {
                        return err
                }
-               switch t := tok.(type) {
+               switch tok.(type) {
                case StartElement:
                        if err := p.Skip(); err != nil {
                                return err
similarity index 98%
rename from libgo/go/xml/read_test.go
rename to libgo/go/encoding/xml/read_test.go
index d39c2d5..fbb7fd5 100644 (file)
@@ -245,6 +245,9 @@ const pathTestString = `
             <Value>C</Value>
             <Value>D</Value>
         </Item1>
+        <_>
+            <value>E</value>
+        </_>
     </items>
     <after>2</after>
 </result>
@@ -279,11 +282,17 @@ type PathTestD struct {
        Before, After string
 }
 
+type PathTestE struct {
+       Underline     string `xml:"items>_>value"`
+       Before, After string
+}
+
 var pathTests = []interface{}{
        &PathTestA{Items: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"},
        &PathTestB{Other: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"},
        &PathTestC{Values1: []string{"A", "C", "D"}, Values2: []string{"B"}, Before: "1", After: "2"},
        &PathTestD{Other: PathTestSet{Item1: []PathTestItem{{"A"}, {"D"}}}, Before: "1", After: "2"},
+       &PathTestE{Underline: "E", Before: "1", After: "2"},
 }
 
 func TestUnmarshalPaths(t *testing.T) {
similarity index 99%
rename from libgo/go/xml/xml.go
rename to libgo/go/encoding/xml/xml.go
index d534c52..216d888 100644 (file)
@@ -21,7 +21,7 @@ import (
        "strconv"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A SyntaxError represents a syntax error in the XML input stream.
@@ -197,7 +197,7 @@ func NewParser(r io.Reader) *Parser {
 }
 
 // Token returns the next XML token in the input stream.
-// At the end of the input stream, Token returns nil, os.EOF.
+// At the end of the input stream, Token returns nil, io.EOF.
 //
 // Slices of bytes in the returned token data refer to the
 // parser's internal buffer and remain valid only until the next
similarity index 98%
rename from libgo/go/xml/xml_test.go
rename to libgo/go/encoding/xml/xml_test.go
index 1b40d0c..6c874fa 100644 (file)
@@ -520,7 +520,7 @@ func TestTrailingRawToken(t *testing.T) {
        for _, err = p.RawToken(); err == nil; _, err = p.RawToken() {
        }
        if err != io.EOF {
-               t.Fatalf("p.RawToken() = _, %v, want _, os.EOF", err)
+               t.Fatalf("p.RawToken() = _, %v, want _, io.EOF", err)
        }
 }
 
@@ -531,7 +531,7 @@ func TestTrailingToken(t *testing.T) {
        for _, err = p.Token(); err == nil; _, err = p.Token() {
        }
        if err != io.EOF {
-               t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
+               t.Fatalf("p.Token() = _, %v, want _, io.EOF", err)
        }
 }
 
@@ -542,7 +542,7 @@ func TestEntityInsideCDATA(t *testing.T) {
        for _, err = p.Token(); err == nil; _, err = p.Token() {
        }
        if err != io.EOF {
-               t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
+               t.Fatalf("p.Token() = _, %v, want _, io.EOF", err)
        }
 }
 
index 15c199a..cd8c83c 100644 (file)
@@ -25,9 +25,9 @@ package ebnf
 import (
        "errors"
        "fmt"
-       "scanner"
+       "text/scanner"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // ----------------------------------------------------------------------------
index 2dad9b4..7a7e3cc 100644 (file)
@@ -6,8 +6,8 @@ package ebnf
 
 import (
        "io"
-       "scanner"
        "strconv"
+       "text/scanner"
 )
 
 type parser struct {
index 7965ffc..7cad8a2 100644 (file)
@@ -4,7 +4,7 @@
 
 package norm
 
-import "utf8"
+import "unicode/utf8"
 
 const (
        maxCombiningChars = 30
index 12360a8..ce159e9 100644 (file)
@@ -4,7 +4,7 @@
 
 package norm
 
-import "utf8"
+import "unicode/utf8"
 
 type input interface {
        skipASCII(p int) int
index c7a3762..39bab7f 100644 (file)
@@ -12,9 +12,9 @@ import (
        "bytes"
        "flag"
        "fmt"
-       "http"
        "io"
        "log"
+       "net/http"
        "os"
        "regexp"
        "strconv"
index 391bc41..25bb28d 100644 (file)
@@ -5,7 +5,7 @@
 // Package norm contains types and functions for normalizing Unicode strings.
 package norm
 
-import "utf8"
+import "unicode/utf8"
 
 // A Form denotes a canonical representation of Unicode code points.
 // The Unicode-defined normalization and equivalence forms are:
index 744bb1c..6610c25 100644 (file)
@@ -10,9 +10,9 @@ import (
        "exp/norm"
        "flag"
        "fmt"
-       "http"
        "io"
        "log"
+       "net/http"
        "os"
        "path"
        "regexp"
@@ -20,7 +20,7 @@ import (
        "strconv"
        "strings"
        "time"
-       "utf8"
+       "unicode/utf8"
 )
 
 func main() {
index bbd5c03..7308d28 100644 (file)
@@ -2,7 +2,7 @@ package norm
 
 import (
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Test data is located in triedata_test.go; generated by maketesttables.
index 56cba32..5edadac 100644 (file)
@@ -14,7 +14,7 @@ import (
        "fmt"
        "hash/crc32"
        "log"
-       "utf8"
+       "unicode/utf8"
 )
 
 const blockSize = 64
index 3de80c0..4830a1d 100644 (file)
@@ -7,8 +7,8 @@ package spdy
 import (
        "compress/zlib"
        "encoding/binary"
-       "http"
        "io"
+       "net/http"
        "strings"
 )
 
index cb91e02..c1cad4b 100644 (file)
@@ -6,8 +6,8 @@ package spdy
 
 import (
        "bytes"
-       "http"
        "io"
+       "net/http"
        "reflect"
        "testing"
 )
index 87d6edb..2648c4f 100644 (file)
@@ -7,8 +7,8 @@ package spdy
 import (
        "bytes"
        "compress/zlib"
-       "http"
        "io"
+       "net/http"
 )
 
 //  Data Frame Format
index 537154f..3dd2ca1 100644 (file)
@@ -6,8 +6,8 @@ package spdy
 
 import (
        "encoding/binary"
-       "http"
        "io"
+       "net/http"
        "strings"
 )
 
index b1feef0..e46cebe 100644 (file)
@@ -8,6 +8,7 @@ package sql
 
 import (
        "errors"
+       "exp/sql/driver"
        "fmt"
        "reflect"
        "strconv"
@@ -36,10 +37,11 @@ func convertAssign(dest, src interface{}) error {
                }
        }
 
-       sv := reflect.ValueOf(src)
+       var sv reflect.Value
 
        switch d := dest.(type) {
        case *string:
+               sv = reflect.ValueOf(src)
                switch sv.Kind() {
                case reflect.Bool,
                        reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
@@ -48,6 +50,12 @@ func convertAssign(dest, src interface{}) error {
                        *d = fmt.Sprintf("%v", src)
                        return nil
                }
+       case *bool:
+               bv, err := driver.Bool.ConvertValue(src)
+               if err == nil {
+                       *d = bv.(bool)
+               }
+               return err
        }
 
        if scanner, ok := dest.(ScannerInto); ok {
@@ -59,6 +67,10 @@ func convertAssign(dest, src interface{}) error {
                return errors.New("destination not a pointer")
        }
 
+       if !sv.IsValid() {
+               sv = reflect.ValueOf(src)
+       }
+
        dv := reflect.Indirect(dpv)
        if dv.Kind() == sv.Kind() {
                dv.Set(sv)
@@ -67,40 +79,49 @@ func convertAssign(dest, src interface{}) error {
 
        switch dv.Kind() {
        case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-               if s, ok := asString(src); ok {
-                       i64, err := strconv.Atoi64(s)
-                       if err != nil {
-                               return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
-                       }
-                       if dv.OverflowInt(i64) {
-                               return fmt.Errorf("string %q overflows %s", s, dv.Kind())
-                       }
-                       dv.SetInt(i64)
-                       return nil
+               s := asString(src)
+               i64, err := strconv.Atoi64(s)
+               if err != nil {
+                       return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
+               }
+               if dv.OverflowInt(i64) {
+                       return fmt.Errorf("string %q overflows %s", s, dv.Kind())
                }
+               dv.SetInt(i64)
+               return nil
        case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
-               if s, ok := asString(src); ok {
-                       u64, err := strconv.Atoui64(s)
-                       if err != nil {
-                               return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
-                       }
-                       if dv.OverflowUint(u64) {
-                               return fmt.Errorf("string %q overflows %s", s, dv.Kind())
-                       }
-                       dv.SetUint(u64)
-                       return nil
+               s := asString(src)
+               u64, err := strconv.Atoui64(s)
+               if err != nil {
+                       return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
+               }
+               if dv.OverflowUint(u64) {
+                       return fmt.Errorf("string %q overflows %s", s, dv.Kind())
+               }
+               dv.SetUint(u64)
+               return nil
+       case reflect.Float32, reflect.Float64:
+               s := asString(src)
+               f64, err := strconv.Atof64(s)
+               if err != nil {
+                       return fmt.Errorf("converting string %q to a %s: %v", s, dv.Kind(), err)
+               }
+               if dv.OverflowFloat(f64) {
+                       return fmt.Errorf("value %q overflows %s", s, dv.Kind())
                }
+               dv.SetFloat(f64)
+               return nil
        }
 
        return fmt.Errorf("unsupported driver -> Scan pair: %T -> %T", src, dest)
 }
 
-func asString(src interface{}) (s string, ok bool) {
+func asString(src interface{}) string {
        switch v := src.(type) {
        case string:
-               return v, true
+               return v
        case []byte:
-               return string(v), true
+               return string(v)
        }
-       return "", false
+       return fmt.Sprintf("%v", src)
 }
index f85ed99..52cee92 100644 (file)
@@ -17,6 +17,9 @@ type conversionTest struct {
        wantint  int64
        wantuint uint64
        wantstr  string
+       wantf32  float32
+       wantf64  float64
+       wantbool bool // used if d is of type *bool
        wanterr  string
 }
 
@@ -29,6 +32,9 @@ var (
        scanint32  int32
        scanuint8  uint8
        scanuint16 uint16
+       scanbool   bool
+       scanf32    float32
+       scanf64    float64
 )
 
 var conversionTests = []conversionTest{
@@ -53,6 +59,35 @@ var conversionTests = []conversionTest{
        {s: "256", d: &scanuint16, wantuint: 256},
        {s: "-1", d: &scanint, wantint: -1},
        {s: "foo", d: &scanint, wanterr: `converting string "foo" to a int: parsing "foo": invalid syntax`},
+
+       // True bools
+       {s: true, d: &scanbool, wantbool: true},
+       {s: "True", d: &scanbool, wantbool: true},
+       {s: "TRUE", d: &scanbool, wantbool: true},
+       {s: "1", d: &scanbool, wantbool: true},
+       {s: 1, d: &scanbool, wantbool: true},
+       {s: int64(1), d: &scanbool, wantbool: true},
+       {s: uint16(1), d: &scanbool, wantbool: true},
+
+       // False bools
+       {s: false, d: &scanbool, wantbool: false},
+       {s: "false", d: &scanbool, wantbool: false},
+       {s: "FALSE", d: &scanbool, wantbool: false},
+       {s: "0", d: &scanbool, wantbool: false},
+       {s: 0, d: &scanbool, wantbool: false},
+       {s: int64(0), d: &scanbool, wantbool: false},
+       {s: uint16(0), d: &scanbool, wantbool: false},
+
+       // Not bools
+       {s: "yup", d: &scanbool, wanterr: `sql/driver: couldn't convert "yup" into type bool`},
+       {s: 2, d: &scanbool, wanterr: `sql/driver: couldn't convert 2 into type bool`},
+
+       // Floats
+       {s: float64(1.5), d: &scanf64, wantf64: float64(1.5)},
+       {s: int64(1), d: &scanf64, wantf64: float64(1)},
+       {s: float64(1.5), d: &scanf32, wantf32: float32(1.5)},
+       {s: "1.5", d: &scanf32, wantf32: float32(1.5)},
+       {s: "1.5", d: &scanf64, wantf64: float64(1.5)},
 }
 
 func intValue(intptr interface{}) int64 {
@@ -63,6 +98,14 @@ func uintValue(intptr interface{}) uint64 {
        return reflect.Indirect(reflect.ValueOf(intptr)).Uint()
 }
 
+func float64Value(ptr interface{}) float64 {
+       return *(ptr.(*float64))
+}
+
+func float32Value(ptr interface{}) float32 {
+       return *(ptr.(*float32))
+}
+
 func TestConversions(t *testing.T) {
        for n, ct := range conversionTests {
                err := convertAssign(ct.d, ct.s)
@@ -86,6 +129,15 @@ func TestConversions(t *testing.T) {
                if ct.wantuint != 0 && ct.wantuint != uintValue(ct.d) {
                        errf("want uint %d, got %d", ct.wantuint, uintValue(ct.d))
                }
+               if ct.wantf32 != 0 && ct.wantf32 != float32Value(ct.d) {
+                       errf("want float32 %v, got %v", ct.wantf32, float32Value(ct.d))
+               }
+               if ct.wantf64 != 0 && ct.wantf64 != float64Value(ct.d) {
+                       errf("want float32 %v, got %v", ct.wantf64, float64Value(ct.d))
+               }
+               if bp, boolTest := ct.d.(*bool); boolTest && *bp != ct.wantbool && ct.wanterr == "" {
+                       errf("want bool %v, got %v", ct.wantbool, *bp)
+               }
        }
 }
 
index 52714e8..6a51c34 100644 (file)
@@ -24,9 +24,13 @@ import "errors"
 // Driver is the interface that must be implemented by a database
 // driver.
 type Driver interface {
-       // Open returns a new or cached connection to the database.
+       // Open returns a new connection to the database.
        // The name is a string in a driver-specific format.
        //
+       // Open may return a cached connection (one previously
+       // closed), but doing so is unnecessary; the sql package
+       // maintains a pool of idle connections for efficient re-use.
+       //
        // The returned connection is only used by one goroutine at a
        // time.
        Open(name string) (Conn, error)
@@ -59,8 +63,12 @@ type Conn interface {
 
        // Close invalidates and potentially stops any current
        // prepared statements and transactions, marking this
-       // connection as no longer in use.  The driver may cache or
-       // close its underlying connection to its database.
+       // connection as no longer in use.
+       //
+       // Because the sql package maintains a free pool of
+       // connections and only calls Close when there's a surplus of
+       // idle connections, it shouldn't be necessary for drivers to
+       // do their own connection caching.
        Close() error
 
        // Begin starts and returns a new transaction.
index 9faf32f..6e0ce43 100644 (file)
@@ -11,6 +11,21 @@ import (
 )
 
 // ValueConverter is the interface providing the ConvertValue method.
+//
+// Various implementations of ValueConverter are provided by the
+// driver package to provide consistent implementations of conversions
+// between drivers.  The ValueConverters have several uses:
+//
+//  * converting from the subset types as provided by the sql package
+//    into a database table's specific column type and making sure it
+//    fits, such as making sure a particular int64 fits in a
+//    table's uint16 column.
+//
+//  * converting a value as given from the database into one of the
+//    subset types.
+//
+//  * by the sql package, for converting from a driver's subset type
+//    to a user's type in a scan.
 type ValueConverter interface {
        // ConvertValue converts a value to a restricted subset type.
        ConvertValue(v interface{}) (interface{}, error)
@@ -19,15 +34,56 @@ type ValueConverter interface {
 // Bool is a ValueConverter that converts input values to bools.
 //
 // The conversion rules are:
-//  - .... TODO(bradfitz): TBD
+//  - booleans are returned unchanged
+//  - for integer types,
+//       1 is true
+//       0 is false,
+//       other integers are an error
+//  - for strings and []byte, same rules as strconv.Atob
+//  - all other types are an error
 var Bool boolType
 
 type boolType struct{}
 
 var _ ValueConverter = boolType{}
 
-func (boolType) ConvertValue(v interface{}) (interface{}, error) {
-       return nil, fmt.Errorf("TODO(bradfitz): bool conversions")
+func (boolType) String() string { return "Bool" }
+
+func (boolType) ConvertValue(src interface{}) (interface{}, error) {
+       switch s := src.(type) {
+       case bool:
+               return s, nil
+       case string:
+               b, err := strconv.Atob(s)
+               if err != nil {
+                       return nil, fmt.Errorf("sql/driver: couldn't convert %q into type bool", s)
+               }
+               return b, nil
+       case []byte:
+               b, err := strconv.Atob(string(s))
+               if err != nil {
+                       return nil, fmt.Errorf("sql/driver: couldn't convert %q into type bool", s)
+               }
+               return b, nil
+       }
+
+       sv := reflect.ValueOf(src)
+       switch sv.Kind() {
+       case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+               iv := sv.Int()
+               if iv == 1 || iv == 0 {
+                       return iv == 1, nil
+               }
+               return nil, fmt.Errorf("sql/driver: couldn't convert %d into type bool", iv)
+       case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+               uv := sv.Uint()
+               if uv == 1 || uv == 0 {
+                       return uv == 1, nil
+               }
+               return nil, fmt.Errorf("sql/driver: couldn't convert %d into type bool", uv)
+       }
+
+       return nil, fmt.Errorf("sql/driver: couldn't convert %v (%T) into type bool", src, src)
 }
 
 // Int32 is a ValueConverter that converts input values to int64,
diff --git a/libgo/go/exp/sql/driver/types_test.go b/libgo/go/exp/sql/driver/types_test.go
new file mode 100644 (file)
index 0000000..4b049e2
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package driver
+
+import (
+       "reflect"
+       "testing"
+)
+
+type valueConverterTest struct {
+       c   ValueConverter
+       in  interface{}
+       out interface{}
+       err string
+}
+
+var valueConverterTests = []valueConverterTest{
+       {Bool, "true", true, ""},
+       {Bool, "True", true, ""},
+       {Bool, []byte("t"), true, ""},
+       {Bool, true, true, ""},
+       {Bool, "1", true, ""},
+       {Bool, 1, true, ""},
+       {Bool, int64(1), true, ""},
+       {Bool, uint16(1), true, ""},
+       {Bool, "false", false, ""},
+       {Bool, false, false, ""},
+       {Bool, "0", false, ""},
+       {Bool, 0, false, ""},
+       {Bool, int64(0), false, ""},
+       {Bool, uint16(0), false, ""},
+       {c: Bool, in: "foo", err: "sql/driver: couldn't convert \"foo\" into type bool"},
+       {c: Bool, in: 2, err: "sql/driver: couldn't convert 2 into type bool"},
+}
+
+func TestValueConverters(t *testing.T) {
+       for i, tt := range valueConverterTests {
+               out, err := tt.c.ConvertValue(tt.in)
+               goterr := ""
+               if err != nil {
+                       goterr = err.Error()
+               }
+               if goterr != tt.err {
+                       t.Errorf("test %d: %s(%T(%v)) error = %q; want error = %q",
+                               i, tt.c, tt.in, tt.in, goterr, tt.err)
+               }
+               if tt.err != "" {
+                       continue
+               }
+               if !reflect.DeepEqual(out, tt.out) {
+                       t.Errorf("test %d: %s(%T(%v)) = %v (%T); want %v (%T)",
+                               i, tt.c, tt.in, tt.in, out, out, tt.out, tt.out)
+               }
+       }
+}
index 289294b..c8a1997 100644 (file)
@@ -476,7 +476,7 @@ func (rc *rowsCursor) Next(dest []interface{}) error {
        for i, v := range rc.rows[rc.pos].cols {
                // TODO(bradfitz): convert to subset types? naah, I
                // think the subset types should only be input to
-               // driver, but the db package should be able to handle
+               // driver, but the sql package should be able to handle
                // a wider range of types coming out of drivers. all
                // for ease of drivers, and to prevent drivers from
                // messing up conversions or doing them differently.
index 4f1c539..291af7f 100644 (file)
@@ -10,7 +10,6 @@ import (
        "errors"
        "fmt"
        "io"
-       "runtime"
        "sync"
 
        "exp/sql/driver"
@@ -192,13 +191,13 @@ func (db *DB) Exec(query string, args ...interface{}) (Result, error) {
 
        // If the driver does not implement driver.Execer, we need
        // a connection.
-       conn, err := db.conn()
+       ci, err := db.conn()
        if err != nil {
                return nil, err
        }
-       defer db.putConn(conn)
+       defer db.putConn(ci)
 
-       if execer, ok := conn.(driver.Execer); ok {
+       if execer, ok := ci.(driver.Execer); ok {
                resi, err := execer.Exec(query, args)
                if err != nil {
                        return nil, err
@@ -206,7 +205,7 @@ func (db *DB) Exec(query string, args ...interface{}) (Result, error) {
                return result{resi}, nil
        }
 
-       sti, err := conn.Prepare(query)
+       sti, err := ci.Prepare(query)
        if err != nil {
                return nil, err
        }
@@ -233,18 +232,26 @@ func (db *DB) Query(query string, args ...interface{}) (*Rows, error) {
 // Row's Scan method is called.
 func (db *DB) QueryRow(query string, args ...interface{}) *Row {
        rows, err := db.Query(query, args...)
-       if err != nil {
-               return &Row{err: err}
-       }
-       return &Row{rows: rows}
+       return &Row{rows: rows, err: err}
 }
 
-// Begin starts a transaction.  The isolation level is dependent on
+// Begin starts a transaction. The isolation level is dependent on
 // the driver.
 func (db *DB) Begin() (*Tx, error) {
-       // TODO(bradfitz): add another method for beginning a transaction
-       // at a specific isolation level.
-       panic(todo())
+       ci, err := db.conn()
+       if err != nil {
+               return nil, err
+       }
+       txi, err := ci.Begin()
+       if err != nil {
+               db.putConn(ci)
+               return nil, fmt.Errorf("sql: failed to Begin transaction: %v", err)
+       }
+       return &Tx{
+               db:  db,
+               ci:  ci,
+               txi: txi,
+       }, nil
 }
 
 // DriverDatabase returns the database's underlying driver.
@@ -253,41 +260,158 @@ func (db *DB) Driver() driver.Driver {
 }
 
 // Tx is an in-progress database transaction.
+//
+// A transaction must end with a call to Commit or Rollback.
+//
+// After a call to Commit or Rollback, all operations on the
+// transaction fail with ErrTransactionFinished.
 type Tx struct {
+       db *DB
+
+       // ci is owned exclusively until Commit or Rollback, at which point
+       // it's returned with putConn.
+       ci  driver.Conn
+       txi driver.Tx
+
+       // cimu is held while somebody is using ci (between grabConn
+       // and releaseConn)
+       cimu sync.Mutex
 
+       // done transitions from false to true exactly once, on Commit
+       // or Rollback. once done, all operations fail with
+       // ErrTransactionFinished.
+       done bool
+}
+
+var ErrTransactionFinished = errors.New("sql: Transaction has already been committed or rolled back")
+
+func (tx *Tx) close() {
+       if tx.done {
+               panic("double close") // internal error
+       }
+       tx.done = true
+       tx.db.putConn(tx.ci)
+       tx.ci = nil
+       tx.txi = nil
+}
+
+func (tx *Tx) grabConn() (driver.Conn, error) {
+       if tx.done {
+               return nil, ErrTransactionFinished
+       }
+       tx.cimu.Lock()
+       return tx.ci, nil
+}
+
+func (tx *Tx) releaseConn() {
+       tx.cimu.Unlock()
 }
 
 // Commit commits the transaction.
 func (tx *Tx) Commit() error {
-       panic(todo())
+       if tx.done {
+               return ErrTransactionFinished
+       }
+       defer tx.close()
+       return tx.txi.Commit()
 }
 
 // Rollback aborts the transaction.
 func (tx *Tx) Rollback() error {
-       panic(todo())
+       if tx.done {
+               return ErrTransactionFinished
+       }
+       defer tx.close()
+       return tx.txi.Rollback()
 }
 
 // Prepare creates a prepared statement.
+//
+// The statement is only valid within the scope of this transaction.
 func (tx *Tx) Prepare(query string) (*Stmt, error) {
-       panic(todo())
+       // TODO(bradfitz): the restriction that the returned statement
+       // is only valid for this Transaction is lame and negates a
+       // lot of the benefit of prepared statements.  We could be
+       // more efficient here and either provide a method to take an
+       // existing Stmt (created on perhaps a different Conn), and
+       // re-create it on this Conn if necessary. Or, better: keep a
+       // map in DB of query string to Stmts, and have Stmt.Execute
+       // do the right thing and re-prepare if the Conn in use
+       // doesn't have that prepared statement.  But we'll want to
+       // avoid caching the statement in the case where we only call
+       // conn.Prepare implicitly (such as in db.Exec or tx.Exec),
+       // but the caller package can't be holding a reference to the
+       // returned statement.  Perhaps just looking at the reference
+       // count (by noting Stmt.Close) would be enough. We might also
+       // want a finalizer on Stmt to drop the reference count.
+       ci, err := tx.grabConn()
+       if err != nil {
+               return nil, err
+       }
+       defer tx.releaseConn()
+
+       si, err := ci.Prepare(query)
+       if err != nil {
+               return nil, err
+       }
+
+       stmt := &Stmt{
+               db:    tx.db,
+               tx:    tx,
+               txsi:  si,
+               query: query,
+       }
+       return stmt, nil
 }
 
 // Exec executes a query that doesn't return rows.
 // For example: an INSERT and UPDATE.
-func (tx *Tx) Exec(query string, args ...interface{}) {
-       panic(todo())
+func (tx *Tx) Exec(query string, args ...interface{}) (Result, error) {
+       ci, err := tx.grabConn()
+       if err != nil {
+               return nil, err
+       }
+       defer tx.releaseConn()
+
+       if execer, ok := ci.(driver.Execer); ok {
+               resi, err := execer.Exec(query, args)
+               if err != nil {
+                       return nil, err
+               }
+               return result{resi}, nil
+       }
+
+       sti, err := ci.Prepare(query)
+       if err != nil {
+               return nil, err
+       }
+       defer sti.Close()
+       resi, err := sti.Exec(args)
+       if err != nil {
+               return nil, err
+       }
+       return result{resi}, nil
 }
 
 // Query executes a query that returns rows, typically a SELECT.
 func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error) {
-       panic(todo())
+       if tx.done {
+               return nil, ErrTransactionFinished
+       }
+       stmt, err := tx.Prepare(query)
+       if err != nil {
+               return nil, err
+       }
+       defer stmt.Close()
+       return stmt.Query(args...)
 }
 
 // QueryRow executes a query that is expected to return at most one row.
 // QueryRow always return a non-nil value. Errors are deferred until
 // Row's Scan method is called.
 func (tx *Tx) QueryRow(query string, args ...interface{}) *Row {
-       panic(todo())
+       rows, err := tx.Query(query, args...)
+       return &Row{rows: rows, err: err}
 }
 
 // connStmt is a prepared statement on a particular connection.
@@ -302,24 +426,28 @@ type Stmt struct {
        db    *DB    // where we came from
        query string // that created the Sttm
 
-       mu     sync.Mutex
+       // If in a transaction, else both nil:
+       tx   *Tx
+       txsi driver.Stmt
+
+       mu     sync.Mutex // protects the rest of the fields
        closed bool
-       css    []connStmt // can use any that have idle connections
-}
 
-func todo() string {
-       _, file, line, _ := runtime.Caller(1)
-       return fmt.Sprintf("%s:%d: TODO: implement", file, line)
+       // css is a list of underlying driver statement interfaces
+       // that are valid on particular connections.  This is only
+       // used if tx == nil and one is found that has idle
+       // connections.  If tx != nil, txsi is always used.
+       css []connStmt
 }
 
 // Exec executes a prepared statement with the given arguments and
 // returns a Result summarizing the effect of the statement.
 func (s *Stmt) Exec(args ...interface{}) (Result, error) {
-       ci, si, err := s.connStmt()
+       _, releaseConn, si, err := s.connStmt()
        if err != nil {
                return nil, err
        }
-       defer s.db.putConn(ci)
+       defer releaseConn()
 
        if want := si.NumInput(); len(args) != want {
                return nil, fmt.Errorf("db: expected %d arguments, got %d", want, len(args))
@@ -353,11 +481,29 @@ func (s *Stmt) Exec(args ...interface{}) (Result, error) {
        return result{resi}, nil
 }
 
-func (s *Stmt) connStmt(args ...interface{}) (driver.Conn, driver.Stmt, error) {
+// connStmt returns a free driver connection on which to execute the
+// statement, a function to call to release the connection, and a
+// statement bound to that connection.
+func (s *Stmt) connStmt() (ci driver.Conn, releaseConn func(), si driver.Stmt, err error) {
        s.mu.Lock()
        if s.closed {
-               return nil, nil, errors.New("db: statement is closed")
+               s.mu.Unlock()
+               err = errors.New("db: statement is closed")
+               return
        }
+
+       // In a transaction, we always use the connection that the
+       // transaction was created on.
+       if s.tx != nil {
+               s.mu.Unlock()
+               ci, err = s.tx.grabConn() // blocks, waiting for the connection.
+               if err != nil {
+                       return
+               }
+               releaseConn = func() { s.tx.releaseConn() }
+               return ci, releaseConn, s.txsi, nil
+       }
+
        var cs connStmt
        match := false
        for _, v := range s.css {
@@ -375,11 +521,11 @@ func (s *Stmt) connStmt(args ...interface{}) (driver.Conn, driver.Stmt, error) {
        if !match {
                ci, err := s.db.conn()
                if err != nil {
-                       return nil, nil, err
+                       return nil, nil, nil, err
                }
                si, err := ci.Prepare(s.query)
                if err != nil {
-                       return nil, nil, err
+                       return nil, nil, nil, err
                }
                s.mu.Lock()
                cs = connStmt{ci, si}
@@ -387,13 +533,15 @@ func (s *Stmt) connStmt(args ...interface{}) (driver.Conn, driver.Stmt, error) {
                s.mu.Unlock()
        }
 
-       return cs.ci, cs.si, nil
+       conn := cs.ci
+       releaseConn = func() { s.db.putConn(conn) }
+       return conn, releaseConn, cs.si, nil
 }
 
 // Query executes a prepared query statement with the given arguments
 // and returns the query results as a *Rows.
 func (s *Stmt) Query(args ...interface{}) (*Rows, error) {
-       ci, si, err := s.connStmt(args...)
+       ci, releaseConn, si, err := s.connStmt()
        if err != nil {
                return nil, err
        }
@@ -405,11 +553,13 @@ func (s *Stmt) Query(args ...interface{}) (*Rows, error) {
                s.db.putConn(ci)
                return nil, err
        }
-       // Note: ownership of ci passes to the *Rows
+       // Note: ownership of ci passes to the *Rows, to be freed
+       // with releaseConn.
        rows := &Rows{
-               db:    s.db,
-               ci:    ci,
-               rowsi: rowsi,
+               db:          s.db,
+               ci:          ci,
+               releaseConn: releaseConn,
+               rowsi:       rowsi,
        }
        return rows, nil
 }
@@ -436,19 +586,24 @@ func (s *Stmt) QueryRow(args ...interface{}) *Row {
 // Close closes the statement.
 func (s *Stmt) Close() error {
        s.mu.Lock()
-       defer s.mu.Unlock() // TODO(bradfitz): move this unlock after 'closed = true'?
+       defer s.mu.Unlock()
        if s.closed {
                return nil
        }
        s.closed = true
-       for _, v := range s.css {
-               if ci, match := s.db.connIfFree(v.ci); match {
-                       v.si.Close()
-                       s.db.putConn(ci)
-               } else {
-                       // TODO(bradfitz): care that we can't close
-                       // this statement because the statement's
-                       // connection is in use?
+
+       if s.tx != nil {
+               s.txsi.Close()
+       } else {
+               for _, v := range s.css {
+                       if ci, match := s.db.connIfFree(v.ci); match {
+                               v.si.Close()
+                               s.db.putConn(ci)
+                       } else {
+                               // TODO(bradfitz): care that we can't close
+                               // this statement because the statement's
+                               // connection is in use?
+                       }
                }
        }
        return nil
@@ -465,12 +620,13 @@ func (s *Stmt) Close() error {
 //         err = rows.Scan(&id, &name)
 //         ...
 //     }
-//     err = rows.Error() // get any Error encountered during iteration
+//     err = rows.Err() // get any error encountered during iteration
 //     ...
 type Rows struct {
-       db    *DB
-       ci    driver.Conn // owned; must be returned when Rows is closed
-       rowsi driver.Rows
+       db          *DB
+       ci          driver.Conn // owned; must call putconn when closed to release
+       releaseConn func()
+       rowsi       driver.Rows
 
        closed   bool
        lastcols []interface{}
@@ -495,8 +651,8 @@ func (rs *Rows) Next() bool {
        return rs.lasterr == nil
 }
 
-// Error returns the error, if any, that was encountered during iteration.
-func (rs *Rows) Error() error {
+// Err returns the error, if any, that was encountered during iteration.
+func (rs *Rows) Err() error {
        if rs.lasterr == io.EOF {
                return nil
        }
@@ -538,7 +694,7 @@ func (rs *Rows) Close() error {
        }
        rs.closed = true
        err := rs.rowsi.Close()
-       rs.db.putConn(rs.ci)
+       rs.releaseConn()
        return err
 }
 
index 345e707..da45688 100644 (file)
@@ -5,12 +5,12 @@
 package ssh
 
 import (
-       "big"
        "crypto"
        "crypto/rand"
        "errors"
        "fmt"
        "io"
+       "math/big"
        "net"
        "sync"
 )
@@ -131,56 +131,6 @@ func (c *ClientConn) handshake() error {
        return c.transport.reader.setupKeys(serverKeys, K, H, H, hashFunc)
 }
 
-// authenticate authenticates with the remote server. See RFC 4252. 
-// Only "password" authentication is supported.
-func (c *ClientConn) authenticate() error {
-       if err := c.writePacket(marshal(msgServiceRequest, serviceRequestMsg{serviceUserAuth})); err != nil {
-               return err
-       }
-       packet, err := c.readPacket()
-       if err != nil {
-               return err
-       }
-
-       var serviceAccept serviceAcceptMsg
-       if err = unmarshal(&serviceAccept, packet, msgServiceAccept); err != nil {
-               return err
-       }
-
-       // TODO(dfc) support proper authentication method negotation
-       method := "none"
-       if c.config.Password != "" {
-               method = "password"
-       }
-       if err := c.sendUserAuthReq(method); err != nil {
-               return err
-       }
-
-       if packet, err = c.readPacket(); err != nil {
-               return err
-       }
-
-       if packet[0] != msgUserAuthSuccess {
-               return UnexpectedMessageError{msgUserAuthSuccess, packet[0]}
-       }
-       return nil
-}
-
-func (c *ClientConn) sendUserAuthReq(method string) error {
-       length := stringLength([]byte(c.config.Password)) + 1
-       payload := make([]byte, length)
-       // always false for password auth, see RFC 4252 Section 8.
-       payload[0] = 0
-       marshalString(payload[1:], []byte(c.config.Password))
-
-       return c.writePacket(marshal(msgUserAuthRequest, userAuthRequestMsg{
-               User:    c.config.User,
-               Service: serviceSSH,
-               Method:  method,
-               Payload: payload,
-       }))
-}
-
 // kexDH performs Diffie-Hellman key agreement on a ClientConn. The
 // returned values are given the same names as in RFC 4253, section 8.
 func (c *ClientConn) kexDH(group *dhGroup, hashFunc crypto.Hash, magics *handshakeMagics, hostKeyAlgo string) ([]byte, []byte, error) {
@@ -348,8 +298,9 @@ type ClientConfig struct {
        // The username to authenticate.
        User string
 
-       // Used for "password" method authentication.
-       Password string
+       // A slice of ClientAuth methods. Only the first instance 
+       // of a particular RFC 4252 method will be used during authentication.
+       Auth []ClientAuth
 }
 
 func (c *ClientConfig) rand() io.Reader {
diff --git a/libgo/go/exp/ssh/client_auth.go b/libgo/go/exp/ssh/client_auth.go
new file mode 100644 (file)
index 0000000..0089d0c
--- /dev/null
@@ -0,0 +1,157 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ssh
+
+import (
+       "errors"
+)
+
+// authenticate authenticates with the remote server. See RFC 4252. 
+func (c *ClientConn) authenticate() error {
+       // initiate user auth session
+       if err := c.writePacket(marshal(msgServiceRequest, serviceRequestMsg{serviceUserAuth})); err != nil {
+               return err
+       }
+       packet, err := c.readPacket()
+       if err != nil {
+               return err
+       }
+       var serviceAccept serviceAcceptMsg
+       if err := unmarshal(&serviceAccept, packet, msgServiceAccept); err != nil {
+               return err
+       }
+       // during the authentication phase the client first attempts the "none" method
+       // then any untried methods suggested by the server. 
+       tried, remain := make(map[string]bool), make(map[string]bool)
+       for auth := ClientAuth(new(noneAuth)); auth != nil; {
+               ok, methods, err := auth.auth(c.config.User, c.transport)
+               if err != nil {
+                       return err
+               }
+               if ok {
+                       // success
+                       return nil
+               }
+               tried[auth.method()] = true
+               delete(remain, auth.method())
+               for _, meth := range methods {
+                       if tried[meth] {
+                               // if we've tried meth already, skip it.
+                               continue
+                       }
+                       remain[meth] = true
+               }
+               auth = nil
+               for _, a := range c.config.Auth {
+                       if remain[a.method()] {
+                               auth = a
+                               break
+                       }
+               }
+       }
+       return errors.New("ssh: unable to authenticate, no supported methods remain")
+}
+
+// A ClientAuth represents an instance of an RFC 4252 authentication method.
+type ClientAuth interface {
+       // auth authenticates user over transport t. 
+       // Returns true if authentication is successful.
+       // If authentication is not successful, a []string of alternative 
+       // method names is returned.
+       auth(user string, t *transport) (bool, []string, error)
+
+       // method returns the RFC 4252 method name.
+       method() string
+}
+
+// "none" authentication, RFC 4252 section 5.2.
+type noneAuth int
+
+func (n *noneAuth) auth(user string, t *transport) (bool, []string, error) {
+       if err := t.writePacket(marshal(msgUserAuthRequest, userAuthRequestMsg{
+               User:    user,
+               Service: serviceSSH,
+               Method:  "none",
+       })); err != nil {
+               return false, nil, err
+       }
+
+       packet, err := t.readPacket()
+       if err != nil {
+               return false, nil, err
+       }
+
+       switch packet[0] {
+       case msgUserAuthSuccess:
+               return true, nil, nil
+       case msgUserAuthFailure:
+               msg := decode(packet).(*userAuthFailureMsg)
+               return false, msg.Methods, nil
+       }
+       return false, nil, UnexpectedMessageError{msgUserAuthSuccess, packet[0]}
+}
+
+func (n *noneAuth) method() string {
+       return "none"
+}
+
+// "password" authentication, RFC 4252 Section 8.
+type passwordAuth struct {
+       ClientPassword
+}
+
+func (p *passwordAuth) auth(user string, t *transport) (bool, []string, error) {
+       type passwordAuthMsg struct {
+               User     string
+               Service  string
+               Method   string
+               Reply    bool
+               Password string
+       }
+
+       pw, err := p.Password(user)
+       if err != nil {
+               return false, nil, err
+       }
+
+       if err := t.writePacket(marshal(msgUserAuthRequest, passwordAuthMsg{
+               User:     user,
+               Service:  serviceSSH,
+               Method:   "password",
+               Reply:    false,
+               Password: pw,
+       })); err != nil {
+               return false, nil, err
+       }
+
+       packet, err := t.readPacket()
+       if err != nil {
+               return false, nil, err
+       }
+
+       switch packet[0] {
+       case msgUserAuthSuccess:
+               return true, nil, nil
+       case msgUserAuthFailure:
+               msg := decode(packet).(*userAuthFailureMsg)
+               return false, msg.Methods, nil
+       }
+       return false, nil, UnexpectedMessageError{msgUserAuthSuccess, packet[0]}
+}
+
+func (p *passwordAuth) method() string {
+       return "password"
+}
+
+// A ClientPassword implements access to a client's passwords.
+type ClientPassword interface {
+       // Password returns the password to use for user.
+       Password(user string) (password string, err error)
+}
+
+// ClientAuthPassword returns a ClientAuth using password authentication.
+func ClientAuthPassword(impl ClientPassword) ClientAuth {
+       return &passwordAuth{impl}
+}
index f68c353..273820b 100644 (file)
@@ -5,7 +5,7 @@
 package ssh
 
 import (
-       "big"
+       "math/big"
        "strconv"
        "sync"
 )
index fc842b0..248b2fe 100644 (file)
@@ -83,7 +83,7 @@ authentication method is supported.
 
        config := &ClientConfig{
                User: "username",
-               Password: "123456",
+               Auth: []ClientAuth{ ... },
        }
        client, err := Dial("yourserver.com:22", config)
 
index 5eae181..e24b639 100644 (file)
@@ -5,9 +5,9 @@
 package ssh
 
 import (
-       "big"
        "bytes"
        "io"
+       "math/big"
        "reflect"
 )
 
index 629f3d3..fe4c397 100644 (file)
@@ -5,8 +5,8 @@
 package ssh
 
 import (
-       "big"
-       "rand"
+       "math/big"
+       "math/rand"
        "reflect"
        "testing"
        "testing/quick"
index 2ae8079..62035d5 100644 (file)
@@ -5,7 +5,6 @@
 package ssh
 
 import (
-       "big"
        "bytes"
        "crypto"
        "crypto/rand"
@@ -14,6 +13,7 @@ import (
        "encoding/pem"
        "errors"
        "io"
+       "math/big"
        "net"
        "sync"
 )
index 1ef95d9..048f63b 100644 (file)
@@ -7,8 +7,8 @@
 package types
 
 import (
-       "big"
        "go/token"
+       "math/big"
        "strconv"
 )
 
@@ -131,7 +131,7 @@ func (x Const) Match(y Const) (u, v Const) {
 // otherwise the result is invalid.
 func (x Const) Convert(typ *Type) Const {
        // TODO(gri) implement this
-       switch x := x.val.(type) {
+       switch x.val.(type) {
        case bool:
        case *big.Int:
        case *big.Rat:
index 69dbd5a..4167caf 100644 (file)
@@ -8,17 +8,17 @@
 package types
 
 import (
-       "big"
        "errors"
        "fmt"
        "go/ast"
        "go/token"
        "io"
+       "math/big"
        "os"
        "path/filepath"
        "runtime"
-       "scanner"
        "strconv"
+       "text/scanner"
 )
 
 const trace = false // set to true for debugging
index ec87f5d..3f66d22 100644 (file)
@@ -5,9 +5,9 @@
 package types
 
 import (
-       "exec"
        "go/ast"
        "io/ioutil"
+       "os/exec"
        "path/filepath"
        "runtime"
        "strings"
index a2f16f2..5df2ee0 100644 (file)
@@ -6,8 +6,8 @@ package main
 
 import (
        "fmt"
-       "syscall"
        "os"
+       "syscall"
        "unsafe"
 )
 
index 3201528..08059df 100644 (file)
@@ -5,8 +5,8 @@
 package main
 
 import (
-       "unsafe"
        "syscall"
+       "unsafe"
 )
 
 type Wndclassex struct {
index f5d6ed5..629280a 100644 (file)
@@ -23,10 +23,10 @@ package expvar
 
 import (
        "bytes"
+       "encoding/json"
        "fmt"
-       "http"
-       "json"
        "log"
+       "net/http"
        "os"
        "runtime"
        "strconv"
index 8f7a481..fc60727 100644 (file)
@@ -5,7 +5,7 @@
 package expvar
 
 import (
-       "json"
+       "encoding/json"
        "testing"
 )
 
index 80eb986..3957a5a 100644 (file)
@@ -8,7 +8,7 @@ import (
        "bytes"
        "strconv"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 const (
index 1345644..bfa88d1 100644 (file)
@@ -12,7 +12,7 @@ import (
        "reflect"
        "sync"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Some constants in the form of bytes, to avoid string overhead.
index 54a9fe2..85571e8 100644 (file)
@@ -14,7 +14,7 @@ import (
        "strconv"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // runeUnreader is the interface to something that can unread runes.
@@ -219,7 +219,7 @@ func (s *ss) getRune() (r rune) {
        return
 }
 
-// mustReadRune turns os.EOF into a panic(io.ErrUnexpectedEOF).
+// mustReadRune turns io.EOF into a panic(io.ErrUnexpectedEOF).
 // It is called in cases such as string scanning where an EOF is a
 // syntax error.
 func (s *ss) mustReadRune() (r rune) {
index 7dd0015..d3c39be 100644 (file)
@@ -15,7 +15,7 @@ import (
        "regexp"
        "strings"
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 type ScanTest struct {
index f8caafc..a0aa5ff 100644 (file)
@@ -10,7 +10,7 @@ package ast
 import (
        "go/token"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // ----------------------------------------------------------------------------
diff --git a/libgo/go/go/ast/import.go b/libgo/go/go/ast/import.go
new file mode 100644 (file)
index 0000000..894fecd
--- /dev/null
@@ -0,0 +1,139 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ast
+
+import (
+       "go/token"
+       "sort"
+       "strconv"
+)
+
+// SortImports sorts runs of consecutive import lines in import blocks in f.
+func SortImports(fset *token.FileSet, f *File) {
+       for _, d := range f.Decls {
+               d, ok := d.(*GenDecl)
+               if !ok || d.Tok != token.IMPORT {
+                       // Not an import declaration, so we're done.
+                       // Imports are always first.
+                       break
+               }
+
+               if d.Lparen == token.NoPos {
+                       // Not a block: sorted by default.
+                       continue
+               }
+
+               // Identify and sort runs of specs on successive lines.
+               i := 0
+               for j, s := range d.Specs {
+                       if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line {
+                               // j begins a new run.  End this one.
+                               sortSpecs(fset, f, d.Specs[i:j])
+                               i = j
+                       }
+               }
+               sortSpecs(fset, f, d.Specs[i:])
+       }
+}
+
+func importPath(s Spec) string {
+       t, err := strconv.Unquote(s.(*ImportSpec).Path.Value)
+       if err == nil {
+               return t
+       }
+       return ""
+}
+
+type posSpan struct {
+       Start token.Pos
+       End   token.Pos
+}
+
+func sortSpecs(fset *token.FileSet, f *File, specs []Spec) {
+       // Avoid work if already sorted (also catches < 2 entries).
+       sorted := true
+       for i, s := range specs {
+               if i > 0 && importPath(specs[i-1]) > importPath(s) {
+                       sorted = false
+                       break
+               }
+       }
+       if sorted {
+               return
+       }
+
+       // Record positions for specs.
+       pos := make([]posSpan, len(specs))
+       for i, s := range specs {
+               // Cannot use s.End(), because it looks at len(s.Path.Value),
+               // and that string might have gotten longer or shorter.
+               // Instead, use s.Pos()+1, which is guaranteed to be > s.Pos()
+               // and still before the original end of the string, since any
+               // string literal must be at least 2 characters ("" or ``).
+               pos[i] = posSpan{s.Pos(), s.Pos() + 1}
+       }
+
+       // Identify comments in this range.
+       // Any comment from pos[0].Start to the final line counts.
+       lastLine := fset.Position(pos[len(pos)-1].End).Line
+       cstart := len(f.Comments)
+       cend := len(f.Comments)
+       for i, g := range f.Comments {
+               if g.Pos() < pos[0].Start {
+                       continue
+               }
+               if i < cstart {
+                       cstart = i
+               }
+               if fset.Position(g.End()).Line > lastLine {
+                       cend = i
+                       break
+               }
+       }
+       comments := f.Comments[cstart:cend]
+
+       // Assign each comment to the import spec preceding it.
+       importComment := map[*ImportSpec][]*CommentGroup{}
+       specIndex := 0
+       for _, g := range comments {
+               for specIndex+1 < len(specs) && pos[specIndex+1].Start <= g.Pos() {
+                       specIndex++
+               }
+               s := specs[specIndex].(*ImportSpec)
+               importComment[s] = append(importComment[s], g)
+       }
+
+       // Sort the import specs by import path.
+       // Reassign the import paths to have the same position sequence.
+       // Reassign each comment to abut the end of its spec.
+       // Sort the comments by new position.
+       sort.Sort(byImportPath(specs))
+       for i, s := range specs {
+               s := s.(*ImportSpec)
+               if s.Name != nil {
+                       s.Name.NamePos = pos[i].Start
+               }
+               s.Path.ValuePos = pos[i].Start
+               s.EndPos = pos[i].End
+               for _, g := range importComment[s] {
+                       for _, c := range g.List {
+                               c.Slash = pos[i].End
+                       }
+               }
+       }
+       sort.Sort(byCommentPos(comments))
+}
+
+type byImportPath []Spec // slice of *ImportSpec
+
+func (x byImportPath) Len() int           { return len(x) }
+func (x byImportPath) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
+func (x byImportPath) Less(i, j int) bool { return importPath(x[i]) < importPath(x[j]) }
+
+type byCommentPos []*CommentGroup
+
+func (x byCommentPos) Len() int           { return len(x) }
+func (x byCommentPos) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }
+func (x byCommentPos) Less(i, j int) bool { return x[i].Pos() < x[j].Pos() }
index 282a508..e3de8d0 100644 (file)
@@ -8,9 +8,9 @@ package build
 import (
        "bytes"
        "errors"
-       "exec"
        "fmt"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "runtime"
index 398e31c..db8bc6c 100644 (file)
@@ -5,7 +5,7 @@
 package build
 
 import (
-       "exec"
+       "os/exec"
        "path/filepath"
        "reflect"
        "runtime"
index e198922..19216f8 100644 (file)
@@ -11,7 +11,7 @@ import (
        "io"
        "regexp"
        "strings"
-       "template" // for HTMLEscape
+       "text/template" // for HTMLEscape
 )
 
 func isWhitespace(ch byte) bool { return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' }
index 7fdf0bc..196c957 100644 (file)
@@ -10,7 +10,7 @@ import (
        "go/ast"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 type Example struct {
index e2c9441..55b8998 100644 (file)
@@ -1131,7 +1131,7 @@ func (p *parser) parseLiteralValue(typ ast.Expr) ast.Expr {
 
 // checkExpr checks that x is an expression (and not a type).
 func (p *parser) checkExpr(x ast.Expr) ast.Expr {
-       switch t := unparen(x).(type) {
+       switch unparen(x).(type) {
        case *ast.BadExpr:
        case *ast.Ident:
        case *ast.BasicLit:
index 8f1ed11..aba7d93 100644 (file)
@@ -13,7 +13,7 @@ import (
        "io"
        "os"
        "path/filepath"
-       "tabwriter"
+       "text/tabwriter"
 )
 
 const debug = false // enable for debugging
index dfbdaa3..cef9c48 100644 (file)
@@ -27,7 +27,7 @@ import (
        "path/filepath"
        "strconv"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A Scanner holds the scanner's internal state while processing
index 611b1b3..042d6ab 100644 (file)
@@ -5,7 +5,7 @@
 package token
 
 import (
-       "gob"
+       "encoding/gob"
        "io"
 )
 
index ba9d188..1bea690 100644 (file)
@@ -36,7 +36,7 @@ lower-cased, and attributes are collected into a []Attribute. For example:
 
        for {
                if z.Next() == html.ErrorToken {
-                       // Returning os.EOF indicates success.
+                       // Returning io.EOF indicates success.
                        return z.Error()
                }
                emitToken(z.Token())
@@ -61,7 +61,7 @@ call to Next. For example, to extract an HTML page's anchor text:
                case StartTagToken, EndTagToken:
                        tn, _ := z.TagName()
                        if len(tn) == 1 && tn[0] == 'a' {
-                               if tt == StartTag {
+                               if tt == StartTagToken {
                                        depth++
                                } else {
                                        depth--
index 2cf49d6..b53f866 100644 (file)
@@ -6,7 +6,7 @@ package html
 
 import (
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 func TestEntityLength(t *testing.T) {
index b8e6571..ac9e100 100644 (file)
@@ -7,7 +7,7 @@ package html
 import (
        "bytes"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 // These replacements permit compatibility with old numeric entities that 
index c9f0165..f47d4ea 100644 (file)
@@ -250,7 +250,7 @@ func (p *parser) read() error {
        p.tok = p.tokenizer.Token()
        switch p.tok.Type {
        case ErrorToken:
-               return p.tokenizer.Error()
+               return p.tokenizer.Err()
        case SelfClosingTagToken:
                p.hasSelfClosingToken = true
                p.tok.Type = StartTagToken
@@ -275,7 +275,9 @@ type insertionMode func(*parser) (insertionMode, bool)
 // Section 11.2.3.1, "using the rules for".
 func useTheRulesFor(p *parser, actual, delegate insertionMode) (insertionMode, bool) {
        im, consumed := delegate(p)
-       // TODO: do we need to update p.originalMode if it equals delegate?
+       if p.originalIM == delegate {
+               p.originalIM = actual
+       }
        if im != delegate {
                return im, consumed
        }
@@ -427,6 +429,7 @@ func beforeHeadIM(p *parser) (insertionMode, bool) {
        }
        if add || implied {
                p.addElement("head", attr)
+               p.head = p.top()
        }
        return inHeadIM, !implied
 }
@@ -455,8 +458,10 @@ func inHeadIM(p *parser) (insertionMode, bool) {
                implied = true
        case StartTagToken:
                switch p.tok.Data {
-               case "meta":
-                       // TODO.
+               case "base", "basefont", "bgsound", "command", "link", "meta":
+                       p.addElement(p.tok.Data, p.tok.Attr)
+                       p.oe.pop()
+                       p.acknowledgeSelfClosingTag()
                case "script", "title", "noscript", "noframes", "style":
                        p.addElement(p.tok.Data, p.tok.Attr)
                        p.setOriginalIM(inHeadIM)
@@ -509,7 +514,9 @@ func afterHeadIM(p *parser) (insertionMode, bool) {
                case "frameset":
                        // TODO.
                case "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title":
-                       // TODO.
+                       p.oe = append(p.oe, p.head)
+                       defer p.oe.pop()
+                       return useTheRulesFor(p, afterHeadIM, inHeadIM)
                case "head":
                        // TODO.
                default:
@@ -532,6 +539,23 @@ func afterHeadIM(p *parser) (insertionMode, bool) {
        return inBodyIM, !implied
 }
 
+// copyAttributes copies attributes of src not found on dst to dst.
+func copyAttributes(dst *Node, src Token) {
+       if len(src.Attr) == 0 {
+               return
+       }
+       attr := map[string]string{}
+       for _, a := range dst.Attr {
+               attr[a.Key] = a.Val
+       }
+       for _, a := range src.Attr {
+               if _, ok := attr[a.Key]; !ok {
+                       dst.Attr = append(dst.Attr, a)
+                       attr[a.Key] = a.Val
+               }
+       }
+}
+
 // Section 11.2.5.4.7.
 func inBodyIM(p *parser) (insertionMode, bool) {
        switch p.tok.Type {
@@ -617,6 +641,19 @@ func inBodyIM(p *parser) (insertionMode, bool) {
                        }
                        p.reconstructActiveFormattingElements()
                        p.addElement(p.tok.Data, p.tok.Attr)
+               case "body":
+                       if len(p.oe) >= 2 {
+                               body := p.oe[1]
+                               if body.Type == ElementNode && body.Data == "body" {
+                                       p.framesetOK = false
+                                       copyAttributes(body, p.tok)
+                               }
+                       }
+               case "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title":
+                       return useTheRulesFor(p, inBodyIM, inHeadIM)
+               case "image":
+                       p.tok.Data = "img"
+                       return inBodyIM, false
                default:
                        // TODO.
                        p.addElement(p.tok.Data, p.tok.Attr)
@@ -635,6 +672,10 @@ func inBodyIM(p *parser) (insertionMode, bool) {
                        p.inBodyEndTagFormatting(p.tok.Data)
                case "address", "article", "aside", "blockquote", "button", "center", "details", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "listing", "menu", "nav", "ol", "pre", "section", "summary", "ul":
                        p.popUntil(defaultScopeStopTags, p.tok.Data)
+               case "applet", "marquee", "object":
+                       if p.popUntil(defaultScopeStopTags, p.tok.Data) {
+                               p.clearActiveFormattingElements()
+                       }
                default:
                        p.inBodyEndTagOther(p.tok.Data)
                }
@@ -934,22 +975,27 @@ func inRowIM(p *parser) (insertionMode, bool) {
        case StartTagToken:
                switch p.tok.Data {
                case "td", "th":
-                       // TODO: clear the stack back to a table row context.
+                       p.clearStackToContext(tableRowContextStopTags)
                        p.addElement(p.tok.Data, p.tok.Attr)
                        p.afe = append(p.afe, &scopeMarker)
                        return inCellIM, true
+               case "caption", "col", "colgroup", "tbody", "tfoot", "thead", "tr":
+                       if p.popUntil(tableScopeStopTags, "tr") {
+                               return inTableBodyIM, false
+                       }
+                       // Ignore the token.
+                       return inRowIM, true
                default:
                        // TODO.
                }
        case EndTagToken:
                switch p.tok.Data {
                case "tr":
-                       if !p.elementInScope(tableScopeStopTags, "tr") {
-                               return inRowIM, true
+                       if p.popUntil(tableScopeStopTags, "tr") {
+                               return inTableBodyIM, true
                        }
-                       p.clearStackToContext(tableRowContextStopTags)
-                       p.oe.pop()
-                       return inTableBodyIM, true
+                       // Ignore the token.
+                       return inRowIM, true
                case "table":
                        if p.popUntil(tableScopeStopTags, "tr") {
                                return inTableBodyIM, false
index 3fa4037..2797922 100644 (file)
@@ -23,6 +23,7 @@ func pipeErr(err error) io.Reader {
 }
 
 func readDat(filename string, c chan io.Reader) {
+       defer close(c)
        f, err := os.Open("testdata/webkit/" + filename)
        if err != nil {
                c <- pipeErr(err)
@@ -125,17 +126,27 @@ func dump(n *Node) (string, error) {
 }
 
 func TestParser(t *testing.T) {
-       // TODO(nigeltao): Process all the .dat files, not just the first one.
-       filenames := []string{
-               "tests1.dat",
+       testFiles := []struct {
+               filename string
+               // n is the number of test cases to run from that file.
+               // -1 means all test cases.
+               n int
+       }{
+               // TODO(nigeltao): Process all the test cases from all the .dat files.
+               {"tests1.dat", 92},
+               {"tests2.dat", 0},
+               {"tests3.dat", 0},
        }
-       for _, filename := range filenames {
+       for _, tf := range testFiles {
                rc := make(chan io.Reader)
-               go readDat(filename, rc)
-               // TODO(nigeltao): Process all test cases, not just a subset.
-               for i := 0; i < 80; i++ {
+               go readDat(tf.filename, rc)
+               for i := 0; i != tf.n; i++ {
                        // Parse the #data section.
-                       b, err := ioutil.ReadAll(<-rc)
+                       dataReader := <-rc
+                       if dataReader == nil {
+                               break
+                       }
+                       b, err := ioutil.ReadAll(dataReader)
                        if err != nil {
                                t.Fatal(err)
                        }
@@ -158,7 +169,7 @@ func TestParser(t *testing.T) {
                                t.Fatal(err)
                        }
                        if want := string(b); got != want {
-                               t.Errorf("%s test #%d %q, got vs want:\n----\n%s----\n%s----", filename, i, text, got, want)
+                               t.Errorf("%s test #%d %q, got vs want:\n----\n%s----\n%s----", tf.filename, i, text, got, want)
                                continue
                        }
                        if renderTestBlacklist[text] {
@@ -178,10 +189,16 @@ func TestParser(t *testing.T) {
                                t.Fatal(err)
                        }
                        if got != got1 {
-                               t.Errorf("%s test #%d %q, got vs got1:\n----\n%s----\n%s----", filename, i, text, got, got1)
+                               t.Errorf("%s test #%d %q, got vs got1:\n----\n%s----\n%s----", tf.filename, i, text, got, got1)
                                continue
                        }
                }
+               // Drain any untested cases for the test file.
+               for r := range rc {
+                       if _, err := ioutil.ReadAll(r); err != nil {
+                               t.Fatal(err)
+                       }
+               }
        }
 }
 
@@ -193,6 +210,7 @@ var renderTestBlacklist = map[string]bool{
        // The second <a> will be reparented to the first <table>'s parent. This
        // results in an <a> whose parent is an <a>, which is not 'well-formed'.
        `<a><table><td><a><table></table><a></tr><a></table><b>X</b>C<a>Y`: true,
-       // The second <a> will be reparented, similar to the case above.
+       // More cases of <a> being reparented:
        `<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe`: true,
+       `<a><table><a></table><p><a><div><a>`:                                     true,
 }
similarity index 99%
rename from libgo/go/exp/template/html/attr.go
rename to libgo/go/html/template/attr.go
index 6a36c7b..3ea0288 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "strings"
similarity index 98%
rename from libgo/go/exp/template/html/clone.go
rename to libgo/go/html/template/clone.go
index 803a64d..d0d8ea4 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
-       "template/parse"
+       "text/template/parse"
 )
 
 // clone clones a template Node.
similarity index 96%
rename from libgo/go/exp/template/html/clone_test.go
rename to libgo/go/html/template/clone_test.go
index d915425..ed1698a 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
-       "template"
-       "template/parse"
        "testing"
+       "text/template"
+       "text/template/parse"
 )
 
 func TestClone(t *testing.T) {
@@ -56,7 +56,7 @@ func TestClone(t *testing.T) {
                        t.Errorf("want %q, got %q", want, got)
                }
 
-               d, err := Escape(d)
+               err := escape(d)
                if err != nil {
                        t.Errorf("%q: failed to escape: %s", test.input, err)
                        continue
similarity index 99%
rename from libgo/go/exp/template/html/content.go
rename to libgo/go/html/template/content.go
index dcaff8c..d720d4b 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "fmt"
similarity index 98%
rename from libgo/go/exp/template/html/content_test.go
rename to libgo/go/html/template/content_test.go
index 033dee1..c96a521 100644 (file)
@@ -2,12 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
        "strings"
-       "template"
        "testing"
 )
 
@@ -203,7 +202,7 @@ func TestTypedContent(t *testing.T) {
        }
 
        for _, test := range tests {
-               tmpl := template.Must(Escape(template.Must(template.New("x").Parse(test.input))))
+               tmpl := Must(New("x").Parse(test.input))
                pre := strings.Index(test.input, "{{.}}")
                post := len(test.input) - (pre + 5)
                var b bytes.Buffer
similarity index 99%
rename from libgo/go/exp/template/html/context.go
rename to libgo/go/html/template/context.go
index c44df4d..7202221 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "fmt"
similarity index 99%
rename from libgo/go/exp/template/html/css.go
rename to libgo/go/html/template/css.go
index c26ae78..b0a2f01 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
        "fmt"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // endsWithCSSKeyword returns whether b ends with an ident that
similarity index 99%
rename from libgo/go/exp/template/html/css_test.go
rename to libgo/go/html/template/css_test.go
index b3b83e8..0d94bdc 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "strconv"
similarity index 71%
rename from libgo/go/exp/template/html/doc.go
rename to libgo/go/html/template/doc.go
index a9b78ca..0324c9c 100644 (file)
@@ -3,65 +3,61 @@
 // license that can be found in the LICENSE file.
 
 /*
-Package html is a specialization of package template that automates the
-construction of HTML output that is safe against code injection.
+Package template (html/template) is a specialization of package text/template
+that automates the construction of HTML output that is safe against code
+injection.
 
 
 Introduction
 
-To use this package, invoke the standard template package to parse a template
-set, and then use this package’s EscapeSet function to secure the set.
-The arguments to EscapeSet are the template set and the names of all templates
-that will be passed to Execute.
+This package wraps package template so you can use the standard template API
+to parse and execute templates.
 
     set, err := new(template.Set).Parse(...)
-    set, err = EscapeSet(set, "templateName0", ...)
+    // Error checking elided
+    err = set.Execute(out, "Foo", data)
 
-If successful, set will now be injection-safe. Otherwise, the returned set will
-be nil and an error, described below, will explain the problem.
+If successful, set will now be injection-safe. Otherwise, err is an error
+defined in the docs for ErrorCode.
 
-The template names do not need to include helper templates but should include
-all names x used thus:
-
-    set.Execute(out, x, ...)
-
-EscapeSet modifies the named templates in place to treat data values as plain
-text safe for embedding in an HTML document. The escaping is contextual, so
-actions can appear within JavaScript, CSS, and URI contexts without introducing'hazards.
+HTML templates treat data values as plain text which should be encoded so they
+can be safely embedded in an HTML document. The escaping is contextual, so
+actions can appear within JavaScript, CSS, and URI contexts.
 
 The security model used by this package assumes that template authors are
 trusted, while Execute's data parameter is not. More details are provided below.
 
 Example
 
-    tmpls, err := new(template.Set).Parse(`{{define "t'}}Hello, {{.}}!{{end}}`)
-
-when used by itself
-
-    tmpls.Execute(out, "t", "<script>alert('you have been pwned')</script>")
+    import "template"
+    ...
+    t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
+    err = t.Execute(out, "T", "<script>alert('you have been pwned')</script>")
 
 produces
 
     Hello, <script>alert('you have been pwned')</script>!
 
-but after securing with EscapeSet like this,
+but with contextual autoescaping,
 
-    tmpls, err := EscapeSet(tmpls, "t")
-    tmpls.Execute(out, "t", ...)
+    import "html/template"
+    ...
+    t, err := (&template.Set{}).Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
+    err = t.Execute(out, "T", "<script>alert('you have been pwned')</script>")
 
-produces the safe, escaped HTML output
+produces safe, escaped HTML output
 
     Hello, &lt;script&gt;alert('you have been pwned')&lt;/script&gt;!
 
 
 Contexts
 
-EscapeSet understands HTML, CSS, JavaScript, and URIs. It adds sanitizing
+This package understands HTML, CSS, JavaScript, and URIs. It adds sanitizing
 functions to each simple action pipeline, so given the excerpt
 
   <a href="/search?q={{.}}">{{.}}</a>
 
-EscapeSet will rewrite each {{.}} to add escaping functions where necessary,
+At parse time each {{.}} is overwritten to add escaping functions as necessary,
 in this case,
 
   <a href="/search?q={{. | urlquery}}">{{. | html}}</a>
@@ -134,8 +130,8 @@ embedding in JavaScript contexts.
 
 Typed Strings
 
-By default, EscapeSet assumes all pipelines produce a plain text string. It
-adds escaping pipeline stages necessary to correctly and safely embed that
+By default, this package assumes that all pipelines produce a plain text string.
+It adds escaping pipeline stages necessary to correctly and safely embed that
 plain text string in the appropriate context.
 
 When a data value is not plain text, you can make sure it is not over-escaped
@@ -183,8 +179,8 @@ injecting the template output into a page and all code specified by the
 template author should run as a result of the same."
 
 Least Surprise Property
-"A developer (or code reviewer) familiar with HTML, CSS, and JavaScript;
-who knows that EscapeSet is applied should be able to look at a {{.}}
+"A developer (or code reviewer) familiar with HTML, CSS, and JavaScript, who
+knows that contextual autoescaping happens should be able to look at a {{.}}
 and correctly infer what sanitization happens."
 */
-package html
+package template
similarity index 75%
rename from libgo/go/exp/template/html/error.go
rename to libgo/go/html/template/error.go
index 22fca9e..9622d7e 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "fmt"
@@ -75,12 +75,12 @@ const (
        // Example:
        //   {{if .C}}<a href="{{end}}{{.X}}
        // Discussion:
-       //   EscapeSet statically examines each possible path when it encounters
-       //   {{if}}, {{range}}, or {{with}} to escape any following pipelines.
+       //   Package html/template statically examines each path through an
+       //   {{if}}, {{range}}, or {{with}} to escape any following pipelines.
        //   The example is ambiguous since {{.X}} might be an HTML text node,
-       //   or a URL prefix in an HTML attribute. EscapeSet needs to understand
-       //   the context of {{.X}} to escape it, but that depends on the
-       //   run-time value of {{.C}}.
+       //   or a URL prefix in an HTML attribute. The context of {{.X}} is
+       //   used to figure out how to escape it, but that context depends on
+       //   the run-time value of {{.C}} which is not statically known.
        //
        //   The problem is usually something like missing quotes or angle
        //   brackets, or can be avoided by refactoring to put the two contexts
@@ -95,44 +95,28 @@ const (
        //   <div title="no close quote>
        //   <script>f()
        // Discussion:
-       //   EscapeSet assumes the ouput is a DocumentFragment of HTML.
+       //   Executed templates should produce a DocumentFragment of HTML.
        //   Templates that end without closing tags will trigger this error.
-       //   Templates that produce incomplete Fragments should not be named
-       //   in the call to EscapeSet.
-       //
-       // If you have a helper template in your set that is not meant to
-       // produce a document fragment, then do not pass its name to
-       // EscapeSet(set, ...names).
+       //   Templates that should not be used in an HTML context or that
+       //   produce incomplete Fragments should not be executed directly.
        //
        //   {{define "main"}} <script>{{template "helper"}}</script> {{end}}
        //   {{define "helper"}} document.write(' <div title=" ') {{end}}
        // 
-       // "helper" does not produce a valid document fragment, though it does
-       // produce a valid JavaScript Program.
+       //   "helper" does not produce a valid document fragment, so should
+       //   not be Executed directly.
        ErrEndContext
 
-       // ErrNoNames: "must specify names of top level templates"
-       // 
-       //   EscapeSet does not assume that all templates in a set produce HTML.
-       //   Some may be helpers that produce snippets of other languages.
-       //   Passing in no template names is most likely an error,
-       //   so EscapeSet(set) will panic.
-       //   If you call EscapeSet with a slice of names, guard it with len:
-       // 
-       //     if len(names) != 0 {
-       //       set, err := EscapeSet(set, ...names)
-       //     }
-       ErrNoNames
-
        // ErrNoSuchTemplate: "no such template ..."
        // Examples:
        //   {{define "main"}}<div {{template "attrs"}}>{{end}}
        //   {{define "attrs"}}href="{{.URL}}"{{end}}
        // Discussion:
-       //   EscapeSet looks through template calls to compute the context.
+       //   Package html/template looks through template calls to compute the
+       //   context.
        //   Here the {{.URL}} in "attrs" must be treated as a URL when called
-       //   from "main", but if "attrs" is not in set when
-       //   EscapeSet(&set, "main") is called, this error will arise.
+       //   from "main", but you will get this error if "attrs" is not defined
+       //   when "main" is parsed.
        ErrNoSuchTemplate
 
        // ErrOutputContext: "cannot compute output context for template ..."
@@ -151,17 +135,18 @@ const (
        // Example:
        //     <script>var pattern = /foo[{{.Chars}}]/</script>
        // Discussion:
-       //   EscapeSet does not support interpolation into regular expression
-       //   literal character sets.
+       //   Package html/template does not support interpolation into regular
+       //   expression literal character sets.
        ErrPartialCharset
 
        // ErrPartialEscape: "unfinished escape sequence in ..."
        // Example:
        //   <script>alert("\{{.X}}")</script>
        // Discussion:
-       //   EscapeSet does not support actions following a backslash.
+       //   Package html/template does not support actions following a
+       //   backslash.
        //   This is usually an error and there are better solutions; for
-       //   our example
+       //   example
        //     <script>alert("{{.X}}")</script>
        //   should work, and if {{.X}} is a partial escape sequence such as
        //   "xA0", mark the whole sequence as safe content: JSStr(`\xA0`)
@@ -169,16 +154,15 @@ const (
 
        // ErrRangeLoopReentry: "on range loop re-entry: ..."
        // Example:
-       //   {{range .}}<p class={{.}}{{end}}
+       //   <script>var x = [{{range .}}'{{.}},{{end}}]</script>
        // Discussion:
        //   If an iteration through a range would cause it to end in a
        //   different context than an earlier pass, there is no single context.
-       //   In the example, the <p> tag is missing a '>'.
-       //   EscapeSet cannot tell whether {{.}} is meant to be an HTML class or
-       //   the content of a broken <p> element and complains because the
-       //   second iteration would produce something like
+       //   In the example, there is missing a quote, so it is not clear
+       //   whether {{.}} is meant to be inside a JS string or in a JS value
+       //   context.  The second iteration would produce something like
        // 
-       //     <p class=foo<p class=bar
+       //     <script>var x = ['firstValue,'secondValue]</script>
        ErrRangeLoopReentry
 
        // ErrSlashAmbig: '/' could start a division or regexp.
similarity index 96%
rename from libgo/go/exp/template/html/escape.go
rename to libgo/go/html/template/escape.go
index 28615a9..8ac07ea 100644 (file)
@@ -2,41 +2,33 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
        "fmt"
        "html"
-       "template"
-       "template/parse"
+       "text/template"
+       "text/template/parse"
 )
 
-// Escape rewrites each action in the template to guarantee that the output is
+// escape rewrites each action in the template to guarantee that the output is
 // properly escaped.
-func Escape(t *template.Template) (*template.Template, error) {
+func escape(t *template.Template) error {
        var s template.Set
        s.Add(t)
-       if _, err := EscapeSet(&s, t.Name()); err != nil {
-               return nil, err
-       }
+       return escapeSet(&s, t.Name())
        // TODO: if s contains cloned dependencies due to self-recursion
        // cross-context, error out.
-       return t, nil
 }
 
-// EscapeSet rewrites the template set to guarantee that the output of any of
+// escapeSet rewrites the template set to guarantee that the output of any of
 // the named templates is properly escaped.
 // Names should include the names of all templates that might be Executed but
 // need not include helper templates.
 // If no error is returned, then the named templates have been modified. 
 // Otherwise the named templates have been rendered unusable.
-func EscapeSet(s *template.Set, names ...string) (*template.Set, error) {
-       if len(names) == 0 {
-               // TODO: Maybe add a method to Set to enumerate template names
-               // and use those instead.
-               return nil, &Error{ErrNoNames, "", 0, "must specify names of top level templates"}
-       }
+func escapeSet(s *template.Set, names ...string) error {
        e := newEscaper(s)
        for _, name := range names {
                c, _ := e.escapeTree(context{}, name, 0)
@@ -53,11 +45,11 @@ func EscapeSet(s *template.Set, names ...string) (*template.Set, error) {
                                        t.Tree = nil
                                }
                        }
-                       return nil, err
+                       return err
                }
        }
        e.commit()
-       return s, nil
+       return nil
 }
 
 // funcMap maps command names to functions that render their inputs safe.
@@ -509,7 +501,7 @@ func (e *escaper) escapeTree(c context, name string, line int) (context, string)
                }, dname
        }
        if dname != name {
-               // Use any template derived during an earlier call to EscapeSet
+               // Use any template derived during an earlier call to escapeSet
                // with different top level templates, or clone if necessary.
                dt := e.template(dname)
                if dt == nil {
@@ -675,7 +667,7 @@ func contextAfterText(c context, s []byte) (context, int) {
                // http://www.w3.org/TR/html5/tokenization.html#attribute-value-unquoted-state
                // lists the runes below as error characters.
                // Error out because HTML parsers may differ on whether
-               // "<a id= onclick=f("     ends inside id's or onchange's value,
+               // "<a id= onclick=f("     ends inside id's or onclick's value,
                // "<a class=`foo "        ends inside a value,
                // "<a style=font:'Arial'" needs open-quote fixup.
                // IE treats '`' as a quotation character.
similarity index 96%
rename from libgo/go/exp/template/html/escape_test.go
rename to libgo/go/html/template/escape_test.go
index 20599bc..d8bfa32 100644 (file)
@@ -2,16 +2,16 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
+       "encoding/json"
        "fmt"
-       "json"
        "strings"
-       "template"
-       "template/parse"
        "testing"
+       "text/template"
+       "text/template/parse"
 )
 
 type badMarshaler struct{}
@@ -224,7 +224,7 @@ func TestEscape(t *testing.T) {
                {
                        "badMarshaller",
                        `<button onclick='alert(1/{{.B}}in numbers)'>`,
-                       `<button onclick='alert(1/ /* json: error calling MarshalJSON for type *html.badMarshaler: invalid character &#39;f&#39; looking for beginning of object key string */null in numbers)'>`,
+                       `<button onclick='alert(1/ /* json: error calling MarshalJSON for type *template.badMarshaler: invalid character &#39;f&#39; looking for beginning of object key string */null in numbers)'>`,
                },
                {
                        "jsMarshaller",
@@ -651,14 +651,14 @@ func TestEscape(t *testing.T) {
        }
 
        for _, test := range tests {
-               tmpl := template.New(test.name)
+               tmpl := New(test.name)
                // TODO: Move noescape into template/func.go
                tmpl.Funcs(template.FuncMap{
                        "noescape": func(a ...interface{}) string {
                                return fmt.Sprint(a...)
                        },
                })
-               tmpl = template.Must(Escape(template.Must(tmpl.Parse(test.input))))
+               tmpl = Must(tmpl.Parse(test.input))
                b := new(bytes.Buffer)
                if err := tmpl.Execute(b, data); err != nil {
                        t.Errorf("%s: template execution failed: %s", test.name, err)
@@ -792,17 +792,13 @@ func TestEscapeSet(t *testing.T) {
        }}
 
        for _, test := range tests {
-               var s template.Set
-               for name, src := range test.inputs {
-                       t := template.New(name)
-                       t.Funcs(fns)
-                       s.Add(template.Must(t.Parse(src)))
+               source := ""
+               for name, body := range test.inputs {
+                       source += fmt.Sprintf("{{define %q}}%s{{end}} ", name, body)
                }
+               s := &Set{}
                s.Funcs(fns)
-               if _, err := EscapeSet(&s, "main"); err != nil {
-                       t.Errorf("%s for input:\n%v", err, test.inputs)
-                       continue
-               }
+               s.Parse(source)
                var b bytes.Buffer
 
                if err := s.Execute(&b, "main", data); err != nil {
@@ -962,17 +958,19 @@ func TestErrors(t *testing.T) {
 
        for _, test := range tests {
                var err error
+               buf := new(bytes.Buffer)
                if strings.HasPrefix(test.input, "{{define") {
-                       var s template.Set
-                       _, err = s.Parse(test.input)
-                       if err != nil {
-                               t.Errorf("Failed to parse %q: %s", test.input, err)
-                               continue
+                       var s *Set
+                       s, err = (&Set{}).Parse(test.input)
+                       if err == nil {
+                               err = s.Execute(buf, "z", nil)
                        }
-                       _, err = EscapeSet(&s, "z")
                } else {
-                       tmpl := template.Must(template.New("z").Parse(test.input))
-                       _, err = Escape(tmpl)
+                       var t *Template
+                       t, err = New("z").Parse(test.input)
+                       if err == nil {
+                               err = t.Execute(buf, nil)
+                       }
                }
                var got string
                if err != nil {
@@ -1548,33 +1546,29 @@ func TestEnsurePipelineContains(t *testing.T) {
        }
 }
 
-func expectExecuteFailure(t *testing.T, b *bytes.Buffer, err error) {
-       if err != nil {
-               if b.Len() != 0 {
-                       t.Errorf("output on buffer: %q", b.String())
-               }
-       } else {
-               t.Errorf("unescaped template executed")
-       }
-}
-
 func TestEscapeErrorsNotIgnorable(t *testing.T) {
        var b bytes.Buffer
-       tmpl := template.Must(template.New("dangerous").Parse("<a"))
-       Escape(tmpl)
+       tmpl, _ := New("dangerous").Parse("<a")
        err := tmpl.Execute(&b, nil)
-       expectExecuteFailure(t, &b, err)
+       if err == nil {
+               t.Errorf("Expected error")
+       } else if b.Len() != 0 {
+               t.Errorf("Emitted output despite escaping failure")
+       }
 }
 
 func TestEscapeSetErrorsNotIgnorable(t *testing.T) {
-       s, err := (&template.Set{}).Parse(`{{define "t"}}<a{{end}}`)
+       var b bytes.Buffer
+       s, err := (&Set{}).Parse(`{{define "t"}}<a{{end}}`)
        if err != nil {
                t.Errorf("failed to parse set: %q", err)
        }
-       EscapeSet(s, "t")
-       var b bytes.Buffer
        err = s.Execute(&b, "t", nil)
-       expectExecuteFailure(t, &b, err)
+       if err == nil {
+               t.Errorf("Expected error")
+       } else if b.Len() != 0 {
+               t.Errorf("Emitted output despite escaping failure")
+       }
 }
 
 func TestRedundantFuncs(t *testing.T) {
@@ -1612,7 +1606,7 @@ func TestRedundantFuncs(t *testing.T) {
 }
 
 func BenchmarkEscapedExecute(b *testing.B) {
-       tmpl := template.Must(Escape(template.Must(template.New("t").Parse(`<a onclick="alert('{{.}}')">{{.}}</a>`))))
+       tmpl := Must(New("t").Parse(`<a onclick="alert('{{.}}')">{{.}}</a>`))
        var buf bytes.Buffer
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
similarity index 99%
rename from libgo/go/exp/template/html/html.go
rename to libgo/go/html/template/html.go
index 92d8f41..7b77d65 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
        "fmt"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 // htmlNospaceEscaper escapes for inclusion in unquoted attribute values.
similarity index 99%
rename from libgo/go/exp/template/html/html_test.go
rename to libgo/go/html/template/html_test.go
index e178d0f..b9b9703 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "html"
similarity index 99%
rename from libgo/go/exp/template/html/js.go
rename to libgo/go/html/template/js.go
index 22be418..68c53e5 100644 (file)
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
+       "encoding/json"
        "fmt"
-       "json"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 // nextJSCtx returns the context that determines whether a slash after the
similarity index 99%
rename from libgo/go/exp/template/html/js_test.go
rename to libgo/go/html/template/js_test.go
index e776405..311e1d2 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
diff --git a/libgo/go/html/template/template.go b/libgo/go/html/template/template.go
new file mode 100644 (file)
index 0000000..4733429
--- /dev/null
@@ -0,0 +1,239 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package template
+
+import (
+       "fmt"
+       "io"
+       "path/filepath"
+       "text/template"
+)
+
+// Set is a specialized template.Set that produces a safe HTML document
+// fragment.
+type Set struct {
+       escaped map[string]bool
+       template.Set
+}
+
+// Template is a specialized template.Template that produces a safe HTML
+// document fragment.
+type Template struct {
+       escaped bool
+       *template.Template
+}
+
+// Execute applies the named template to the specified data object, writing
+// the output to wr.
+func (s *Set) Execute(wr io.Writer, name string, data interface{}) error {
+       if !s.escaped[name] {
+               if err := escapeSet(&s.Set, name); err != nil {
+                       return err
+               }
+               if s.escaped == nil {
+                       s.escaped = make(map[string]bool)
+               }
+               s.escaped[name] = true
+       }
+       return s.Set.Execute(wr, name, data)
+}
+
+// Parse parses a string into a set of named templates.  Parse may be called
+// multiple times for a given set, adding the templates defined in the string
+// to the set.  If a template is redefined, the element in the set is
+// overwritten with the new definition.
+func (set *Set) Parse(src string) (*Set, error) {
+       set.escaped = nil
+       s, err := set.Set.Parse(src)
+       if err != nil {
+               return nil, err
+       }
+       if s != &(set.Set) {
+               panic("allocated new set")
+       }
+       return set, nil
+}
+
+// Parse parses the template definition string to construct an internal
+// representation of the template for execution.
+func (tmpl *Template) Parse(src string) (*Template, error) {
+       tmpl.escaped = false
+       t, err := tmpl.Template.Parse(src)
+       if err != nil {
+               return nil, err
+       }
+       tmpl.Template = t
+       return tmpl, nil
+}
+
+// Execute applies a parsed template to the specified data object,
+// writing the output to wr.
+func (t *Template) Execute(wr io.Writer, data interface{}) error {
+       if !t.escaped {
+               if err := escape(t.Template); err != nil {
+                       return err
+               }
+               t.escaped = true
+       }
+       return t.Template.Execute(wr, data)
+}
+
+// New allocates a new HTML template with the given name.
+func New(name string) *Template {
+       return &Template{false, template.New(name)}
+}
+
+// Must panics if err is non-nil in the same way as template.Must.
+func Must(t *Template, err error) *Template {
+       t.Template = template.Must(t.Template, err)
+       return t
+}
+
+// ParseFile creates a new Template and parses the template definition from
+// the named file.  The template name is the base name of the file.
+func ParseFile(filename string) (*Template, error) {
+       t, err := template.ParseFile(filename)
+       if err != nil {
+               return nil, err
+       }
+       return &Template{false, t}, nil
+}
+
+// ParseFile reads the template definition from a file and parses it to
+// construct an internal representation of the template for execution.
+// The returned template will be nil if an error occurs.
+func (tmpl *Template) ParseFile(filename string) (*Template, error) {
+       t, err := tmpl.Template.ParseFile(filename)
+       if err != nil {
+               return nil, err
+       }
+       tmpl.Template = t
+       return tmpl, nil
+}
+
+// SetMust panics if the error is non-nil just like template.SetMust.
+func SetMust(s *Set, err error) *Set {
+       if err != nil {
+               template.SetMust(&(s.Set), err)
+       }
+       return s
+}
+
+// ParseFiles parses the named files into a set of named templates.
+// Each file must be parseable by itself.
+// If an error occurs, parsing stops and the returned set is nil.
+func (set *Set) ParseFiles(filenames ...string) (*Set, error) {
+       s, err := set.Set.ParseFiles(filenames...)
+       if err != nil {
+               return nil, err
+       }
+       if s != &(set.Set) {
+               panic("allocated new set")
+       }
+       return set, nil
+}
+
+// ParseSetFiles creates a new Set and parses the set definition from the
+// named files. Each file must be individually parseable.
+func ParseSetFiles(filenames ...string) (*Set, error) {
+       set := new(Set)
+       s, err := set.Set.ParseFiles(filenames...)
+       if err != nil {
+               return nil, err
+       }
+       if s != &(set.Set) {
+               panic("allocated new set")
+       }
+       return set, nil
+}
+
+// ParseGlob parses the set definition from the files identified by the
+// pattern. The pattern is processed by filepath.Glob and must match at
+// least one file.
+// If an error occurs, parsing stops and the returned set is nil.
+func (s *Set) ParseGlob(pattern string) (*Set, error) {
+       filenames, err := filepath.Glob(pattern)
+       if err != nil {
+               return nil, err
+       }
+       if len(filenames) == 0 {
+               return nil, fmt.Errorf("pattern matches no files: %#q", pattern)
+       }
+       return s.ParseFiles(filenames...)
+}
+
+// ParseSetGlob creates a new Set and parses the set definition from the
+// files identified by the pattern. The pattern is processed by filepath.Glob
+// and must match at least one file.
+func ParseSetGlob(pattern string) (*Set, error) {
+       set, err := new(Set).ParseGlob(pattern)
+       if err != nil {
+               return nil, err
+       }
+       return set, nil
+}
+
+// Functions and methods to parse stand-alone template files into a set.
+
+// ParseTemplateFiles parses the named template files and adds them to the set
+// in the same way as template.ParseTemplateFiles but ensures that templates
+// with upper-case names are contextually-autoescaped.
+func (set *Set) ParseTemplateFiles(filenames ...string) (*Set, error) {
+       s, err := set.Set.ParseTemplateFiles(filenames...)
+       if err != nil {
+               return nil, err
+       }
+       if s != &(set.Set) {
+               panic("new set allocated")
+       }
+       return set, nil
+}
+
+// ParseTemplateGlob parses the template files matched by the
+// patern and adds them to the set. Each template will be named
+// the base name of its file.
+// Unlike with ParseGlob, each file should be a stand-alone template
+// definition suitable for Template.Parse (not Set.Parse); that is, the
+// file does not contain {{define}} clauses. ParseTemplateGlob is
+// therefore equivalent to calling the ParseFile function to create
+// individual templates, which are then added to the set.
+// Each file must be parseable by itself.
+// If an error occurs, parsing stops and the returned set is nil.
+func (s *Set) ParseTemplateGlob(pattern string) (*Set, error) {
+       filenames, err := filepath.Glob(pattern)
+       if err != nil {
+               return nil, err
+       }
+       return s.ParseTemplateFiles(filenames...)
+}
+
+// ParseTemplateFiles creates a set by parsing the named files,
+// each of which defines a single template. Each template will be
+// named the base name of its file.
+// Unlike with ParseFiles, each file should be a stand-alone template
+// definition suitable for Template.Parse (not Set.Parse); that is, the
+// file does not contain {{define}} clauses. ParseTemplateFiles is
+// therefore equivalent to calling the ParseFile function to create
+// individual templates, which are then added to the set.
+// Each file must be parseable by itself. Parsing stops if an error is
+// encountered.
+func ParseTemplateFiles(filenames ...string) (*Set, error) {
+       return new(Set).ParseTemplateFiles(filenames...)
+}
+
+// ParseTemplateGlob creates a set by parsing the files matched
+// by the pattern, each of which defines a single template. The pattern
+// is processed by filepath.Glob and must match at least one file. Each
+// template will be named the base name of its file.
+// Unlike with ParseGlob, each file should be a stand-alone template
+// definition suitable for Template.Parse (not Set.Parse); that is, the
+// file does not contain {{define}} clauses. ParseTemplateGlob is
+// therefore equivalent to calling the ParseFile function to create
+// individual templates, which are then added to the set.
+// Each file must be parseable by itself. Parsing stops if an error is
+// encountered.
+func ParseTemplateGlob(pattern string) (*Set, error) {
+       return new(Set).ParseTemplateGlob(pattern)
+}
similarity index 99%
rename from libgo/go/exp/template/html/transition.go
rename to libgo/go/html/template/transition.go
index 49a1451..96a4f66 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
similarity index 99%
rename from libgo/go/exp/template/html/url.go
rename to libgo/go/html/template/url.go
index 5b19df0..454c791 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "bytes"
similarity index 99%
rename from libgo/go/exp/template/html/url_test.go
rename to libgo/go/html/template/url_test.go
index b846231..5182e9d 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package html
+package template
 
 import (
        "testing"
diff --git a/libgo/go/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat b/libgo/go/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat
new file mode 100644 (file)
index 0000000..a5ebb1e
Binary files /dev/null and b/libgo/go/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat differ
index c5b8a1c..2c13822 100644 (file)
@@ -123,7 +123,7 @@ type Tokenizer struct {
        // for tt != Error && err != nil to hold: this means that Next returned a
        // valid token but the subsequent Next call will return an error token.
        // For example, if the HTML text input was just "plain", then the first
-       // Next call would set z.err to os.EOF but return a TextToken, and all
+       // Next call would set z.err to io.EOF but return a TextToken, and all
        // subsequent Next calls would return an ErrorToken.
        // err is never reset. Once it becomes non-nil, it stays non-nil.
        err error
@@ -149,9 +149,9 @@ type Tokenizer struct {
        textIsRaw bool
 }
 
-// Error returns the error associated with the most recent ErrorToken token.
-// This is typically os.EOF, meaning the end of tokenization.
-func (z *Tokenizer) Error() error {
+// Err returns the error associated with the most recent ErrorToken token.
+// This is typically io.EOF, meaning the end of tokenization.
+func (z *Tokenizer) Err() error {
        if z.tt != ErrorToken {
                return nil
        }
index 76cc9f8..61d4e67 100644 (file)
@@ -427,7 +427,7 @@ loop:
                if tt.golden != "" {
                        for i, s := range strings.Split(tt.golden, "$") {
                                if z.Next() == ErrorToken {
-                                       t.Errorf("%s token %d: want %q got error %v", tt.desc, i, s, z.Error())
+                                       t.Errorf("%s token %d: want %q got error %v", tt.desc, i, s, z.Err())
                                        continue loop
                                }
                                actual := z.Token().String()
@@ -438,8 +438,8 @@ loop:
                        }
                }
                z.Next()
-               if z.Error() != io.EOF {
-                       t.Errorf("%s: want EOF got %q", tt.desc, z.Error())
+               if z.Err() != io.EOF {
+                       t.Errorf("%s: want EOF got %q", tt.desc, z.Err())
                }
        }
 }
@@ -543,8 +543,8 @@ loop:
                tt := z.Next()
                switch tt {
                case ErrorToken:
-                       if z.Error() != io.EOF {
-                               t.Error(z.Error())
+                       if z.Err() != io.EOF {
+                               t.Error(z.Err())
                        }
                        break loop
                case TextToken:
diff --git a/libgo/go/http/dump.go b/libgo/go/http/dump.go
deleted file mode 100644 (file)
index b85feea..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package http
-
-import (
-       "bytes"
-       "io"
-       "io/ioutil"
-)
-
-// One of the copies, say from b to r2, could be avoided by using a more
-// elaborate trick where the other copy is made during Request/Response.Write.
-// This would complicate things too much, given that these functions are for
-// debugging only.
-func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) {
-       var buf bytes.Buffer
-       if _, err = buf.ReadFrom(b); err != nil {
-               return nil, nil, err
-       }
-       if err = b.Close(); err != nil {
-               return nil, nil, err
-       }
-       return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewBuffer(buf.Bytes())), nil
-}
-
-// DumpRequest returns the wire representation of req,
-// optionally including the request body, for debugging.
-// DumpRequest is semantically a no-op, but in order to
-// dump the body, it reads the body data into memory and
-// changes req.Body to refer to the in-memory copy.
-// The documentation for Request.Write details which fields
-// of req are used.
-func DumpRequest(req *Request, body bool) (dump []byte, err error) {
-       var b bytes.Buffer
-       save := req.Body
-       if !body || req.Body == nil {
-               req.Body = nil
-       } else {
-               save, req.Body, err = drainBody(req.Body)
-               if err != nil {
-                       return
-               }
-       }
-       err = req.dumpWrite(&b)
-       req.Body = save
-       if err != nil {
-               return
-       }
-       dump = b.Bytes()
-       return
-}
-
-// DumpResponse is like DumpRequest but dumps a response.
-func DumpResponse(resp *Response, body bool) (dump []byte, err error) {
-       var b bytes.Buffer
-       save := resp.Body
-       savecl := resp.ContentLength
-       if !body || resp.Body == nil {
-               resp.Body = nil
-               resp.ContentLength = 0
-       } else {
-               save, resp.Body, err = drainBody(resp.Body)
-               if err != nil {
-                       return
-               }
-       }
-       err = resp.Write(&b)
-       resp.Body = save
-       resp.ContentLength = savecl
-       if err != nil {
-               return
-       }
-       dump = b.Bytes()
-       return
-}
index ad56865..58bd781 100644 (file)
@@ -9,8 +9,8 @@ package bmp
 
 import (
        "errors"
-       "image/color"
        "image"
+       "image/color"
        "io"
 )
 
index 72cec93..28e8732 100644 (file)
@@ -10,7 +10,7 @@ import (
        "image/color"
        "image/png"
        "io/ioutil"
-       "rand"
+       "math/rand"
        "os"
        "testing"
 )
index f6b2f00..df3e449 100644 (file)
@@ -6,7 +6,7 @@ package suffixarray
 
 import (
        "bytes"
-       "rand"
+       "math/rand"
        "regexp"
        "sort"
        "strings"
index bb439f0..0de5cc3 100644 (file)
@@ -5,10 +5,10 @@
 package io_test
 
 import (
-       . "io"
        "bytes"
        "crypto/sha1"
        "fmt"
+       . "io"
        "strings"
        "testing"
 )
index 55b7e9e..b5368af 100644 (file)
@@ -16,10 +16,10 @@ import (
        "bytes"
        "fmt"
        "io"
-       "runtime"
        "os"
-       "time"
+       "runtime"
        "sync"
+       "time"
 )
 
 // These flags define which text to prefix to each log entry generated by the Logger.
index b540b17..7e63023 100644 (file)
@@ -7,7 +7,6 @@ package math_test
 import (
        "fmt"
        . "math"
-       "runtime"
        "testing"
 )
 
@@ -160,6 +159,19 @@ var cos = []float64{
        -2.517729313893103197176091e-01,
        -7.39241351595676573201918e-01,
 }
+// Results for 100000 * Pi + vf[i]
+var cosLarge = []float64{
+       2.634752141185559426744e-01,
+       1.14855126055543100712e-01,
+       9.61912973266488928113e-01,
+       2.9381411499556122552e-01,
+       -9.777138189880161924641e-01,
+       -9.76930413445147608049e-01,
+       4.940088097314976789841e-01,
+       -9.15658690217517835002e-01,
+       -2.51772931436786954751e-01,
+       -7.3924135157173099849e-01,
+}
 var cosh = []float64{
        7.2668796942212842775517446e+01,
        1.1479413465659254502011135e+03,
@@ -502,6 +514,19 @@ var sin = []float64{
        9.6778633541687993721617774e-01,
        -6.734405869050344734943028e-01,
 }
+// Results for 100000 * Pi + vf[i]
+var sinLarge = []float64{
+       -9.646661658548936063912e-01,
+       9.933822527198506903752e-01,
+       -2.7335587036246899796e-01,
+       9.55862576853689321268e-01,
+       -2.099421066862688873691e-01,
+       2.13557878070308981163e-01,
+       -8.694568970959221300497e-01,
+       4.01956668098863248917e-01,
+       9.67786335404528727927e-01,
+       -6.7344058693131973066e-01,
+}
 var sinh = []float64{
        7.2661916084208532301448439e+01,
        1.1479409110035194500526446e+03,
@@ -538,6 +563,19 @@ var tan = []float64{
        -3.843885560201130679995041e+00,
        9.10988793377685105753416e-01,
 }
+// Results for 100000 * Pi + vf[i]
+var tanLarge = []float64{
+       -3.66131656475596512705e+00,
+       8.6490023287202547927e+00,
+       -2.841794195104782406e-01,
+       3.2532901861033120983e+00,
+       2.14727564046880001365e-01,
+       -2.18600910700688062874e-01,
+       -1.760002817699722747043e+00,
+       -4.38980891453536115952e-01,
+       -3.84388555942723509071e+00,
+       9.1098879344275101051e-01,
+}
 var tanh = []float64{
        9.9990531206936338549262119e-01,
        9.9999962057085294197613294e-01,
@@ -2247,7 +2285,7 @@ func TestSqrt(t *testing.T) {
 
 func TestTan(t *testing.T) {
        for i := 0; i < len(vf); i++ {
-               if f := Tan(vf[i]); !close(tan[i], f) {
+               if f := Tan(vf[i]); !veryclose(tan[i], f) {
                        t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
                }
        }
@@ -2257,16 +2295,6 @@ func TestTan(t *testing.T) {
                        t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
                }
        }
-
-       // Make sure portable Tan(Pi/2) doesn't panic (it used to).
-       // The portable implementation returns NaN.
-       // Assembly implementations might not,
-       // because Pi/2 is not exactly representable.
-       if runtime.GOARCH != "386" {
-               if f := Tan(Pi / 2); !alike(f, NaN()) {
-                       t.Errorf("Tan(%g) = %g, want %g", Pi/2, f, NaN())
-               }
-       }
 }
 
 func TestTanh(t *testing.T) {
@@ -2344,13 +2372,15 @@ func TestYn(t *testing.T) {
 }
 
 // Check that math functions of high angle values
-// return similar results to low angle values
+// return accurate results. [Since (vf[i] + large) - large != vf[i],
+// testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
+// a multiple of 2*Pi, is misleading.]
 func TestLargeCos(t *testing.T) {
        large := float64(100000 * Pi)
        for i := 0; i < len(vf); i++ {
-               f1 := Cos(vf[i])
+               f1 := cosLarge[i]
                f2 := Cos(vf[i] + large)
-               if !kindaclose(f1, f2) {
+               if !close(f1, f2) {
                        t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
                }
        }
@@ -2359,9 +2389,9 @@ func TestLargeCos(t *testing.T) {
 func TestLargeSin(t *testing.T) {
        large := float64(100000 * Pi)
        for i := 0; i < len(vf); i++ {
-               f1 := Sin(vf[i])
+               f1 := sinLarge[i]
                f2 := Sin(vf[i] + large)
-               if !kindaclose(f1, f2) {
+               if !close(f1, f2) {
                        t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
                }
        }
@@ -2370,9 +2400,9 @@ func TestLargeSin(t *testing.T) {
 func TestLargeSincos(t *testing.T) {
        large := float64(100000 * Pi)
        for i := 0; i < len(vf); i++ {
-               f1, g1 := Sincos(vf[i])
+               f1, g1 := sinLarge[i], cosLarge[i]
                f2, g2 := Sincos(vf[i] + large)
-               if !kindaclose(f1, f2) || !kindaclose(g1, g2) {
+               if !close(f1, f2) || !close(g1, g2) {
                        t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
                }
        }
@@ -2381,9 +2411,9 @@ func TestLargeSincos(t *testing.T) {
 func TestLargeTan(t *testing.T) {
        large := float64(100000 * Pi)
        for i := 0; i < len(vf); i++ {
-               f1 := Tan(vf[i])
+               f1 := tanLarge[i]
                f2 := Tan(vf[i] + large)
-               if !kindaclose(f1, f2) {
+               if !close(f1, f2) {
                        t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
                }
        }
similarity index 99%
rename from libgo/go/big/int.go
rename to libgo/go/math/big/int.go
index c6affbb..533a97f 100644 (file)
@@ -10,7 +10,7 @@ import (
        "errors"
        "fmt"
        "io"
-       "rand"
+       "math/rand"
        "strings"
 )
 
@@ -516,7 +516,7 @@ func (z *Int) SetString(s string, base int) (*Int, bool) {
        if err != io.EOF {
                return nil, false
        }
-       return z, true // err == os.EOF => scan consumed all of s
+       return z, true // err == io.EOF => scan consumed all of s
 }
 
 // SetBytes interprets buf as the bytes of a big-endian unsigned
similarity index 99%
rename from libgo/go/big/int_test.go
rename to libgo/go/math/big/int_test.go
index d66bb5f..163c662 100644 (file)
@@ -6,9 +6,9 @@ package big
 
 import (
        "bytes"
+       "encoding/gob"
        "encoding/hex"
        "fmt"
-       "gob"
        "testing"
        "testing/quick"
 )
similarity index 99%
rename from libgo/go/big/nat.go
rename to libgo/go/math/big/nat.go
index a46f782..3fa41e7 100644 (file)
@@ -21,7 +21,7 @@ package big
 import (
        "errors"
        "io"
-       "rand"
+       "math/rand"
 )
 
 // An unsigned integer x of the form
similarity index 100%
rename from libgo/go/big/rat.go
rename to libgo/go/math/big/rat.go
similarity index 99%
rename from libgo/go/big/rat_test.go
rename to libgo/go/math/big/rat_test.go
index 2443450..f7f31ae 100644 (file)
@@ -6,8 +6,8 @@ package big
 
 import (
        "bytes"
+       "encoding/gob"
        "fmt"
-       "gob"
        "testing"
 )
 
similarity index 81%
rename from libgo/go/cmath/abs.go
rename to libgo/go/math/cmplx/abs.go
index f3199ca..f3cd107 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package cmath provides basic constants and mathematical functions for
+// Package cmplx provides basic constants and mathematical functions for
 // complex numbers.
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/asin.go
rename to libgo/go/math/cmplx/asin.go
index 01ce80a..61880a2 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/cmath_test.go
rename to libgo/go/math/cmplx/cmath_test.go
index 6a595b0..610ca8c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import (
        "math"
similarity index 95%
rename from libgo/go/cmath/conj.go
rename to libgo/go/math/cmplx/conj.go
index 776b57d..34a4277 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 // Conj returns the complex conjugate of x.
 func Conj(x complex128) complex128 { return complex(real(x), -imag(x)) }
similarity index 99%
rename from libgo/go/cmath/exp.go
rename to libgo/go/math/cmplx/exp.go
index 64c1ef4..485ed2c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 97%
rename from libgo/go/cmath/isinf.go
rename to libgo/go/math/cmplx/isinf.go
index f23d2de..d5a65b4 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 97%
rename from libgo/go/cmath/isnan.go
rename to libgo/go/math/cmplx/isnan.go
index 2063bb8..05d0cce 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/log.go
rename to libgo/go/math/cmplx/log.go
index 8e6964f..881a064 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 96%
rename from libgo/go/cmath/phase.go
rename to libgo/go/math/cmplx/phase.go
index 2d67aa3..03cece8 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 96%
rename from libgo/go/cmath/polar.go
rename to libgo/go/math/cmplx/polar.go
index 033676a..9b192bc 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 // Polar returns the absolute value r and phase Î¸ of x,
 // such that x = r * e**θi.
similarity index 99%
rename from libgo/go/cmath/pow.go
rename to libgo/go/math/cmplx/pow.go
index 68e1207..4dbc583 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 95%
rename from libgo/go/cmath/rect.go
rename to libgo/go/math/cmplx/rect.go
index b955f0b..bf94d78 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/sin.go
rename to libgo/go/math/cmplx/sin.go
index 486b717..2c57536 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/sqrt.go
rename to libgo/go/math/cmplx/sqrt.go
index 4e7e805..179b539 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
similarity index 99%
rename from libgo/go/cmath/tan.go
rename to libgo/go/math/cmplx/tan.go
index 67dc22a..9485315 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package cmath
+package cmplx
 
 import "math"
 
index 0136507..e117158 100644 (file)
@@ -63,7 +63,7 @@ package math
 //   Stephen L. Moshier
 //   moshier@na-net.ornl.gov
 
-var _P = []float64{
+var _P = [...]float64{
        1.60119522476751861407e-04,
        1.19135147006586384913e-03,
        1.04213797561761569935e-02,
@@ -72,7 +72,7 @@ var _P = []float64{
        4.94214826801497100753e-01,
        9.99999999999999996796e-01,
 }
-var _Q = []float64{
+var _Q = [...]float64{
        -2.31581873324120129819e-05,
        5.39605580493303397842e-04,
        -4.45641913851797240494e-03,
@@ -82,7 +82,7 @@ var _Q = []float64{
        7.14304917030273074085e-02,
        1.00000000000000000320e+00,
 }
-var _S = []float64{
+var _S = [...]float64{
        7.87311395793093628397e-04,
        -2.29549961613378126380e-04,
        -2.68132617805781232825e-03,
similarity index 100%
rename from libgo/go/rand/rand_test.go
rename to libgo/go/math/rand/rand_test.go
index 66ffa58..76215a9 100644 (file)
@@ -6,8 +6,8 @@ package rand
 
 import (
        "errors"
-       "math"
        "fmt"
+       "math"
        "testing"
 )
 
index 6d7a60b..739ee80 100644 (file)
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
 package math
 
 /*
-       Floating point tangent.
+       Floating-point tangent.
 */
 
+// The original C code, the long comment, and the constants
+// below were from http://netlib.sandia.gov/cephes/cmath/sin.c,
+// available from http://www.netlib.org/cephes/cmath.tgz.
+// The go code is a simplified version of the original C.
+//
+//      tan.c
+//
+//      Circular tangent
+//
+// SYNOPSIS:
+//
+// double x, y, tan();
+// y = tan( x );
+//
+// DESCRIPTION:
+//
+// Returns the circular tangent of the radian argument x.
+//
+// Range reduction is modulo pi/4.  A rational function
+//       x + x**3 P(x**2)/Q(x**2)
+// is employed in the basic interval [0, pi/4].
+//
+// ACCURACY:
+//                      Relative error:
+// arithmetic   domain     # trials      peak         rms
+//    DEC      +-1.07e9      44000      4.1e-17     1.0e-17
+//    IEEE     +-1.07e9      30000      2.9e-16     8.1e-17
+//
+// Partial loss of accuracy begins to occur at x = 2**30 = 1.074e9.  The loss
+// is not gradual, but jumps suddenly to about 1 part in 10e7.  Results may
+// be meaningless for x > 2**49 = 5.6e14.
+// [Accuracy loss statement from sin.go comments.]
+//
+// Cephes Math Library Release 2.8:  June, 2000
+// Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier
+//
+// The readme file at http://netlib.sandia.gov/cephes/ says:
+//    Some software in this archive may be from the book _Methods and
+// Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster
+// International, 1989) or from the Cephes Mathematical Library, a
+// commercial product. In either event, it is copyrighted by the author.
+// What you see here may be used freely but it comes with no support or
+// guarantee.
+//
+//   The two known misprints in the book are repaired here in the
+// source listings for the gamma function and the incomplete beta
+// integral.
+//
+//   Stephen L. Moshier
+//   moshier@na-net.ornl.gov
+
+// tan coefficients
+var _tanP = [...]float64{
+       -1.30936939181383777646E4, // 0xc0c992d8d24f3f38
+       1.15351664838587416140E6,  // 0x413199eca5fc9ddd
+       -1.79565251976484877988E7, // 0xc1711fead3299176
+}
+var _tanQ = [...]float64{
+       1.00000000000000000000E0,
+       1.36812963470692954678E4,  //0x40cab8a5eeb36572
+       -1.32089234440210967447E6, //0xc13427bc582abc96
+       2.50083801823357915839E7,  //0x4177d98fc2ead8ef
+       -5.38695755929454629881E7, //0xc189afe03cbe5a31
+}
+
 // Tan returns the tangent of x.
+//
+// Special conditions are:
+//     Tan(±0) = Â±0
+//     Tan(±Inf) = NaN
+//     Tan(NaN) = NaN
 func Tan(x float64) float64 {
-       // Coefficients are #4285 from Hart & Cheney. (19.74D)
        const (
-               P0 = -.1306820264754825668269611177e+5
-               P1 = .1055970901714953193602353981e+4
-               P2 = -.1550685653483266376941705728e+2
-               P3 = .3422554387241003435328470489e-1
-               P4 = .3386638642677172096076369e-4
-               Q0 = -.1663895238947119001851464661e+5
-               Q1 = .4765751362916483698926655581e+4
-               Q2 = -.1555033164031709966900124574e+3
+               PI4A = 7.85398125648498535156E-1                             // 0x3fe921fb40000000, Pi/4 split into three parts
+               PI4B = 3.77489470793079817668E-8                             // 0x3e64442d00000000,
+               PI4C = 2.69515142907905952645E-15                            // 0x3ce8469898cc5170,
+               M4PI = 1.273239544735162542821171882678754627704620361328125 // 4/pi
        )
+       // TODO(rsc): Remove manual inlining of IsNaN, IsInf
+       // when compiler does it for us
+       // special cases
+       switch {
+       case x == 0 || x != x: // x == 0 || IsNaN():
+               return x // return Â±0 || NaN()
+       case x < -MaxFloat64 || x > MaxFloat64: // IsInf(x, 0):
+               return NaN()
+       }
 
-       flag := false
+       // make argument positive but save the sign
        sign := false
        if x < 0 {
                x = -x
                sign = true
        }
-       x = x * (4 / Pi) /* overflow? */
-       var e float64
-       e, x = Modf(x)
-       i := int32(e)
-
-       switch i & 3 {
-       case 1:
-               x = 1 - x
-               flag = true
 
-       case 2:
-               sign = !sign
-               flag = true
+       j := int64(x * M4PI) // integer part of x/(Pi/4), as integer for tests on the phase angle
+       y := float64(j)      // integer part of x/(Pi/4), as float
 
-       case 3:
-               x = 1 - x
-               sign = !sign
+       /* map zeros and singularities to origin */
+       if j&1 == 1 {
+               j += 1
+               y += 1
        }
 
-       xsq := x * x
-       temp := ((((P4*xsq+P3)*xsq+P2)*xsq+P1)*xsq + P0) * x
-       temp = temp / (((xsq+Q2)*xsq+Q1)*xsq + Q0)
+       z := ((x - y*PI4A) - y*PI4B) - y*PI4C
+       zz := z * z
 
-       if flag {
-               if temp == 0 {
-                       return NaN()
-               }
-               temp = 1 / temp
+       if zz > 1e-14 {
+               y = z + z*(zz*(((_tanP[0]*zz)+_tanP[1])*zz+_tanP[2])/((((zz+_tanQ[1])*zz+_tanQ[2])*zz+_tanQ[3])*zz+_tanQ[4]))
+       } else {
+               y = z
+       }
+       if j&2 == 2 {
+               y = -1 / y
        }
        if sign {
-               temp = -temp
+               y = -y
        }
-       return temp
+       return y
 }
index 24b0e41..64a11e6 100644 (file)
@@ -176,7 +176,7 @@ type Reader struct {
 }
 
 // NextPart returns the next part in the multipart or an error.
-// When there are no more parts, the error os.EOF is returned.
+// When there are no more parts, the error io.EOF is returned.
 func (mr *Reader) NextPart() (*Part, error) {
        if mr.currentPart != nil {
                mr.currentPart.Close()
index dd5d7c1..89ff5e4 100644 (file)
@@ -6,10 +6,10 @@ package multipart
 
 import (
        "bytes"
+       "encoding/json"
        "fmt"
        "io"
        "io/ioutil"
-       "json"
        "strings"
        "testing"
 )
@@ -214,7 +214,7 @@ func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) {
                t.Error("Didn't expect a fifth part.")
        }
        if err != io.EOF {
-               t.Errorf("On fifth part expected os.EOF; got %v", err)
+               t.Errorf("On fifth part expected io.EOF; got %v", err)
        }
 }
 
@@ -259,7 +259,7 @@ func TestVariousTextLineEndings(t *testing.T) {
                        t.Errorf("Unexpected part in test %d", testNum)
                }
                if err != io.EOF {
-                       t.Errorf("On test %d expected os.EOF; got %v", testNum, err)
+                       t.Errorf("On test %d expected io.EOF; got %v", testNum, err)
                }
 
        }
index e66f28c..f4ed8b8 100644 (file)
@@ -7,7 +7,7 @@ package net
 import (
        "bytes"
        "fmt"
-       "rand"
+       "math/rand"
        "sort"
 )
 
index e321ed9..bab5f2a 100644 (file)
@@ -17,7 +17,7 @@
 package net
 
 import (
-       "rand"
+       "math/rand"
        "sync"
        "time"
 )
similarity index 99%
rename from libgo/go/http/cgi/child.go
rename to libgo/go/net/http/cgi/child.go
index 1618268..e188cd4 100644 (file)
@@ -12,14 +12,14 @@ import (
        "crypto/tls"
        "errors"
        "fmt"
-       "http"
        "io"
        "io/ioutil"
        "net"
+       "net/http"
+       "net/url"
        "os"
        "strconv"
        "strings"
-       "url"
 )
 
 // Request returns the HTTP request as represented in the current
similarity index 99%
rename from libgo/go/http/cgi/host.go
rename to libgo/go/net/http/cgi/host.go
index 8c999c0..615d366 100644 (file)
@@ -16,12 +16,12 @@ package cgi
 
 import (
        "bufio"
-       "exec"
        "fmt"
-       "http"
        "io"
        "log"
+       "net/http"
        "os"
+       "os/exec"
        "path/filepath"
        "regexp"
        "runtime"
similarity index 99%
rename from libgo/go/http/cgi/host_test.go
rename to libgo/go/net/http/cgi/host_test.go
index 3227e32..2bc913a 100644 (file)
@@ -8,19 +8,19 @@ package cgi
 
 import (
        "bufio"
-       "exec"
        "fmt"
-       "http"
-       "http/httptest"
        "io"
-       "os"
        "net"
+       "net/http"
+       "net/http/httptest"
+       "os"
+       "os/exec"
        "path/filepath"
+       "runtime"
        "strconv"
        "strings"
        "testing"
        "time"
-       "runtime"
 )
 
 func newRequest(httpreq string) *http.Request {
@@ -374,8 +374,6 @@ func TestCopyError(t *testing.T) {
        }
 }
 
-/* This test doesn't work in gccgo's testing environment.
-
 func TestDirUnix(t *testing.T) {
        if skipTest(t) || runtime.GOOS == "windows" {
                return
@@ -398,14 +396,13 @@ func TestDirUnix(t *testing.T) {
                Path: "testdata/test.cgi",
                Root: "/test.cgi",
        }
+       abswd, _ := filepath.EvalSymlinks(cwd)
        expectedMap = map[string]string{
-               "cwd": cwd,
+               "cwd": abswd,
        }
        runCgiTest(t, h, "GET /test.cgi HTTP/1.0\nHost: example.com\n\n", expectedMap)
 }
 
-*/
-
 func TestDirWindows(t *testing.T) {
        if skipTest(t) || runtime.GOOS != "windows" {
                return
similarity index 99%
rename from libgo/go/http/cgi/matryoshka_test.go
rename to libgo/go/net/http/cgi/matryoshka_test.go
index 3e4a6ad..1a44df2 100644 (file)
@@ -10,7 +10,7 @@ package cgi
 
 import (
        "fmt"
-       "http"
+       "net/http"
        "os"
        "testing"
 )
old mode 100755 (executable)
new mode 100644 (file)
similarity index 100%
rename from libgo/go/http/cgi/testdata/test.cgi
rename to libgo/go/net/http/cgi/testdata/test.cgi
diff --git a/libgo/go/net/http/chunked.go b/libgo/go/net/http/chunked.go
new file mode 100644 (file)
index 0000000..b012dd1
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package http
+
+import (
+       "bufio"
+       "io"
+       "strconv"
+)
+
+func newChunkedWriter(w io.Writer) io.WriteCloser {
+       return &chunkedWriter{w}
+}
+
+// Writing to ChunkedWriter translates to writing in HTTP chunked Transfer
+// Encoding wire format to the underlying Wire writer.
+type chunkedWriter struct {
+       Wire io.Writer
+}
+
+// Write the contents of data as one chunk to Wire.
+// NOTE: Note that the corresponding chunk-writing procedure in Conn.Write has
+// a bug since it does not check for success of io.WriteString
+func (cw *chunkedWriter) Write(data []byte) (n int, err error) {
+
+       // Don't send 0-length data. It looks like EOF for chunked encoding.
+       if len(data) == 0 {
+               return 0, nil
+       }
+
+       head := strconv.Itob(len(data), 16) + "\r\n"
+
+       if _, err = io.WriteString(cw.Wire, head); err != nil {
+               return 0, err
+       }
+       if n, err = cw.Wire.Write(data); err != nil {
+               return
+       }
+       if n != len(data) {
+               err = io.ErrShortWrite
+               return
+       }
+       _, err = io.WriteString(cw.Wire, "\r\n")
+
+       return
+}
+
+func (cw *chunkedWriter) Close() error {
+       _, err := io.WriteString(cw.Wire, "0\r\n")
+       return err
+}
+
+func newChunkedReader(r *bufio.Reader) io.Reader {
+       return &chunkedReader{r: r}
+}
similarity index 99%
rename from libgo/go/http/client.go
rename to libgo/go/net/http/client.go
index 503cc89..211ac44 100644 (file)
@@ -14,8 +14,8 @@ import (
        "errors"
        "fmt"
        "io"
+       "net/url"
        "strings"
-       "url"
 )
 
 // A Client is an HTTP client. Its zero value (DefaultClient) is a usable client
@@ -143,7 +143,7 @@ func shouldRedirect(statusCode int) bool {
 //
 // Caller should close r.Body when done reading from it.
 //
-// Get is a convenience wrapper around DefaultClient.Get.
+// Get is a wrapper around DefaultClient.Get.
 func Get(url string) (r *Response, err error) {
        return DefaultClient.Get(url)
 }
similarity index 99%
rename from libgo/go/http/client_test.go
rename to libgo/go/net/http/client_test.go
index fdad2cd..d224380 100644 (file)
@@ -10,15 +10,15 @@ import (
        "crypto/tls"
        "errors"
        "fmt"
-       . "http"
-       "http/httptest"
        "io"
        "io/ioutil"
        "net"
+       . "net/http"
+       "net/http/httptest"
+       "net/url"
        "strconv"
        "strings"
        "testing"
-       "url"
 )
 
 var robotsTxtHandler = HandlerFunc(func(w ResponseWriter, r *Request) {
similarity index 99%
rename from libgo/go/http/cookie_test.go
rename to libgo/go/net/http/cookie_test.go
index 9a537f9..24adf20 100644 (file)
@@ -5,8 +5,8 @@
 package http
 
 import (
+       "encoding/json"
        "fmt"
-       "json"
        "reflect"
        "testing"
        "time"
similarity index 99%
rename from libgo/go/http/fcgi/child.go
rename to libgo/go/net/http/fcgi/child.go
index f6591e0..7b56395 100644 (file)
@@ -8,10 +8,10 @@ package fcgi
 
 import (
        "fmt"
-       "http"
-       "http/cgi"
        "io"
        "net"
+       "net/http"
+       "net/http/cgi"
        "os"
        "time"
 )
similarity index 99%
rename from libgo/go/http/filetransport_test.go
rename to libgo/go/net/http/filetransport_test.go
index aaee73e..265a3b9 100644 (file)
@@ -5,8 +5,8 @@
 package http_test
 
 import (
-       "http"
        "io/ioutil"
+       "net/http"
        "path/filepath"
        "testing"
 )
similarity index 99%
rename from libgo/go/http/fs.go
rename to libgo/go/net/http/fs.go
index eb0c67d..5f91ff5 100644 (file)
@@ -17,7 +17,7 @@ import (
        "strconv"
        "strings"
        "time"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A Dir implements http.FileSystem using the native file
similarity index 99%
rename from libgo/go/http/fs_test.go
rename to libgo/go/net/http/fs_test.go
index 76312e8..e1a784c 100644 (file)
@@ -6,14 +6,14 @@ package http_test
 
 import (
        "fmt"
-       . "http"
-       "http/httptest"
        "io/ioutil"
+       . "net/http"
+       "net/http/httptest"
+       "net/url"
        "os"
        "path/filepath"
        "strings"
        "testing"
-       "url"
 )
 
 const (
similarity index 96%
rename from libgo/go/http/header.go
rename to libgo/go/net/http/header.go
index 6be6016..b107c31 100644 (file)
@@ -30,8 +30,8 @@ func (h Header) Set(key, value string) {
 
 // Get gets the first value associated with the given key.
 // If there are no values associated with the key, Get returns "".
-// Get is a convenience method.  For more complex queries,
-// access the map directly.
+// To access multiple values of a key, access the map directly
+// with CanonicalHeaderKey.
 func (h Header) Get(key string) string {
        return textproto.MIMEHeader(h).Get(key)
 }
similarity index 99%
rename from libgo/go/http/httptest/recorder.go
rename to libgo/go/net/http/httptest/recorder.go
index f69279f..9aa0d51 100644 (file)
@@ -7,7 +7,7 @@ package httptest
 
 import (
        "bytes"
-       "http"
+       "net/http"
 )
 
 // ResponseRecorder is an implementation of http.ResponseWriter that
similarity index 99%
rename from libgo/go/http/httptest/server.go
rename to libgo/go/net/http/httptest/server.go
index ea719cf..f09e826 100644 (file)
@@ -11,8 +11,8 @@ import (
        "crypto/tls"
        "flag"
        "fmt"
-       "http"
        "net"
+       "net/http"
        "os"
        "time"
 )
similarity index 78%
rename from libgo/go/http/chunked.go
rename to libgo/go/net/http/httputil/chunked.go
index 157e1c4..34e47c7 100644 (file)
@@ -2,13 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package http
+package httputil
 
 import (
        "bufio"
        "io"
-       "log"
+       "net/http"
        "strconv"
+       "strings"
 )
 
 // NewChunkedWriter returns a new writer that translates writes into HTTP
@@ -21,9 +22,6 @@ import (
 // would result in double chunking or chunking with a Content-Length
 // length, both of which are wrong.
 func NewChunkedWriter(w io.Writer) io.WriteCloser {
-       if _, bad := w.(*response); bad {
-               log.Printf("warning: using NewChunkedWriter in an http.Handler; expect corrupt output")
-       }
        return &chunkedWriter{w}
 }
 
@@ -67,10 +65,20 @@ func (cw *chunkedWriter) Close() error {
 
 // NewChunkedReader returns a new reader that translates the data read from r
 // out of HTTP "chunked" format before returning it. 
-// The reader returns os.EOF when the final 0-length chunk is read.
+// The reader returns io.EOF when the final 0-length chunk is read.
 //
 // NewChunkedReader is not needed by normal applications. The http package
 // automatically decodes chunking when reading response bodies.
-func NewChunkedReader(r *bufio.Reader) io.Reader {
-       return &chunkedReader{r: r}
+func NewChunkedReader(r io.Reader) io.Reader {
+       // This is a bit of a hack so we don't have to copy chunkedReader into
+       // httputil.  It's a bit more complex than chunkedWriter, which is copied
+       // above.
+       req, err := http.ReadRequest(bufio.NewReader(io.MultiReader(
+               strings.NewReader("POST / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n"),
+               r,
+               strings.NewReader("\r\n"))))
+       if err != nil {
+               panic("bad fake request: " + err.Error())
+       }
+       return req.Body
 }
diff --git a/libgo/go/net/http/httputil/chunked_test.go b/libgo/go/net/http/httputil/chunked_test.go
new file mode 100644 (file)
index 0000000..258d39b
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package httputil
+
+import (
+       "bytes"
+       "io/ioutil"
+       "testing"
+)
+
+func TestChunk(t *testing.T) {
+       var b bytes.Buffer
+
+       w := NewChunkedWriter(&b)
+       const chunk1 = "hello, "
+       const chunk2 = "world! 0123456789abcdef"
+       w.Write([]byte(chunk1))
+       w.Write([]byte(chunk2))
+       w.Close()
+
+       if g, e := b.String(), "7\r\nhello, \r\n17\r\nworld! 0123456789abcdef\r\n0\r\n"; g != e {
+               t.Fatalf("chunk writer wrote %q; want %q", g, e)
+       }
+
+       r := NewChunkedReader(&b)
+       data, err := ioutil.ReadAll(r)
+       if err != nil {
+               t.Fatalf("ReadAll from NewChunkedReader: %v", err)
+       }
+       if g, e := string(data), chunk1+chunk2; g != e {
+               t.Errorf("chunk reader read %q; want %q", g, e)
+       }
+}
diff --git a/libgo/go/net/http/httputil/dump.go b/libgo/go/net/http/httputil/dump.go
new file mode 100644 (file)
index 0000000..31696ae
--- /dev/null
@@ -0,0 +1,203 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package httputil
+
+import (
+       "bytes"
+       "errors"
+       "fmt"
+       "io"
+       "io/ioutil"
+       "net"
+       "net/http"
+       "strings"
+)
+
+// One of the copies, say from b to r2, could be avoided by using a more
+// elaborate trick where the other copy is made during Request/Response.Write.
+// This would complicate things too much, given that these functions are for
+// debugging only.
+func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) {
+       var buf bytes.Buffer
+       if _, err = buf.ReadFrom(b); err != nil {
+               return nil, nil, err
+       }
+       if err = b.Close(); err != nil {
+               return nil, nil, err
+       }
+       return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewBuffer(buf.Bytes())), nil
+}
+
+// dumpConn is a net.Conn which writes to Writer and reads from Reader
+type dumpConn struct {
+       io.Writer
+       io.Reader
+}
+
+func (c *dumpConn) Close() error                     { return nil }
+func (c *dumpConn) LocalAddr() net.Addr              { return nil }
+func (c *dumpConn) RemoteAddr() net.Addr             { return nil }
+func (c *dumpConn) SetTimeout(nsec int64) error      { return nil }
+func (c *dumpConn) SetReadTimeout(nsec int64) error  { return nil }
+func (c *dumpConn) SetWriteTimeout(nsec int64) error { return nil }
+
+// DumpRequestOut is like DumpRequest but includes
+// headers that the standard http.Transport adds,
+// such as User-Agent.
+func DumpRequestOut(req *http.Request, body bool) (dump []byte, err error) {
+       save := req.Body
+       if !body || req.Body == nil {
+               req.Body = nil
+       } else {
+               save, req.Body, err = drainBody(req.Body)
+               if err != nil {
+                       return
+               }
+       }
+
+       var b bytes.Buffer
+       dialed := false
+       t := &http.Transport{
+               Dial: func(net, addr string) (c net.Conn, err error) {
+                       if dialed {
+                               return nil, errors.New("unexpected second dial")
+                       }
+                       c = &dumpConn{
+                               Writer: &b,
+                               Reader: strings.NewReader("HTTP/1.1 500 Fake Error\r\n\r\n"),
+                       }
+                       return
+               },
+       }
+
+       _, err = t.RoundTrip(req)
+
+       req.Body = save
+       if err != nil {
+               return
+       }
+       dump = b.Bytes()
+       return
+}
+
+// Return value if nonempty, def otherwise.
+func valueOrDefault(value, def string) string {
+       if value != "" {
+               return value
+       }
+       return def
+}
+
+var reqWriteExcludeHeaderDump = map[string]bool{
+       "Host":              true, // not in Header map anyway
+       "Content-Length":    true,
+       "Transfer-Encoding": true,
+       "Trailer":           true,
+}
+
+// dumpAsReceived writes req to w in the form as it was received, or
+// at least as accurately as possible from the information retained in
+// the request.
+func dumpAsReceived(req *http.Request, w io.Writer) error {
+       return nil
+}
+
+// DumpRequest returns the as-received wire representation of req,
+// optionally including the request body, for debugging.
+// DumpRequest is semantically a no-op, but in order to
+// dump the body, it reads the body data into memory and
+// changes req.Body to refer to the in-memory copy.
+// The documentation for http.Request.Write details which fields
+// of req are used.
+func DumpRequest(req *http.Request, body bool) (dump []byte, err error) {
+       save := req.Body
+       if !body || req.Body == nil {
+               req.Body = nil
+       } else {
+               save, req.Body, err = drainBody(req.Body)
+               if err != nil {
+                       return
+               }
+       }
+
+       var b bytes.Buffer
+
+       urlStr := req.URL.Raw
+       if urlStr == "" {
+               urlStr = valueOrDefault(req.URL.EncodedPath(), "/")
+               if req.URL.RawQuery != "" {
+                       urlStr += "?" + req.URL.RawQuery
+               }
+       }
+
+       fmt.Fprintf(&b, "%s %s HTTP/%d.%d\r\n", valueOrDefault(req.Method, "GET"), urlStr,
+               req.ProtoMajor, req.ProtoMinor)
+
+       host := req.Host
+       if host == "" && req.URL != nil {
+               host = req.URL.Host
+       }
+       if host != "" {
+               fmt.Fprintf(&b, "Host: %s\r\n", host)
+       }
+
+       chunked := len(req.TransferEncoding) > 0 && req.TransferEncoding[0] == "chunked"
+       if len(req.TransferEncoding) > 0 {
+               fmt.Fprintf(&b, "Transfer-Encoding: %s\r\n", strings.Join(req.TransferEncoding, ","))
+       }
+       if req.Close {
+               fmt.Fprintf(&b, "Connection: close\r\n")
+       }
+
+       err = req.Header.WriteSubset(&b, reqWriteExcludeHeaderDump)
+       if err != nil {
+               return
+       }
+
+       io.WriteString(&b, "\r\n")
+
+       if req.Body != nil {
+               var dest io.Writer = &b
+               if chunked {
+                       dest = NewChunkedWriter(dest)
+               }
+               _, err = io.Copy(dest, req.Body)
+               if chunked {
+                       dest.(io.Closer).Close()
+                       io.WriteString(&b, "\r\n")
+               }
+       }
+
+       req.Body = save
+       if err != nil {
+               return
+       }
+       dump = b.Bytes()
+       return
+}
+
+// DumpResponse is like DumpRequest but dumps a response.
+func DumpResponse(resp *http.Response, body bool) (dump []byte, err error) {
+       var b bytes.Buffer
+       save := resp.Body
+       savecl := resp.ContentLength
+       if !body || resp.Body == nil {
+               resp.Body = nil
+               resp.ContentLength = 0
+       } else {
+               save, resp.Body, err = drainBody(resp.Body)
+               if err != nil {
+                       return
+               }
+       }
+       err = resp.Write(&b)
+       resp.Body = save
+       resp.ContentLength = savecl
+       if err != nil {
+               return
+       }
+       dump = b.Bytes()
+       return
+}
diff --git a/libgo/go/net/http/httputil/dump_test.go b/libgo/go/net/http/httputil/dump_test.go
new file mode 100644 (file)
index 0000000..819efb5
--- /dev/null
@@ -0,0 +1,140 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package httputil
+
+import (
+       "bytes"
+       "fmt"
+       "io"
+       "io/ioutil"
+       "net/http"
+       "net/url"
+       "testing"
+)
+
+type dumpTest struct {
+       Req  http.Request
+       Body interface{} // optional []byte or func() io.ReadCloser to populate Req.Body
+
+       WantDump    string
+       WantDumpOut string
+}
+
+var dumpTests = []dumpTest{
+
+       // HTTP/1.1 => chunked coding; body; empty trailer
+       {
+               Req: http.Request{
+                       Method: "GET",
+                       URL: &url.URL{
+                               Scheme: "http",
+                               Host:   "www.google.com",
+                               Path:   "/search",
+                       },
+                       ProtoMajor:       1,
+                       ProtoMinor:       1,
+                       TransferEncoding: []string{"chunked"},
+               },
+
+               Body: []byte("abcdef"),
+
+               WantDump: "GET /search HTTP/1.1\r\n" +
+                       "Host: www.google.com\r\n" +
+                       "Transfer-Encoding: chunked\r\n\r\n" +
+                       chunk("abcdef") + chunk(""),
+       },
+
+       // Verify that DumpRequest preserves the HTTP version number, doesn't add a Host,
+       // and doesn't add a User-Agent.
+       {
+               Req: http.Request{
+                       Method:     "GET",
+                       URL:        mustParseURL("/foo"),
+                       ProtoMajor: 1,
+                       ProtoMinor: 0,
+                       Header: http.Header{
+                               "X-Foo": []string{"X-Bar"},
+                       },
+               },
+
+               WantDump: "GET /foo HTTP/1.0\r\n" +
+                       "X-Foo: X-Bar\r\n\r\n",
+       },
+
+       {
+               Req: *mustNewRequest("GET", "http://example.com/foo", nil),
+
+               WantDumpOut: "GET /foo HTTP/1.1\r\n" +
+                       "Host: example.com\r\n" +
+                       "User-Agent: Go http package\r\n" +
+                       "Accept-Encoding: gzip\r\n\r\n",
+       },
+}
+
+func TestDumpRequest(t *testing.T) {
+       for i, tt := range dumpTests {
+               setBody := func() {
+                       if tt.Body == nil {
+                               return
+                       }
+                       switch b := tt.Body.(type) {
+                       case []byte:
+                               tt.Req.Body = ioutil.NopCloser(bytes.NewBuffer(b))
+                       case func() io.ReadCloser:
+                               tt.Req.Body = b()
+                       }
+               }
+               setBody()
+               if tt.Req.Header == nil {
+                       tt.Req.Header = make(http.Header)
+               }
+
+               if tt.WantDump != "" {
+                       setBody()
+                       dump, err := DumpRequest(&tt.Req, true)
+                       if err != nil {
+                               t.Errorf("DumpRequest #%d: %s", i, err)
+                               continue
+                       }
+                       if string(dump) != tt.WantDump {
+                               t.Errorf("DumpRequest %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantDump, string(dump))
+                               continue
+                       }
+               }
+
+               if tt.WantDumpOut != "" {
+                       setBody()
+                       dump, err := DumpRequestOut(&tt.Req, true)
+                       if err != nil {
+                               t.Errorf("DumpRequestOut #%d: %s", i, err)
+                               continue
+                       }
+                       if string(dump) != tt.WantDumpOut {
+                               t.Errorf("DumpRequestOut %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantDumpOut, string(dump))
+                               continue
+                       }
+               }
+       }
+}
+
+func chunk(s string) string {
+       return fmt.Sprintf("%x\r\n%s\r\n", len(s), s)
+}
+
+func mustParseURL(s string) *url.URL {
+       u, err := url.Parse(s)
+       if err != nil {
+               panic(fmt.Sprintf("Error parsing URL %q: %v", s, err))
+       }
+       return u
+}
+
+func mustNewRequest(method, url string, body io.Reader) *http.Request {
+       req, err := http.NewRequest(method, url, body)
+       if err != nil {
+               panic(fmt.Sprintf("NewRequest(%q, %q, %p) err = %v", method, url, body, err))
+       }
+       return req
+}
similarity index 90%
rename from libgo/go/http/persist.go
rename to libgo/go/net/http/httputil/persist.go
index 7d84e96..d7b6701 100644 (file)
@@ -2,21 +2,24 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package http
+// Package httputil provides HTTP utility functions, complementing the
+// more common ones in the net/http package.
+package httputil
 
 import (
        "bufio"
        "errors"
        "io"
        "net"
+       "net/http"
        "net/textproto"
        "os"
        "sync"
 )
 
 var (
-       ErrPersistEOF = &ProtocolError{"persistent connection closed"}
-       ErrPipeline   = &ProtocolError{"pipeline error"}
+       ErrPersistEOF = &http.ProtocolError{"persistent connection closed"}
+       ErrPipeline   = &http.ProtocolError{"pipeline error"}
 )
 
 // A ServerConn reads requests and sends responses over an underlying
@@ -35,7 +38,7 @@ type ServerConn struct {
        re, we          error // read/write errors
        lastbody        io.ReadCloser
        nread, nwritten int
-       pipereq         map[*Request]uint
+       pipereq         map[*http.Request]uint
 
        pipe textproto.Pipeline
 }
@@ -46,7 +49,7 @@ func NewServerConn(c net.Conn, r *bufio.Reader) *ServerConn {
        if r == nil {
                r = bufio.NewReader(c)
        }
-       return &ServerConn{c: c, r: r, pipereq: make(map[*Request]uint)}
+       return &ServerConn{c: c, r: r, pipereq: make(map[*http.Request]uint)}
 }
 
 // Hijack detaches the ServerConn and returns the underlying connection as well
@@ -76,7 +79,7 @@ func (sc *ServerConn) Close() error {
 // it is gracefully determined that there are no more requests (e.g. after the
 // first request on an HTTP/1.0 connection, or after a Connection:close on a
 // HTTP/1.1 connection).
-func (sc *ServerConn) Read() (req *Request, err error) {
+func (sc *ServerConn) Read() (req *http.Request, err error) {
 
        // Ensure ordered execution of Reads and Writes
        id := sc.pipe.Next()
@@ -126,7 +129,7 @@ func (sc *ServerConn) Read() (req *Request, err error) {
                }
        }
 
-       req, err = ReadRequest(r)
+       req, err = http.ReadRequest(r)
        sc.lk.Lock()
        defer sc.lk.Unlock()
        if err != nil {
@@ -161,7 +164,7 @@ func (sc *ServerConn) Pending() int {
 // Write writes resp in response to req. To close the connection gracefully, set the
 // Response.Close field to true. Write should be considered operational until
 // it returns an error, regardless of any errors returned on the Read side.
-func (sc *ServerConn) Write(req *Request, resp *Response) error {
+func (sc *ServerConn) Write(req *http.Request, resp *http.Response) error {
 
        // Retrieve the pipeline ID of this request/response pair
        sc.lk.Lock()
@@ -225,10 +228,10 @@ type ClientConn struct {
        re, we          error // read/write errors
        lastbody        io.ReadCloser
        nread, nwritten int
-       pipereq         map[*Request]uint
+       pipereq         map[*http.Request]uint
 
        pipe     textproto.Pipeline
-       writeReq func(*Request, io.Writer) error
+       writeReq func(*http.Request, io.Writer) error
 }
 
 // NewClientConn returns a new ClientConn reading and writing c.  If r is not
@@ -240,8 +243,8 @@ func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn {
        return &ClientConn{
                c:        c,
                r:        r,
-               pipereq:  make(map[*Request]uint),
-               writeReq: (*Request).Write,
+               pipereq:  make(map[*http.Request]uint),
+               writeReq: (*http.Request).Write,
        }
 }
 
@@ -249,7 +252,7 @@ func NewClientConn(c net.Conn, r *bufio.Reader) *ClientConn {
 // using Request's WriteProxy method.
 func NewProxyClientConn(c net.Conn, r *bufio.Reader) *ClientConn {
        cc := NewClientConn(c, r)
-       cc.writeReq = (*Request).WriteProxy
+       cc.writeReq = (*http.Request).WriteProxy
        return cc
 }
 
@@ -281,7 +284,7 @@ func (cc *ClientConn) Close() error {
 // keepalive connection is logically closed after this request and the opposing
 // server is informed. An ErrUnexpectedEOF indicates the remote closed the
 // underlying TCP connection, which is usually considered as graceful close.
-func (cc *ClientConn) Write(req *Request) (err error) {
+func (cc *ClientConn) Write(req *http.Request) (err error) {
 
        // Ensure ordered execution of Writes
        id := cc.pipe.Next()
@@ -344,13 +347,7 @@ func (cc *ClientConn) Pending() int {
 // returned together with an ErrPersistEOF, which means that the remote
 // requested that this be the last request serviced. Read can be called
 // concurrently with Write, but not with another Read.
-func (cc *ClientConn) Read(req *Request) (*Response, error) {
-       return cc.readUsing(req, ReadResponse)
-}
-
-// readUsing is the implementation of Read with a replaceable
-// ReadResponse-like function, used by the Transport.
-func (cc *ClientConn) readUsing(req *Request, readRes func(*bufio.Reader, *Request) (*Response, error)) (resp *Response, err error) {
+func (cc *ClientConn) Read(req *http.Request) (resp *http.Response, err error) {
        // Retrieve the pipeline ID of this request/response pair
        cc.lk.Lock()
        id, ok := cc.pipereq[req]
@@ -393,7 +390,7 @@ func (cc *ClientConn) readUsing(req *Request, readRes func(*bufio.Reader, *Reque
                }
        }
 
-       resp, err = readRes(r, req)
+       resp, err = http.ReadResponse(r, req)
        cc.lk.Lock()
        defer cc.lk.Unlock()
        if err != nil {
@@ -412,7 +409,7 @@ func (cc *ClientConn) readUsing(req *Request, readRes func(*bufio.Reader, *Reque
 }
 
 // Do is convenience method that writes a request and reads a response.
-func (cc *ClientConn) Do(req *Request) (resp *Response, err error) {
+func (cc *ClientConn) Do(req *http.Request) (resp *http.Response, err error) {
        err = cc.Write(req)
        if err != nil {
                return
similarity index 87%
rename from libgo/go/http/reverseproxy.go
rename to libgo/go/net/http/httputil/reverseproxy.go
index 9cd359f..bfcb3ca 100644 (file)
@@ -4,16 +4,17 @@
 
 // HTTP reverse proxy handler
 
-package http
+package httputil
 
 import (
        "io"
        "log"
        "net"
+       "net/http"
+       "net/url"
        "strings"
        "sync"
        "time"
-       "url"
 )
 
 // ReverseProxy is an HTTP Handler that takes an incoming request and
@@ -24,11 +25,11 @@ type ReverseProxy struct {
        // the request into a new request to be sent
        // using Transport. Its response is then copied
        // back to the original client unmodified.
-       Director func(*Request)
+       Director func(*http.Request)
 
-       // The Transport used to perform proxy requests.
-       // If nil, DefaultTransport is used.
-       Transport RoundTripper
+       // The transport used to perform proxy requests.
+       // If nil, http.DefaultTransport is used.
+       Transport http.RoundTripper
 
        // FlushInterval specifies the flush interval, in
        // nanoseconds, to flush to the client while
@@ -54,7 +55,7 @@ func singleJoiningSlash(a, b string) string {
 // target's path is "/base" and the incoming request was for "/dir",
 // the target request will be for /base/dir.
 func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy {
-       director := func(req *Request) {
+       director := func(req *http.Request) {
                req.URL.Scheme = target.Scheme
                req.URL.Host = target.Host
                req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path)
@@ -68,7 +69,7 @@ func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy {
        return &ReverseProxy{Director: director}
 }
 
-func copyHeader(dst, src Header) {
+func copyHeader(dst, src http.Header) {
        for k, vv := range src {
                for _, v := range vv {
                        dst.Add(k, v)
@@ -76,13 +77,13 @@ func copyHeader(dst, src Header) {
        }
 }
 
-func (p *ReverseProxy) ServeHTTP(rw ResponseWriter, req *Request) {
+func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
        transport := p.Transport
        if transport == nil {
-               transport = DefaultTransport
+               transport = http.DefaultTransport
        }
 
-       outreq := new(Request)
+       outreq := new(http.Request)
        *outreq = *req // includes shallow copies of maps, but okay
 
        p.Director(outreq)
@@ -96,7 +97,7 @@ func (p *ReverseProxy) ServeHTTP(rw ResponseWriter, req *Request) {
        // to us.  This is modifying the same underlying map from req
        // (shallow copied above) so we only copy it if necessary.
        if outreq.Header.Get("Connection") != "" {
-               outreq.Header = make(Header)
+               outreq.Header = make(http.Header)
                copyHeader(outreq.Header, req.Header)
                outreq.Header.Del("Connection")
        }
@@ -108,7 +109,7 @@ func (p *ReverseProxy) ServeHTTP(rw ResponseWriter, req *Request) {
        res, err := transport.RoundTrip(outreq)
        if err != nil {
                log.Printf("http: proxy error: %v", err)
-               rw.WriteHeader(StatusInternalServerError)
+               rw.WriteHeader(http.StatusInternalServerError)
                return
        }
 
@@ -129,7 +130,7 @@ func (p *ReverseProxy) ServeHTTP(rw ResponseWriter, req *Request) {
 
 type writeFlusher interface {
        io.Writer
-       Flusher
+       http.Flusher
 }
 
 type maxLatencyWriter struct {
similarity index 84%
rename from libgo/go/http/reverseproxy_test.go
rename to libgo/go/net/http/httputil/reverseproxy_test.go
index 663218d..655784b 100644 (file)
@@ -4,20 +4,20 @@
 
 // Reverse proxy tests.
 
-package http_test
+package httputil
 
 import (
-       . "http"
-       "http/httptest"
        "io/ioutil"
+       "net/http"
+       "net/http/httptest"
+       "net/url"
        "testing"
-       "url"
 )
 
 func TestReverseProxy(t *testing.T) {
        const backendResponse = "I am the backend"
        const backendStatus = 404
-       backend := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
+       backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                if len(r.TransferEncoding) > 0 {
                        t.Errorf("backend got unexpected TransferEncoding: %v", r.TransferEncoding)
                }
@@ -31,7 +31,7 @@ func TestReverseProxy(t *testing.T) {
                        t.Errorf("backend got Host header %q, want %q", g, e)
                }
                w.Header().Set("X-Foo", "bar")
-               SetCookie(w, &Cookie{Name: "flavor", Value: "chocolateChip"})
+               http.SetCookie(w, &http.Cookie{Name: "flavor", Value: "chocolateChip"})
                w.WriteHeader(backendStatus)
                w.Write([]byte(backendResponse))
        }))
@@ -44,11 +44,11 @@ func TestReverseProxy(t *testing.T) {
        frontend := httptest.NewServer(proxyHandler)
        defer frontend.Close()
 
-       getReq, _ := NewRequest("GET", frontend.URL, nil)
+       getReq, _ := http.NewRequest("GET", frontend.URL, nil)
        getReq.Host = "some-name"
        getReq.Header.Set("Connection", "close")
        getReq.Close = true
-       res, err := DefaultClient.Do(getReq)
+       res, err := http.DefaultClient.Do(getReq)
        if err != nil {
                t.Fatalf("Get: %v", err)
        }
similarity index 99%
rename from libgo/go/http/pprof/pprof.go
rename to libgo/go/net/http/pprof/pprof.go
index a118a25..c0327a9 100644 (file)
@@ -28,8 +28,8 @@ import (
        "bufio"
        "bytes"
        "fmt"
-       "http"
        "io"
+       "net/http"
        "os"
        "runtime"
        "runtime/pprof"
similarity index 78%
rename from libgo/go/http/readrequest_test.go
rename to libgo/go/net/http/readrequest_test.go
index d62133d..2219d43 100644 (file)
@@ -9,19 +9,22 @@ import (
        "bytes"
        "fmt"
        "io"
+       "net/url"
+       "reflect"
        "testing"
-       "url"
 )
 
 type reqTest struct {
-       Raw   string
-       Req   *Request
-       Body  string
-       Error string
+       Raw     string
+       Req     *Request
+       Body    string
+       Trailer Header
+       Error   string
 }
 
 var noError = ""
 var noBody = ""
+var noTrailer Header = nil
 
 var reqTests = []reqTest{
        // Baseline test; All Request fields included for template use
@@ -72,6 +75,7 @@ var reqTests = []reqTest{
 
                "abcdef\n",
 
+               noTrailer,
                noError,
        },
 
@@ -97,6 +101,7 @@ var reqTests = []reqTest{
                },
 
                noBody,
+               noTrailer,
                noError,
        },
 
@@ -130,6 +135,7 @@ var reqTests = []reqTest{
                },
 
                noBody,
+               noTrailer,
                noError,
        },
 
@@ -139,6 +145,7 @@ var reqTests = []reqTest{
                        "Host: test\r\n\r\n",
                nil,
                noBody,
+               noTrailer,
                "parse ../../../../etc/passwd: invalid URI for request",
        },
 
@@ -148,8 +155,42 @@ var reqTests = []reqTest{
                        "Host: test\r\n\r\n",
                nil,
                noBody,
+               noTrailer,
                "parse : empty url",
        },
+
+       // Tests chunked body with trailer:
+       {
+               "POST / HTTP/1.1\r\n" +
+                       "Host: foo.com\r\n" +
+                       "Transfer-Encoding: chunked\r\n\r\n" +
+                       "3\r\nfoo\r\n" +
+                       "3\r\nbar\r\n" +
+                       "0\r\n" +
+                       "Trailer-Key: Trailer-Value\r\n" +
+                       "\r\n",
+               &Request{
+                       Method: "POST",
+                       URL: &url.URL{
+                               Raw:     "/",
+                               Path:    "/",
+                               RawPath: "/",
+                       },
+                       TransferEncoding: []string{"chunked"},
+                       Proto:            "HTTP/1.1",
+                       ProtoMajor:       1,
+                       ProtoMinor:       1,
+                       ContentLength:    -1,
+                       Host:             "foo.com",
+                       Form:             url.Values{},
+               },
+
+               "foobar",
+               Header{
+                       "Trailer-Key": {"Trailer-Value"},
+               },
+               noError,
+       },
 }
 
 func TestReadRequest(t *testing.T) {
@@ -169,12 +210,18 @@ func TestReadRequest(t *testing.T) {
                diff(t, fmt.Sprintf("#%d Request", i), req, tt.Req)
                var bout bytes.Buffer
                if rbody != nil {
-                       io.Copy(&bout, rbody)
+                       _, err := io.Copy(&bout, rbody)
+                       if err != nil {
+                               t.Fatalf("#%d. copying body: %v", i, err)
+                       }
                        rbody.Close()
                }
                body := bout.String()
                if body != tt.Body {
                        t.Errorf("#%d: Body = %q want %q", i, body, tt.Body)
                }
+               if !reflect.DeepEqual(tt.Trailer, req.Trailer) {
+                       t.Errorf("%#d. Trailers differ.\n got: %v\nwant: %v", i, req.Trailer, tt.Trailer)
+               }
        }
 }
similarity index 92%
rename from libgo/go/http/request.go
rename to libgo/go/net/http/request.go
index d9a04ef..4410ca1 100644 (file)
@@ -18,9 +18,9 @@ import (
        "mime"
        "mime/multipart"
        "net/textproto"
+       "net/url"
        "strconv"
        "strings"
-       "url"
 )
 
 const (
@@ -69,14 +69,8 @@ var reqWriteExcludeHeader = map[string]bool{
        "Trailer":           true,
 }
 
-var reqWriteExcludeHeaderDump = map[string]bool{
-       "Host":              true, // not in Header map anyway
-       "Content-Length":    true,
-       "Transfer-Encoding": true,
-       "Trailer":           true,
-}
-
-// A Request represents a parsed HTTP request header.
+// A Request represents an HTTP request received by a server
+// or to be sent by a client.
 type Request struct {
        Method string // GET, POST, PUT, etc.
        URL    *url.URL
@@ -113,14 +107,20 @@ type Request struct {
 
        // ContentLength records the length of the associated content.
        // The value -1 indicates that the length is unknown.
-       // Values >= 0 indicate that the given number of bytes may be read from Body.
+       // Values >= 0 indicate that the given number of bytes may
+       // be read from Body.
+       // For outgoing requests, a value of 0 means unknown if Body is not nil.
        ContentLength int64
 
-       // TransferEncoding lists the transfer encodings from outermost to innermost.
-       // An empty list denotes the "identity" encoding.
+       // TransferEncoding lists the transfer encodings from outermost to
+       // innermost. An empty list denotes the "identity" encoding.
+       // TransferEncoding can usually be ignored; chunked encoding is
+       // automatically added and removed as necessary when sending and
+       // receiving requests.
        TransferEncoding []string
 
-       // Whether to close the connection after replying to this request.
+       // Close indicates whether to close the connection after
+       // replying to this request.
        Close bool
 
        // The host on which the URL is sought.
@@ -128,16 +128,23 @@ type Request struct {
        // or the host name given in the URL itself.
        Host string
 
-       // The parsed form. Only available after ParseForm is called.
+       // Form contains the parsed form data, including both the URL
+       // field's query parameters and the POST or PUT form data.
+       // This field is only available after ParseForm is called.
+       // The HTTP client ignores Form and uses Body instead.
        Form url.Values
 
-       // The parsed multipart form, including file uploads.
-       // Only available after ParseMultipartForm is called.
+       // MultipartForm is the parsed multipart form, including file uploads.
+       // This field is only available after ParseMultipartForm is called.
+       // The HTTP client ignores MultipartForm and uses Body instead.
        MultipartForm *multipart.Form
 
        // Trailer maps trailer keys to values.  Like for Header, if the
        // response has multiple trailer lines with the same key, they will be
        // concatenated, delimited by commas.
+       // For server requests, Trailer is only populated after Body has been
+       // closed or fully consumed.
+       // Trailer support is only partially complete.
        Trailer Header
 
        // RemoteAddr allows HTTP servers and other software to record
@@ -146,6 +153,7 @@ type Request struct {
        // has no defined format. The HTTP server in this package
        // sets RemoteAddr to an "IP:port" address before invoking a
        // handler.
+       // This field is ignored by the HTTP client.
        RemoteAddr string
 
        // TLS allows HTTP servers and other software to record
@@ -154,6 +162,7 @@ type Request struct {
        // The HTTP server in this package sets the field for
        // TLS-enabled connections before invoking a handler;
        // otherwise it leaves the field nil.
+       // This field is ignored by the HTTP client.
        TLS *tls.ConnectionState
 }
 
@@ -286,51 +295,6 @@ func (req *Request) WriteProxy(w io.Writer) error {
        return req.write(w, true, nil)
 }
 
-func (req *Request) dumpWrite(w io.Writer) error {
-       // TODO(bradfitz): RawPath here?
-       urlStr := valueOrDefault(req.URL.EncodedPath(), "/")
-       if req.URL.RawQuery != "" {
-               urlStr += "?" + req.URL.RawQuery
-       }
-
-       bw := bufio.NewWriter(w)
-       fmt.Fprintf(bw, "%s %s HTTP/%d.%d\r\n", valueOrDefault(req.Method, "GET"), urlStr,
-               req.ProtoMajor, req.ProtoMinor)
-
-       host := req.Host
-       if host == "" && req.URL != nil {
-               host = req.URL.Host
-       }
-       if host != "" {
-               fmt.Fprintf(bw, "Host: %s\r\n", host)
-       }
-
-       // Process Body,ContentLength,Close,Trailer
-       tw, err := newTransferWriter(req)
-       if err != nil {
-               return err
-       }
-       err = tw.WriteHeader(bw)
-       if err != nil {
-               return err
-       }
-
-       err = req.Header.WriteSubset(bw, reqWriteExcludeHeaderDump)
-       if err != nil {
-               return err
-       }
-
-       io.WriteString(bw, "\r\n")
-
-       // Write body and trailer
-       err = tw.WriteBody(bw)
-       if err != nil {
-               return err
-       }
-       bw.Flush()
-       return nil
-}
-
 // extraHeaders may be nil
 func (req *Request) write(w io.Writer, usingProxy bool, extraHeaders Header) error {
        host := req.Host
@@ -502,16 +466,6 @@ func (cr *chunkedReader) beginChunk() {
                return
        }
        if cr.n == 0 {
-               // trailer CRLF
-               for {
-                       line, cr.err = readLine(cr.r)
-                       if cr.err != nil {
-                               return
-                       }
-                       if line == "" {
-                               break
-                       }
-               }
                cr.err = io.EOF
        }
 }
@@ -734,7 +688,7 @@ func (r *Request) ParseForm() (err error) {
                ct := r.Header.Get("Content-Type")
                ct, _, err := mime.ParseMediaType(ct)
                switch {
-               case ct == "text/plain" || ct == "application/x-www-form-urlencoded" || ct == "":
+               case ct == "application/x-www-form-urlencoded":
                        var reader io.Reader = r.Body
                        maxFormSize := int64(1<<63 - 1)
                        if _, ok := r.Body.(*maxBytesReader); !ok {
similarity index 93%
rename from libgo/go/http/request_test.go
rename to libgo/go/net/http/request_test.go
index 9be9efc..714cb64 100644 (file)
@@ -7,17 +7,17 @@ package http_test
 import (
        "bytes"
        "fmt"
-       . "http"
-       "http/httptest"
        "io"
        "io/ioutil"
        "mime/multipart"
+       . "net/http"
+       "net/http/httptest"
+       "net/url"
        "os"
        "reflect"
        "regexp"
        "strings"
        "testing"
-       "url"
 )
 
 func TestQuery(t *testing.T) {
@@ -29,12 +29,10 @@ func TestQuery(t *testing.T) {
 }
 
 func TestPostQuery(t *testing.T) {
-       req := &Request{Method: "POST"}
-       req.URL, _ = url.Parse("http://www.google.com/search?q=foo&q=bar&both=x")
-       req.Header = Header{
-               "Content-Type": {"application/x-www-form-urlencoded; boo!"},
-       }
-       req.Body = ioutil.NopCloser(strings.NewReader("z=post&both=y"))
+       req, _ := NewRequest("POST", "http://www.google.com/search?q=foo&q=bar&both=x",
+               strings.NewReader("z=post&both=y"))
+       req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
+
        if q := req.FormValue("q"); q != "foo" {
                t.Errorf(`req.FormValue("q") = %q, want "foo"`, q)
        }
@@ -49,7 +47,6 @@ func TestPostQuery(t *testing.T) {
 type stringMap map[string][]string
 type parseContentTypeTest struct {
        contentType stringMap
-       err         bool
 }
 
 var parseContentTypeTests = []parseContentTypeTest{
@@ -58,11 +55,10 @@ var parseContentTypeTests = []parseContentTypeTest{
        {contentType: stringMap{"Content-Type": {"text/plain; boundary="}}},
        {
                contentType: stringMap{"Content-Type": {"application/unknown"}},
-               err:         true,
        },
 }
 
-func TestPostContentTypeParsing(t *testing.T) {
+func TestParseFormBadContentType(t *testing.T) {
        for i, test := range parseContentTypeTests {
                req := &Request{
                        Method: "POST",
@@ -70,10 +66,7 @@ func TestPostContentTypeParsing(t *testing.T) {
                        Body:   ioutil.NopCloser(bytes.NewBufferString("body")),
                }
                err := req.ParseForm()
-               if !test.err && err != nil {
-                       t.Errorf("test %d: Unexpected error: %v", i, err)
-               }
-               if test.err && err == nil {
+               if err == nil {
                        t.Errorf("test %d should have returned error", i)
                }
        }
similarity index 93%
rename from libgo/go/http/requestwrite_test.go
rename to libgo/go/net/http/requestwrite_test.go
index 16593e9..8081589 100644 (file)
@@ -10,9 +10,9 @@ import (
        "fmt"
        "io"
        "io/ioutil"
+       "net/url"
        "strings"
        "testing"
-       "url"
 )
 
 type reqWriteTest struct {
@@ -22,7 +22,6 @@ type reqWriteTest struct {
        // Any of these three may be empty to skip that test.
        WantWrite string // Request.Write
        WantProxy string // Request.WriteProxy
-       WantDump  string // DumpRequest
 
        WantError error // wanted error from Request.Write
 }
@@ -109,11 +108,6 @@ var reqWriteTests = []reqWriteTest{
                        "User-Agent: Go http package\r\n" +
                        "Transfer-Encoding: chunked\r\n\r\n" +
                        chunk("abcdef") + chunk(""),
-
-               WantDump: "GET /search HTTP/1.1\r\n" +
-                       "Host: www.google.com\r\n" +
-                       "Transfer-Encoding: chunked\r\n\r\n" +
-                       chunk("abcdef") + chunk(""),
        },
        // HTTP/1.1 POST => chunked coding; body; empty trailer
        {
@@ -335,13 +329,6 @@ var reqWriteTests = []reqWriteTest{
                        },
                },
 
-               // We can dump it:
-               WantDump: "GET /foo HTTP/1.0\r\n" +
-                       "X-Foo: X-Bar\r\n\r\n",
-
-               // .. but we can't call Request.Write on it, due to its lack of Host header.
-               // TODO(bradfitz): there might be an argument to allow this, but for now I'd
-               // rather let HTTP/1.0 continue to die.
                WantWrite: "GET /foo HTTP/1.1\r\n" +
                        "Host: \r\n" +
                        "User-Agent: Go http package\r\n" +
@@ -401,19 +388,6 @@ func TestRequestWrite(t *testing.T) {
                                continue
                        }
                }
-
-               if tt.WantDump != "" {
-                       setBody()
-                       dump, err := DumpRequest(&tt.Req, true)
-                       if err != nil {
-                               t.Errorf("DumpRequest #%d: %s", i, err)
-                               continue
-                       }
-                       if string(dump) != tt.WantDump {
-                               t.Errorf("DumpRequest %d, expecting:\n%s\nGot:\n%s\n", i, tt.WantDump, string(dump))
-                               continue
-                       }
-               }
        }
 }
 
similarity index 99%
rename from libgo/go/http/response.go
rename to libgo/go/net/http/response.go
index 7be7150..ae314b5 100644 (file)
@@ -11,9 +11,9 @@ import (
        "errors"
        "io"
        "net/textproto"
+       "net/url"
        "strconv"
        "strings"
-       "url"
 )
 
 var respExcludeHeader = map[string]bool{
similarity index 99%
rename from libgo/go/http/response_test.go
rename to libgo/go/net/http/response_test.go
index 6a14179..be717aa 100644 (file)
@@ -12,9 +12,9 @@ import (
        "fmt"
        "io"
        "io/ioutil"
+       "net/url"
        "reflect"
        "testing"
-       "url"
 )
 
 type respTest struct {
similarity index 99%
rename from libgo/go/http/serve_test.go
rename to libgo/go/net/http/serve_test.go
index 98e10d4..e278396 100644 (file)
@@ -11,19 +11,20 @@ import (
        "bytes"
        "crypto/tls"
        "fmt"
-       . "http"
-       "http/httptest"
        "io"
        "io/ioutil"
        "log"
        "net"
+       . "net/http"
+       "net/http/httptest"
+       "net/http/httputil"
+       "net/url"
        "os"
        "reflect"
        "strings"
        "syscall"
        "testing"
        "time"
-       "url"
 )
 
 type dummyAddr string
@@ -181,7 +182,7 @@ func TestHostHandlers(t *testing.T) {
                t.Fatal(err)
        }
        defer conn.Close()
-       cc := NewClientConn(conn, nil)
+       cc := httputil.NewClientConn(conn, nil)
        for _, vt := range vtests {
                var r *Response
                var req Request
@@ -824,7 +825,7 @@ func TestRedirectMunging(t *testing.T) {
 // explicit Content-Length of zero is present), then the transport can re-use the
 // connection immediately. But when it re-uses the connection, it typically closes
 // the previous request's body, which is not optimal for zero-lengthed bodies,
-// as the client would then see http.ErrBodyReadAfterClose and not 0, os.EOF.
+// as the client would then see http.ErrBodyReadAfterClose and not 0, io.EOF.
 func TestZeroLengthPostAndResponse(t *testing.T) {
        ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
                all, err := ioutil.ReadAll(r.Body)
similarity index 99%
rename from libgo/go/http/server.go
rename to libgo/go/net/http/server.go
index f2a4f01..8c48894 100644 (file)
@@ -20,13 +20,13 @@ import (
        "io/ioutil"
        "log"
        "net"
+       "net/url"
        "path"
        "runtime/debug"
        "strconv"
        "strings"
        "sync"
        "time"
-       "url"
 )
 
 // Errors introduced by the HTTP server.
similarity index 97%
rename from libgo/go/http/sniff.go
rename to libgo/go/net/http/sniff.go
index d608687..5707c7f 100644 (file)
@@ -11,7 +11,7 @@ import (
 
 // Content-type sniffing algorithm.
 // References in this file refer to this draft specification:
-//   http://tools.ietf.org/html/draft-ietf-websec-mime-sniff-03
+//   http://mimesniff.spec.whatwg.org/
 
 // The algorithm prefers to use sniffLen bytes to make its decision.
 const sniffLen = 512
@@ -38,7 +38,7 @@ func DetectContentType(data []byte) string {
 }
 
 func isWS(b byte) bool {
-       return bytes.IndexByte([]byte("\t\n\x0C\n "), b) != -1
+       return bytes.IndexByte([]byte("\t\n\x0C\r "), b) != -1
 }
 
 type sniffSig interface {
similarity index 95%
rename from libgo/go/http/sniff_test.go
rename to libgo/go/net/http/sniff_test.go
index faf05e4..a414e64 100644 (file)
@@ -6,10 +6,10 @@ package http_test
 
 import (
        "bytes"
-       . "http"
-       "http/httptest"
        "io/ioutil"
        "log"
+       . "net/http"
+       "net/http/httptest"
        "strconv"
        "testing"
 )
@@ -26,6 +26,7 @@ var sniffTests = []struct {
        {"HTML document #1", []byte(`<HtMl><bOdY>blah blah blah</body></html>`), "text/html; charset=utf-8"},
        {"HTML document #2", []byte(`<HTML></HTML>`), "text/html; charset=utf-8"},
        {"HTML document #3 (leading whitespace)", []byte(`   <!DOCTYPE HTML>...`), "text/html; charset=utf-8"},
+       {"HTML document #4 (leading CRLF)", []byte("\r\n<html>..."), "text/html; charset=utf-8"},
 
        {"Plain text", []byte(`This is not HTML. It has â˜ƒ though.`), "text/plain; charset=utf-8"},
 
similarity index 89%
rename from libgo/go/http/transfer.go
rename to libgo/go/net/http/transfer.go
index 6cb8625..2670d77 100644 (file)
@@ -5,12 +5,13 @@
 package http
 
 import (
-       "bytes"
        "bufio"
+       "bytes"
        "errors"
        "fmt"
        "io"
        "io/ioutil"
+       "net/textproto"
        "strconv"
        "strings"
 )
@@ -187,7 +188,7 @@ func (t *transferWriter) WriteBody(w io.Writer) (err error) {
        // Write body
        if t.Body != nil {
                if chunked(t.TransferEncoding) {
-                       cw := NewChunkedWriter(w)
+                       cw := newChunkedWriter(w)
                        _, err = io.Copy(cw, t.Body)
                        if err == nil {
                                err = cw.Close()
@@ -319,7 +320,7 @@ func readTransfer(msg interface{}, r *bufio.Reader) (err error) {
        // or close connection when finished, since multipart is not supported yet
        switch {
        case chunked(t.TransferEncoding):
-               t.Body = &body{Reader: NewChunkedReader(r), hdr: msg, r: r, closing: t.Close}
+               t.Body = &body{Reader: newChunkedReader(r), hdr: msg, r: r, closing: t.Close}
        case t.ContentLength >= 0:
                // TODO: limit the Content-Length. This is an easy DoS vector.
                t.Body = &body{Reader: io.LimitReader(r, t.ContentLength), closing: t.Close}
@@ -532,7 +533,68 @@ func (b *body) Read(p []byte) (n int, err error) {
        if b.closed {
                return 0, ErrBodyReadAfterClose
        }
-       return b.Reader.Read(p)
+       n, err = b.Reader.Read(p)
+
+       // Read the final trailer once we hit EOF.
+       if err == io.EOF && b.hdr != nil {
+               err = b.readTrailer()
+               b.hdr = nil
+       }
+       return n, err
+}
+
+var (
+       singleCRLF = []byte("\r\n")
+       doubleCRLF = []byte("\r\n\r\n")
+)
+
+func seeUpcomingDoubleCRLF(r *bufio.Reader) bool {
+       for peekSize := 4; ; peekSize++ {
+               // This loop stops when Peek returns an error,
+               // which it does when r's buffer has been filled.
+               buf, err := r.Peek(peekSize)
+               if bytes.HasSuffix(buf, doubleCRLF) {
+                       return true
+               }
+               if err != nil {
+                       break
+               }
+       }
+       return false
+}
+
+func (b *body) readTrailer() error {
+       // The common case, since nobody uses trailers.
+       buf, _ := b.r.Peek(2)
+       if bytes.Equal(buf, singleCRLF) {
+               b.r.ReadByte()
+               b.r.ReadByte()
+               return nil
+       }
+
+       // Make sure there's a header terminator coming up, to prevent
+       // a DoS with an unbounded size Trailer.  It's not easy to
+       // slip in a LimitReader here, as textproto.NewReader requires
+       // a concrete *bufio.Reader.  Also, we can't get all the way
+       // back up to our conn's LimitedReader that *might* be backing
+       // this bufio.Reader.  Instead, a hack: we iteratively Peek up
+       // to the bufio.Reader's max size, looking for a double CRLF.
+       // This limits the trailer to the underlying buffer size, typically 4kB.
+       if !seeUpcomingDoubleCRLF(b.r) {
+               return errors.New("http: suspiciously long trailer after chunked body")
+       }
+
+       hdr, err := textproto.NewReader(b.r).ReadMIMEHeader()
+       if err != nil {
+               return err
+       }
+       switch rr := b.hdr.(type) {
+       case *Request:
+               rr.Trailer = Header(hdr)
+       case *Response:
+               rr.Trailer = Header(hdr)
+       }
+       return nil
 }
 
 func (b *body) Close() error {
@@ -557,15 +619,10 @@ func (b *body) Close() error {
                return nil
        }
 
+       // Fully consume the body, which will also lead to us reading
+       // the trailer headers after the body, if present.
        if _, err := io.Copy(ioutil.Discard, b); err != nil {
                return err
        }
-
-       if b.hdr == nil { // not reading trailer
-               return nil
-       }
-
-       // TODO(petar): Put trailer reader code here
-
        return nil
 }
similarity index 95%
rename from libgo/go/http/transport.go
rename to libgo/go/net/http/transport.go
index c7041cb..da5244b 100644 (file)
@@ -20,10 +20,10 @@ import (
        "io/ioutil"
        "log"
        "net"
+       "net/url"
        "os"
        "strings"
        "sync"
-       "url"
 )
 
 // DefaultTransport is the default implementation of Transport and is
@@ -372,7 +372,7 @@ func (t *Transport) getConn(cm *connectMethod) (*persistConn, error) {
        }
 
        pconn.br = bufio.NewReader(pconn.conn)
-       pconn.cc = NewClientConn(conn, pconn.br)
+       pconn.bw = bufio.NewWriter(pconn.conn)
        go pconn.readLoop()
        return pconn, nil
 }
@@ -474,8 +474,8 @@ type persistConn struct {
        t        *Transport
        cacheKey string // its connectMethod.String()
        conn     net.Conn
-       cc       *ClientConn
-       br       *bufio.Reader
+       br       *bufio.Reader       // from conn
+       bw       *bufio.Writer       // to conn
        reqch    chan requestAndChan // written by roundTrip(); read by readLoop()
        isProxy  bool
 
@@ -515,6 +515,8 @@ func remoteSideClosed(err error) bool {
 
 func (pc *persistConn) readLoop() {
        alive := true
+       var lastbody io.ReadCloser // last response body, if any, read on this connection
+
        for alive {
                pb, err := pc.br.Peek(1)
                if err != nil {
@@ -533,33 +535,32 @@ func (pc *persistConn) readLoop() {
                }
 
                rc := <-pc.reqch
-               resp, err := pc.cc.readUsing(rc.req, func(buf *bufio.Reader, forReq *Request) (*Response, error) {
-                       resp, err := ReadResponse(buf, forReq)
-                       if err != nil || resp.ContentLength == 0 {
-                               return resp, err
-                       }
+
+               // Advance past the previous response's body, if the
+               // caller hasn't done so.
+               if lastbody != nil {
+                       lastbody.Close() // assumed idempotent
+                       lastbody = nil
+               }
+               resp, err := ReadResponse(pc.br, rc.req)
+
+               if err == nil {
                        if rc.addedGzip && resp.Header.Get("Content-Encoding") == "gzip" {
                                resp.Header.Del("Content-Encoding")
                                resp.Header.Del("Content-Length")
                                resp.ContentLength = -1
-                               gzReader, err := gzip.NewReader(resp.Body)
+                               gzReader, zerr := gzip.NewReader(resp.Body)
                                if err != nil {
                                        pc.close()
-                                       return nil, err
+                                       err = zerr
+                               } else {
+                                       resp.Body = &readFirstCloseBoth{&discardOnCloseReadCloser{gzReader}, resp.Body}
                                }
-                               resp.Body = &readFirstCloseBoth{&discardOnCloseReadCloser{gzReader}, resp.Body}
                        }
                        resp.Body = &bodyEOFSignal{body: resp.Body}
-                       return resp, err
-               })
+               }
 
-               if err == ErrPersistEOF {
-                       // Succeeded, but we can't send any more
-                       // persistent connections on this again.  We
-                       // hide this error to upstream callers.
-                       alive = false
-                       err = nil
-               } else if err != nil || rc.req.Close {
+               if err != nil || resp.Close || rc.req.Close {
                        alive = false
                }
 
@@ -567,6 +568,7 @@ func (pc *persistConn) readLoop() {
                var waitForBodyRead chan bool
                if alive {
                        if hasBody {
+                               lastbody = resp.Body
                                waitForBodyRead = make(chan bool)
                                resp.Body.(*bodyEOFSignal).fn = func() {
                                        pc.t.putIdleConn(pc)
@@ -580,9 +582,7 @@ func (pc *persistConn) readLoop() {
                                // loop, otherwise it might close the body
                                // before the client code has had a chance to
                                // read it (even though it'll just be 0, EOF).
-                               pc.cc.lk.Lock()
-                               pc.cc.lastbody = nil
-                               pc.cc.lk.Unlock()
+                               lastbody = nil
 
                                pc.t.putIdleConn(pc)
                        }
@@ -635,15 +635,12 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err
        pc.numExpectedResponses++
        pc.lk.Unlock()
 
-       pc.cc.writeReq = func(r *Request, w io.Writer) error {
-               return r.write(w, pc.isProxy, req.extra)
-       }
-
-       err = pc.cc.Write(req.Request)
+       err = req.Request.write(pc.bw, pc.isProxy, req.extra)
        if err != nil {
                pc.close()
                return
        }
+       pc.bw.Flush()
 
        ch := make(chan responseAndError, 1)
        pc.reqch <- requestAndChan{req.Request, ch, requestedGzip}
@@ -659,7 +656,6 @@ func (pc *persistConn) close() {
        pc.lk.Lock()
        defer pc.lk.Unlock()
        pc.broken = true
-       pc.cc.Close()
        pc.conn.Close()
        pc.mutateHeaderFunc = nil
 }
similarity index 99%
rename from libgo/go/http/transport_test.go
rename to libgo/go/net/http/transport_test.go
index b2d0eba..7729797 100644 (file)
@@ -11,15 +11,15 @@ import (
        "compress/gzip"
        "crypto/rand"
        "fmt"
-       . "http"
-       "http/httptest"
        "io"
        "io/ioutil"
+       . "net/http"
+       "net/http/httptest"
+       "net/url"
        "strconv"
        "strings"
        "testing"
        "time"
-       "url"
 )
 
 // TODO: test 5 pipelined requests with responses: 1) OK, 2) OK, Connection: Close
similarity index 100%
rename from libgo/go/http/transport_windows.go
rename to libgo/go/net/http/transport_windows.go
index e0dc857..2a20d22 100644 (file)
@@ -5,8 +5,8 @@
 package http
 
 import (
-       "os"
        "net"
+       "os"
 )
 
 func init() {
diff --git a/libgo/go/net/http/triv.go b/libgo/go/net/http/triv.go
new file mode 100644 (file)
index 0000000..994fc0e
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+       "bytes"
+       "expvar"
+       "flag"
+       "fmt"
+       "io"
+       "log"
+       "net/http"
+       "os"
+       "strconv"
+)
+
+// hello world, the web server
+var helloRequests = expvar.NewInt("hello-requests")
+
+func HelloServer(w http.ResponseWriter, req *http.Request) {
+       helloRequests.Add(1)
+       io.WriteString(w, "hello, world!\n")
+}
+
+// Simple counter server. POSTing to it will set the value.
+type Counter struct {
+       n int
+}
+
+// This makes Counter satisfy the expvar.Var interface, so we can export
+// it directly.
+func (ctr *Counter) String() string { return fmt.Sprintf("%d", ctr.n) }
+
+func (ctr *Counter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+       switch req.Method {
+       case "GET":
+               ctr.n++
+       case "POST":
+               buf := new(bytes.Buffer)
+               io.Copy(buf, req.Body)
+               body := buf.String()
+               if n, err := strconv.Atoi(body); err != nil {
+                       fmt.Fprintf(w, "bad POST: %v\nbody: [%v]\n", err, body)
+               } else {
+                       ctr.n = n
+                       fmt.Fprint(w, "counter reset\n")
+               }
+       }
+       fmt.Fprintf(w, "counter = %d\n", ctr.n)
+}
+
+// simple flag server
+var booleanflag = flag.Bool("boolean", true, "another flag for testing")
+
+func FlagServer(w http.ResponseWriter, req *http.Request) {
+       w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+       fmt.Fprint(w, "Flags:\n")
+       flag.VisitAll(func(f *flag.Flag) {
+               if f.Value.String() != f.DefValue {
+                       fmt.Fprintf(w, "%s = %s [default = %s]\n", f.Name, f.Value.String(), f.DefValue)
+               } else {
+                       fmt.Fprintf(w, "%s = %s\n", f.Name, f.Value.String())
+               }
+       })
+}
+
+// simple argument server
+func ArgServer(w http.ResponseWriter, req *http.Request) {
+       for _, s := range os.Args {
+               fmt.Fprint(w, s, " ")
+       }
+}
+
+// a channel (just for the fun of it)
+type Chan chan int
+
+func ChanCreate() Chan {
+       c := make(Chan)
+       go func(c Chan) {
+               for x := 0; ; x++ {
+                       c <- x
+               }
+       }(c)
+       return c
+}
+
+func (ch Chan) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+       io.WriteString(w, fmt.Sprintf("channel send #%d\n", <-ch))
+}
+
+// exec a program, redirecting output
+func DateServer(rw http.ResponseWriter, req *http.Request) {
+       rw.Header().Set("Content-Type", "text/plain; charset=utf-8")
+       r, w, err := os.Pipe()
+       if err != nil {
+               fmt.Fprintf(rw, "pipe: %s\n", err)
+               return
+       }
+
+       p, err := os.StartProcess("/bin/date", []string{"date"}, &os.ProcAttr{Files: []*os.File{nil, w, w}})
+       defer r.Close()
+       w.Close()
+       if err != nil {
+               fmt.Fprintf(rw, "fork/exec: %s\n", err)
+               return
+       }
+       defer p.Release()
+       io.Copy(rw, r)
+       wait, err := p.Wait(0)
+       if err != nil {
+               fmt.Fprintf(rw, "wait: %s\n", err)
+               return
+       }
+       if !wait.Exited() || wait.ExitStatus() != 0 {
+               fmt.Fprintf(rw, "date: %v\n", wait)
+               return
+       }
+}
+
+func Logger(w http.ResponseWriter, req *http.Request) {
+       log.Print(req.URL.Raw)
+       w.WriteHeader(404)
+       w.Write([]byte("oops"))
+}
+
+var webroot = flag.String("root", "/home/rsc", "web root directory")
+
+func main() {
+       flag.Parse()
+
+       // The counter is published as a variable directly.
+       ctr := new(Counter)
+       http.Handle("/counter", ctr)
+       expvar.Publish("counter", ctr)
+
+       http.Handle("/", http.HandlerFunc(Logger))
+       http.Handle("/go/", http.StripPrefix("/go/", http.FileServer(http.Dir(*webroot))))
+       http.Handle("/flags", http.HandlerFunc(FlagServer))
+       http.Handle("/args", http.HandlerFunc(ArgServer))
+       http.Handle("/go/hello", http.HandlerFunc(HelloServer))
+       http.Handle("/chan", ChanCreate())
+       http.Handle("/date", http.HandlerFunc(DateServer))
+       err := http.ListenAndServe(":12345", nil)
+       if err != nil {
+               log.Panicln("ListenAndServe:", err)
+       }
+}
index 0ca315e..df647ef 100644 (file)
@@ -7,8 +7,8 @@ package net
 import (
        "bytes"
        "reflect"
-       "testing"
        "runtime"
+       "testing"
 )
 
 func isEqual(a, b []byte) bool {
index 6b7e53d..9a39ca8 100644 (file)
@@ -52,10 +52,6 @@ func TestGmailMX(t *testing.T) {
 }
 
 func TestGmailTXT(t *testing.T) {
-       if runtime.GOOS == "windows" {
-               t.Logf("LookupTXT is not implemented on Windows")
-               return
-       }
        if testing.Short() || avoidMacFirewall {
                t.Logf("skipping test to avoid external network")
                return
index 53cb8f4..61d8a88 100644 (file)
@@ -5,11 +5,10 @@
 package net
 
 import (
-       "errors"
-       "syscall"
-       "unsafe"
        "os"
        "sync"
+       "syscall"
+       "unsafe"
 )
 
 var (
@@ -81,7 +80,7 @@ func LookupPort(network, service string) (port int, err error) {
 func LookupCNAME(name string) (cname string, err error) {
        var r *syscall.DNSRecord
        e := syscall.DnsQuery(name, syscall.DNS_TYPE_CNAME, 0, nil, &r, nil)
-       if int(e) != 0 {
+       if e != 0 {
                return "", os.NewSyscallError("LookupCNAME", int(e))
        }
        defer syscall.DnsRecordListFree(r, 1)
@@ -110,7 +109,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
        }
        var r *syscall.DNSRecord
        e := syscall.DnsQuery(target, syscall.DNS_TYPE_SRV, 0, nil, &r, nil)
-       if int(e) != 0 {
+       if e != 0 {
                return "", nil, os.NewSyscallError("LookupSRV", int(e))
        }
        defer syscall.DnsRecordListFree(r, 1)
@@ -126,7 +125,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
 func LookupMX(name string) (mx []*MX, err error) {
        var r *syscall.DNSRecord
        e := syscall.DnsQuery(name, syscall.DNS_TYPE_MX, 0, nil, &r, nil)
-       if int(e) != 0 {
+       if e != 0 {
                return nil, os.NewSyscallError("LookupMX", int(e))
        }
        defer syscall.DnsRecordListFree(r, 1)
@@ -140,7 +139,21 @@ func LookupMX(name string) (mx []*MX, err error) {
 }
 
 func LookupTXT(name string) (txt []string, err error) {
-       return nil, errors.New("net.LookupTXT is not implemented on Windows")
+       var r *syscall.DNSRecord
+       e := syscall.DnsQuery(name, syscall.DNS_TYPE_TEXT, 0, nil, &r, nil)
+       if e != 0 {
+               return nil, os.NewSyscallError("LookupTXT", int(e))
+       }
+       defer syscall.DnsRecordListFree(r, 1)
+       txt = make([]string, 0, 10)
+       if r != nil && r.Type == syscall.DNS_TYPE_TEXT {
+               d := (*syscall.DNSTXTData)(unsafe.Pointer(&r.Data[0]))
+               for _, v := range (*[1 << 10]*uint16)(unsafe.Pointer(&(d.StringArray[0])))[:d.StringCount] {
+                       s := syscall.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(v))[:])
+                       txt = append(txt, s)
+               }
+       }
+       return
 }
 
 func LookupAddr(addr string) (name []string, err error) {
@@ -150,7 +163,7 @@ func LookupAddr(addr string) (name []string, err error) {
        }
        var r *syscall.DNSRecord
        e := syscall.DnsQuery(arpa, syscall.DNS_TYPE_PTR, 0, nil, &r, nil)
-       if int(e) != 0 {
+       if e != 0 {
                return nil, os.NewSyscallError("LookupAddr", int(e))
        }
        defer syscall.DnsRecordListFree(r, 1)
index e1488ef..d09ebf0 100644 (file)
@@ -147,7 +147,7 @@ func TestShutdown(t *testing.T) {
                var buf [10]byte
                n, err := c.Read(buf[:])
                if n != 0 || err != io.EOF {
-                       t.Fatalf("server Read = %d, %v; want 0, os.EOF", n, err)
+                       t.Fatalf("server Read = %d, %v; want 0, io.EOF", n, err)
                }
                c.Write([]byte("response"))
                c.Close()
index 8d51eba..dfbaba4 100644 (file)
@@ -7,8 +7,8 @@ package net
 import (
        "bufio"
        "os"
-       "testing"
        "runtime"
+       "testing"
 )
 
 func TestReadLine(t *testing.T) {
similarity index 99%
rename from libgo/go/rpc/client.go
rename to libgo/go/net/rpc/client.go
index ecc84de..6fb414e 100644 (file)
@@ -6,12 +6,12 @@ package rpc
 
 import (
        "bufio"
+       "encoding/gob"
        "errors"
-       "gob"
-       "http"
        "io"
        "log"
        "net"
+       "net/http"
        "sync"
 )
 
similarity index 98%
rename from libgo/go/rpc/debug.go
rename to libgo/go/net/rpc/debug.go
index 02d577f..663663f 100644 (file)
@@ -11,9 +11,9 @@ package rpc
 
 import (
        "fmt"
-       "http"
+       "net/http"
        "sort"
-       "template"
+       "text/template"
 )
 
 const debugText = `<html>
similarity index 99%
rename from libgo/go/rpc/jsonrpc/all_test.go
rename to libgo/go/net/rpc/jsonrpc/all_test.go
index 1451a0f..e6c7441 100644 (file)
@@ -5,12 +5,12 @@
 package jsonrpc
 
 import (
+       "encoding/json"
        "errors"
        "fmt"
        "io"
-       "json"
        "net"
-       "rpc"
+       "net/rpc"
        "testing"
 )
 
similarity index 99%
rename from libgo/go/rpc/jsonrpc/client.go
rename to libgo/go/net/rpc/jsonrpc/client.go
index f0475f0..3fa8cbf 100644 (file)
@@ -7,11 +7,11 @@
 package jsonrpc
 
 import (
+       "encoding/json"
        "fmt"
        "io"
-       "json"
        "net"
-       "rpc"
+       "net/rpc"
        "sync"
 )
 
similarity index 99%
rename from libgo/go/rpc/jsonrpc/server.go
rename to libgo/go/net/rpc/jsonrpc/server.go
index 9fe3470..4c54553 100644 (file)
@@ -5,10 +5,10 @@
 package jsonrpc
 
 import (
+       "encoding/json"
        "errors"
        "io"
-       "json"
-       "rpc"
+       "net/rpc"
        "sync"
 )
 
similarity index 99%
rename from libgo/go/rpc/server.go
rename to libgo/go/net/rpc/server.go
index d031533..920ae91 100644 (file)
@@ -114,17 +114,17 @@ package rpc
 
 import (
        "bufio"
+       "encoding/gob"
        "errors"
-       "gob"
-       "http"
        "io"
        "log"
        "net"
+       "net/http"
        "reflect"
        "strings"
        "sync"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 const (
similarity index 99%
rename from libgo/go/rpc/server_test.go
rename to libgo/go/net/rpc/server_test.go
index 119de7f..f289521 100644 (file)
@@ -7,10 +7,10 @@ package rpc
 import (
        "errors"
        "fmt"
-       "http/httptest"
        "io"
        "log"
        "net"
+       "net/http/httptest"
        "runtime"
        "strings"
        "sync"
index 9e54449..7d17ccd 100644 (file)
@@ -8,10 +8,10 @@ import (
        "flag"
        "io"
        "os"
+       "runtime"
        "strings"
        "syscall"
        "testing"
-       "runtime"
 )
 
 // Do not test empty datagrams by default.
index c59802f..7025edf 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin freebsd
+// +build darwin freebsd openbsd
 
 // Sockets for BSD variants
 
index 658b5c2..793c6c2 100644 (file)
@@ -299,7 +299,7 @@ func (r *Reader) ReadResponse(expectCode int) (code int, message string, err err
 //
 // The decoded form returned by the Reader's Read method
 // rewrites the "\r\n" line endings into the simpler "\n",
-// removes leading dot escapes if present, and stops with error os.EOF
+// removes leading dot escapes if present, and stops with error io.EOF
 // after consuming (and discarding) the end-of-sequence line.
 func (r *Reader) DotReader() io.Reader {
        r.closeDot()
similarity index 100%
rename from libgo/go/url/url.go
rename to libgo/go/net/url/url.go
index 855b717..dfd1fd0 100644 (file)
@@ -5,8 +5,8 @@
 package netchan
 
 import (
+       "encoding/gob"
        "errors"
-       "gob"
        "io"
        "reflect"
        "sync"
index a4c4c6a..d698dd5 100644 (file)
@@ -23,8 +23,8 @@ package netchan
 
 import (
        "errors"
-       "log"
        "io"
+       "log"
        "net"
        "reflect"
        "strconv"
index 720aaf3..86df4de 100644 (file)
@@ -72,7 +72,7 @@ import (
        "bytes"
        "io"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 var debug = false
index fc9885f..b8c8064 100644 (file)
@@ -14,7 +14,7 @@ import (
        "strconv"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // Errors returned during parsing and execution.  Users may extract the information and reformat
index c883469..9462c7e 100644 (file)
@@ -6,10 +6,10 @@ package template
 
 import (
        "bytes"
+       "encoding/json"
        "fmt"
        "io"
        "io/ioutil"
-       "json"
        "strings"
        "testing"
 )
index e59c1af..a16bcf6 100644 (file)
@@ -19,7 +19,7 @@ const (
 //
 // If n > 0, Readdirnames returns at most n names. In this case, if
 // Readdirnames returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
+// explaining why. At the end of a directory, the error is io.EOF.
 //
 // If n <= 0, Readdirnames returns all the names from the directory in
 // a single slice. In this case, if Readdirnames succeeds (reads all
index 762734a..9757aa9 100644 (file)
@@ -7,7 +7,7 @@
 package os
 
 import (
-       "error"
+       "errors"
        "syscall"
 )
 
index 795da21..4e90385 100644 (file)
@@ -9,7 +9,7 @@ package os
 import (
        "errors"
        "syscall"
-       "utf16"
+       "unicode/utf16"
        "unsafe"
 )
 
index 1e5114d..e087070 100644 (file)
@@ -28,7 +28,7 @@ func NewSyscallError(syscall string, err syscall.Error) error {
        if err == nil {
                return nil
        }
-       return &SyscallError{syscall, err.String()}
+       return &SyscallError{syscall, err.Error()}
 }
 
 var (
similarity index 100%
rename from libgo/go/exec/exec_test.go
rename to libgo/go/os/exec/exec_test.go
index 6d5e893..8f63653 100644 (file)
@@ -10,11 +10,11 @@ import (
        "fmt"
        "io"
        "io/ioutil"
-       "testing"
        "os"
        "runtime"
        "strconv"
        "strings"
+       "testing"
 )
 
 func helperCommand(s ...string) *Cmd {
index a815c99..a1a3353 100644 (file)
@@ -5,6 +5,7 @@
 package os
 
 import (
+       "errors"
        "runtime"
        "syscall"
 )
@@ -47,7 +48,7 @@ func (note Plan9Note) String() string {
 
 func (p *Process) Signal(sig Signal) error {
        if p.done {
-               return NewError("os: process already finished")
+               return errors.New("os: process already finished")
        }
 
        f, e := OpenFile("/proc/"+itoa(p.Pid)+"/note", O_WRONLY, 0)
index f196f1f..a7ccb33 100644 (file)
@@ -39,7 +39,7 @@ func NewFile(fd int, name string) *File {
 
 // Auxiliary information if the File describes a directory
 type dirInfo struct {
-       buf  []byte // buffer for directory I/O
+       buf []byte       // buffer for directory I/O
        dir *syscall.DIR // from opendir
 }
 
@@ -79,7 +79,7 @@ func (file *File) Close() error {
        }
 
        if file.dirinfo != nil {
-               if libc_closedir(file.dirinfo.dir) < 0  && err == nil {
+               if libc_closedir(file.dirinfo.dir) < 0 && err == nil {
                        err = &PathError{"closedir", file.name, Errno(syscall.GetErrno())}
                }
        }
@@ -142,7 +142,7 @@ func Lstat(name string) (fi *FileInfo, err error) {
 //
 // If n > 0, Readdir returns at most n FileInfo structures. In this case, if
 // Readdir returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
+// explaining why. At the end of a directory, the error is io.EOF.
 //
 // If n <= 0, Readdir returns all the FileInfo from the directory in
 // a single slice. In this case, if Readdir succeeds (reads all
index f0da186..89d66c2 100644 (file)
@@ -7,9 +7,9 @@ package os_test
 import (
        . "os"
        "path/filepath"
-       "testing"
        "runtime"
        "syscall"
+       "testing"
 )
 
 func TestMkdirAll(t *testing.T) {
index bc0930e..8cf1f9a 100644 (file)
@@ -9,7 +9,7 @@ import (
        "os"
        "sort"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 var ErrBadPattern = errors.New("syntax error in pattern")
index bf253a4..dc0fff2 100644 (file)
@@ -6,8 +6,8 @@ package filepath_test
 
 import (
        . "path/filepath"
-       "testing"
        "runtime"
+       "testing"
 )
 
 type MatchTest struct {
index bc685f4..ba7e4de 100644 (file)
@@ -7,7 +7,7 @@ package path
 import (
        "errors"
        "strings"
-       "utf8"
+       "unicode/utf8"
 )
 
 var ErrBadPattern = errors.New("syntax error in pattern")
index 499d1a5..d981f54 100644 (file)
@@ -9,15 +9,15 @@ import (
        "compress/bzip2"
        "fmt"
        "io"
+       "math/rand"
        old "old/regexp"
        "os"
        "path/filepath"
-       "rand"
        "regexp/syntax"
        "strconv"
        "strings"
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 // TestRE2 tests this package's regexp API against test cases
index 9e9fb85..b906076 100644 (file)
@@ -60,7 +60,7 @@ import (
        "strconv"
        "strings"
        "sync"
-       "utf8"
+       "unicode/utf8"
 )
 
 var debug = false
index ba5c0a1..2ad682f 100644 (file)
@@ -8,7 +8,7 @@ import (
        "sort"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // An Error describes a failure to parse a regular expression
diff --git a/libgo/go/regexp/testdata/re2-exhaustive.txt.bz2 b/libgo/go/regexp/testdata/re2-exhaustive.txt.bz2
new file mode 100644 (file)
index 0000000..a357f28
Binary files /dev/null and b/libgo/go/regexp/testdata/re2-exhaustive.txt.bz2 differ
index b3af221..eb7a445 100644 (file)
@@ -18,6 +18,7 @@ var F64toint = f64toint
 
 func entersyscall()
 func exitsyscall()
+func LockedOSThread() bool
 
 /* Useless for gccgo.
 
index fb7f3d3..df63010 100644 (file)
@@ -6,7 +6,7 @@ package runtime_test
 
 import (
        "math"
-       "rand"
+       "math/rand"
        . "runtime"
        "testing"
 )
index a564015..ee8a9d0 100644 (file)
@@ -7,7 +7,7 @@ package sort_test
 import (
        "fmt"
        "math"
-       "rand"
+       "math/rand"
        . "sort"
        "strconv"
        "testing"
index 24b19be..9b48c07 100644 (file)
@@ -8,7 +8,7 @@ import (
        "bytes"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 const lowerhex = "0123456789abcdef"
index ac8d9dc..8ff851f 100644 (file)
@@ -7,7 +7,7 @@ package strings
 import (
        "errors"
        "io"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A Reader implements the io.Reader, io.ByteScanner, and
@@ -58,7 +58,7 @@ func (r *Reader) UnreadByte() error {
 
 // ReadRune reads and returns the next UTF-8-encoded
 // Unicode code point from the buffer.
-// If no bytes are available, the error returned is os.EOF.
+// If no bytes are available, the error returned is io.EOF.
 // If the bytes are an erroneous UTF-8 encoding, it
 // consumes one byte and returns U+FFFD, 1.
 func (r *Reader) ReadRune() (ch rune, size int, err error) {
index 4f6e8a6..b4d9207 100644 (file)
@@ -7,7 +7,7 @@ package strings
 
 import (
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // explode splits s into an array of UTF-8 sequences, one per Unicode character (still strings) up to a maximum of n (n < 0 means no limit).
index 2cf4bde..304d69a 100644 (file)
@@ -12,8 +12,8 @@ import (
        . "strings"
        "testing"
        "unicode"
+       "unicode/utf8"
        "unsafe"
-       "utf8"
 )
 
 func eq(a, b []string) bool {
index 157a366..37075af 100644 (file)
@@ -5,9 +5,9 @@
 package sync_test
 
 import (
+       "runtime"
        . "sync"
        "sync/atomic"
-       "runtime"
        "testing"
 )
 
index 9e6b84b..f94c541 100644 (file)
@@ -9,7 +9,7 @@ import (
        "flag"
        "fmt"
        "math"
-       "rand"
+       "math/rand"
        "reflect"
        "strings"
 )
index e9ff1aa..a6cf0dc 100644 (file)
@@ -5,7 +5,7 @@
 package quick
 
 import (
-       "rand"
+       "math/rand"
        "reflect"
        "testing"
 )
index 98f3625..d8f8093 100644 (file)
@@ -7,7 +7,7 @@ package script
 
 import (
        "fmt"
-       "rand"
+       "math/rand"
        "reflect"
        "strings"
 )
similarity index 99%
rename from libgo/go/scanner/scanner.go
rename to libgo/go/text/scanner/scanner.go
index 5ab3779..f46f63d 100644 (file)
@@ -31,7 +31,7 @@ import (
        "io"
        "os"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // TODO(gri): Consider changing this to use the new (token) Position package.
@@ -235,7 +235,7 @@ func (s *Scanner) next() rune {
                        copy(s.srcBuf[0:], s.srcBuf[s.srcPos:s.srcEnd])
                        s.srcBufOffset += s.srcPos
                        // read more bytes
-                       // (an io.Reader must return os.EOF when it reaches
+                       // (an io.Reader must return io.EOF when it reaches
                        // the end of what it is reading - simply returning
                        // n == 0 will make this loop retry forever; but the
                        // error is in the reader implementation in that case)
similarity index 99%
rename from libgo/go/scanner/scanner_test.go
rename to libgo/go/text/scanner/scanner_test.go
index b07e559..bb3adb5 100644 (file)
@@ -10,7 +10,7 @@ import (
        "io"
        "strings"
        "testing"
-       "utf8"
+       "unicode/utf8"
 )
 
 // A StringReader delivers its data one string segment at a time via Read.
similarity index 99%
rename from libgo/go/tabwriter/tabwriter.go
rename to libgo/go/text/tabwriter/tabwriter.go
index d588b38..c136ca2 100644 (file)
@@ -14,7 +14,7 @@ import (
        "bytes"
        "io"
        "os"
-       "utf8"
+       "unicode/utf8"
 )
 
 // ----------------------------------------------------------------------------
similarity index 98%
rename from libgo/go/template/exec.go
rename to libgo/go/text/template/exec.go
index 228477c..1910882 100644 (file)
@@ -10,7 +10,7 @@ import (
        "reflect"
        "runtime"
        "strings"
-       "template/parse"
+       "text/template/parse"
 )
 
 // state represents the state of an execution. It's not part of the
@@ -445,7 +445,7 @@ func methodByName(receiver reflect.Value, name string) (reflect.Value, bool) {
 }
 
 var (
-       osErrorType     = reflect.TypeOf((*error)(nil)).Elem()
+       errorType       = reflect.TypeOf((*error)(nil)).Elem()
        fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
 )
 
@@ -659,8 +659,8 @@ func (s *state) printValue(n parse.Node, v reflect.Value) {
                return
        }
 
-       if !v.Type().Implements(fmtStringerType) {
-               if v.CanAddr() && reflect.PtrTo(v.Type()).Implements(fmtStringerType) {
+       if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) {
+               if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) {
                        v = v.Addr()
                } else {
                        switch v.Kind() {
similarity index 97%
rename from libgo/go/template/exec_test.go
rename to libgo/go/text/template/exec_test.go
index e32de4d..5721667 100644 (file)
@@ -6,6 +6,7 @@ package template
 
 import (
        "bytes"
+       "errors"
        "flag"
        "fmt"
        "os"
@@ -31,6 +32,9 @@ type T struct {
        // Struct with String method.
        V0     V
        V1, V2 *V
+       // Struct with Error method.
+       W0     W
+       W1, W2 *W
        // Slices
        SI      []int
        SIEmpty []int
@@ -52,6 +56,7 @@ type T struct {
        NonEmptyInterface I
        // Stringer.
        Str fmt.Stringer
+       Err error
        // Pointers
        PI  *int
        PSI *[]int
@@ -75,6 +80,17 @@ func (v *V) String() string {
        return fmt.Sprintf("<%d>", v.j)
 }
 
+type W struct {
+       k int
+}
+
+func (w *W) Error() string {
+       if w == nil {
+               return "nilW"
+       }
+       return fmt.Sprintf("[%d]", w.k)
+}
+
 var tVal = &T{
        True:   true,
        I:      17,
@@ -83,6 +99,8 @@ var tVal = &T{
        U:      &U{"v"},
        V0:     V{6666},
        V1:     &V{7777}, // leave V2 as nil
+       W0:     W{888},
+       W1:     &W{999}, // leave W2 as nil
        SI:     []int{3, 4, 5},
        SB:     []bool{true, false},
        MSI:    map[string]int{"one": 1, "two": 2, "three": 3},
@@ -99,6 +117,7 @@ var tVal = &T{
        Empty4:            &U{"UinEmpty"},
        NonEmptyInterface: new(T),
        Str:               bytes.NewBuffer([]byte("foozle")),
+       Err:               errors.New("erroozle"),
        PI:                newInt(23),
        PSI:               newIntSlice(21, 22, 23),
        Tmpl:              Must(New("x").Parse("test template")), // "x" is the value of .X
@@ -248,6 +267,11 @@ var execTests = []execTest{
        {"&V{7777}.String()", "-{{.V1}}-", "-<7777>-", tVal, true},
        {"(*V)(nil).String()", "-{{.V2}}-", "-nilV-", tVal, true},
 
+       // Type with Error method.
+       {"W{888}.Error()", "-{{.W0}}-", "-[888]-", tVal, true},
+       {"&W{999}.Error()", "-{{.W1}}-", "-[999]-", tVal, true},
+       {"(*W)(nil).Error()", "-{{.W2}}-", "-nilW-", tVal, true},
+
        // Pointers.
        {"*int", "{{.PI}}", "23", tVal, true},
        {"*[]int", "{{.PSI}}", "[21 22 23]", tVal, true},
@@ -416,6 +440,7 @@ var execTests = []execTest{
        {"bug4", "{{if .Empty0}}non-nil{{else}}nil{{end}}", "nil", tVal, true},
        // Stringer.
        {"bug5", "{{.Str}}", "foozle", tVal, true},
+       {"bug5a", "{{.Err}}", "erroozle", tVal, true},
        // Args need to be indirected and dereferenced sometimes.
        {"bug6a", "{{vfunc .V0 .V1}}", "vfunc", tVal, true},
        {"bug6b", "{{vfunc .V0 .V0}}", "vfunc", tVal, true},
similarity index 99%
rename from libgo/go/template/funcs.go
rename to libgo/go/text/template/funcs.go
index 26c3a6e..2ca09a7 100644 (file)
@@ -8,11 +8,11 @@ import (
        "bytes"
        "fmt"
        "io"
+       "net/url"
        "reflect"
        "strings"
        "unicode"
-       "url"
-       "utf8"
+       "unicode/utf8"
 )
 
 // FuncMap is the type of the map defining the mapping from names to functions.
@@ -72,7 +72,7 @@ func goodFunc(typ reflect.Type) bool {
        switch {
        case typ.NumOut() == 1:
                return true
-       case typ.NumOut() == 2 && typ.Out(1) == osErrorType:
+       case typ.NumOut() == 2 && typ.Out(1) == errorType:
                return true
        }
        return false
similarity index 88%
rename from libgo/go/template/parse.go
rename to libgo/go/text/template/parse.go
index 2fbd37f..fa56214 100644 (file)
@@ -6,7 +6,7 @@ package template
 
 import (
        "reflect"
-       "template/parse"
+       "text/template/parse"
 )
 
 // Template is the representation of a parsed template.
@@ -71,7 +71,7 @@ func (t *Template) Parse(s string) (tmpl *Template, err error) {
 
 // ParseInSet parses the template definition string to construct an internal
 // representation of the template for execution. It also adds the template
-// to the set.
+// to the set. It is an error if s is already defined in the set.
 // Function bindings are checked against those in the set.
 func (t *Template) ParseInSet(s string, set *Set) (tmpl *Template, err error) {
        var setFuncs FuncMap
@@ -82,15 +82,8 @@ func (t *Template) ParseInSet(s string, set *Set) (tmpl *Template, err error) {
        if err != nil {
                return nil, err
        }
-       t.addToSet(set)
-       return t, nil
-}
-
-// addToSet adds the template to the set, verifying it's not being double-assigned.
-func (t *Template) addToSet(set *Set) {
-       if set == nil || t.set == set {
-               return
+       if set != nil {
+               err = set.add(t)
        }
-       // If double-assigned, Add will panic and we will turn that into an error.
-       set.Add(t)
+       return t, err
 }
similarity index 99%
rename from libgo/go/template/parse/lex.go
rename to libgo/go/text/template/parse/lex.go
index 04c105d..97c19a1 100644 (file)
@@ -8,7 +8,7 @@ import (
        "fmt"
        "strings"
        "unicode"
-       "utf8"
+       "unicode/utf8"
 )
 
 // item represents a token or text string returned from the scanner.
similarity index 94%
rename from libgo/go/template/set.go
rename to libgo/go/text/template/set.go
index bd0dfc6..747cc78 100644 (file)
@@ -8,7 +8,7 @@ import (
        "fmt"
        "io"
        "reflect"
-       "template/parse"
+       "text/template/parse"
 )
 
 // Set holds a set of related templates that can refer to one another by name.
@@ -101,8 +101,7 @@ func (s *Set) Execute(wr io.Writer, name string, data interface{}) error {
 
 // Parse parses a string into a set of named templates.  Parse may be called
 // multiple times for a given set, adding the templates defined in the string
-// to the set.  If a template is redefined, the element in the set is
-// overwritten with the new definition.
+// to the set.  It is an error if a template has a name already defined in the set.
 func (s *Set) Parse(text string) (*Set, error) {
        trees, err := parse.Set(text, s.leftDelim, s.rightDelim, s.parseFuncs, builtins)
        if err != nil {
@@ -112,8 +111,10 @@ func (s *Set) Parse(text string) (*Set, error) {
        for name, tree := range trees {
                tmpl := New(name)
                tmpl.Tree = tree
-               tmpl.addToSet(s)
-               s.tmpl[name] = tmpl
+               err = s.add(tmpl)
+               if err != nil {
+                       return s, err
+               }
        }
        return s, nil
 }
index 2407a4a..0662e33 100644 (file)
@@ -7,8 +7,8 @@ package time_test
 import (
        "errors"
        "fmt"
-       "testing"
        "sort"
+       "testing"
        . "time"
 )
 
@@ -148,7 +148,7 @@ func TestAfterQueuing(t *testing.T) {
 }
 
 // For gccgo omit 0 for now because it can take too long to start the
-var slots = []int{5, 3, 6, 6, 6, 1, 1, 2, 7, 9, 4, 8, /*0*/}
+var slots = []int{5, 3, 6, 6, 6, 1, 1, 2, 7, 9, 4, 8 /*0*/ }
 
 type afterResult struct {
        slot int
index 4bc9253..ca1d334 100644 (file)
@@ -4,27 +4,17 @@
 
 package time
 
-import "os"
-
 // Seconds reports the number of seconds since the Unix epoch,
 // January 1, 1970 00:00:00 UTC.
 func Seconds() int64 {
-       sec, _, err := os.Time()
-       if err != nil {
-               panic(err)
-       }
-       return sec
+       return Nanoseconds() / 1e9
 }
 
+// Nanoseconds is implemented by package runtime.
+
 // Nanoseconds reports the number of nanoseconds since the Unix epoch,
 // January 1, 1970 00:00:00 UTC.
-func Nanoseconds() int64 {
-       sec, nsec, err := os.Time()
-       if err != nil {
-               panic(err)
-       }
-       return sec*1e9 + nsec
-}
+func Nanoseconds() int64
 
 // Sleep pauses the current goroutine for at least ns nanoseconds.
 // Higher resolution sleeping may be provided by syscall.Nanosleep 
index ba9295c..ba152e0 100644 (file)
@@ -5,9 +5,9 @@
 package time
 
 import (
-       "syscall"
-       "sync"
        "os"
+       "sync"
+       "syscall"
 )
 
 // BUG(brainman): The Windows implementation assumes that
similarity index 99%
rename from libgo/go/utf16/utf16_test.go
rename to libgo/go/unicode/utf16/utf16_test.go
index 7ea290a..d453b2f 100644 (file)
@@ -8,7 +8,7 @@ import (
        "reflect"
        "testing"
        "unicode"
-       . "utf16"
+       . "unicode/utf16"
 )
 
 type encodeTest struct {
similarity index 98%
rename from libgo/go/utf8/string_test.go
rename to libgo/go/unicode/utf8/string_test.go
index 920d2a0..2c139be 100644 (file)
@@ -5,9 +5,9 @@
 package utf8_test
 
 import (
-       "rand"
+       "math/rand"
        "testing"
-       . "utf8"
+       . "unicode/utf8"
 )
 
 func TestScanForwards(t *testing.T) {
similarity index 99%
rename from libgo/go/utf8/utf8_test.go
rename to libgo/go/unicode/utf8/utf8_test.go
index 857bcf6..6351426 100644 (file)
@@ -7,7 +7,7 @@ package utf8_test
 import (
        "bytes"
        "testing"
-       . "utf8"
+       . "unicode/utf8"
 )
 
 type Utf8Map struct {
index 3da39a0..5dfd824 100644 (file)
@@ -9,7 +9,7 @@ import (
        "crypto/tls"
        "io"
        "net"
-       "url"
+       "net/url"
 )
 
 // DialError is an error that occurs while dialling a websocket server.
index 63eebc9..4d5360f 100644 (file)
@@ -13,13 +13,13 @@ import (
        "crypto/md5"
        "encoding/binary"
        "fmt"
-       "http"
        "io"
        "io/ioutil"
-       "rand"
+       "math/rand"
+       "net/http"
+       "net/url"
        "strconv"
        "strings"
-       "url"
 )
 
 // An aray of characters to be randomly inserted to construct Sec-WebSocket-Key
index 40cb53f..bf537c0 100644 (file)
@@ -8,11 +8,11 @@ import (
        "bufio"
        "bytes"
        "fmt"
-       "http"
        "io"
+       "net/http"
+       "net/url"
        "strings"
        "testing"
-       "url"
 )
 
 // Test the getChallengeResponse function with values from section
index d3d4258..b17d947 100644 (file)
@@ -15,11 +15,11 @@ import (
        "encoding/base64"
        "encoding/binary"
        "fmt"
-       "http"
        "io"
        "io/ioutil"
+       "net/http"
+       "net/url"
        "strings"
-       "url"
 )
 
 const (
index df0f555..60375ff 100644 (file)
@@ -8,11 +8,11 @@ import (
        "bufio"
        "bytes"
        "fmt"
-       "http"
        "io"
+       "net/http"
+       "net/url"
        "strings"
        "testing"
-       "url"
 )
 
 // Test the getNonceAccept function with values in
index 9420c47..57dc4fd 100644 (file)
@@ -7,8 +7,8 @@ package websocket
 import (
        "bufio"
        "fmt"
-       "http"
        "io"
+       "net/http"
 )
 
 func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request) (conn *Conn, err error) {
@@ -20,6 +20,7 @@ func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Requ
                fmt.Fprintf(buf, "Sec-WebSocket-Version: %s\r\n", SupportedProtocolVersion)
                buf.WriteString("\r\n")
                buf.WriteString(err.Error())
+               buf.Flush()
                return
        }
        if err != nil {
@@ -34,12 +35,17 @@ func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Requ
                fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code))
                buf.WriteString("\r\n")
                buf.WriteString(err.Error())
+               buf.Flush()
                return
        }
        config.Protocol = nil
 
        err = hs.AcceptHandshake(buf.Writer)
        if err != nil {
+               code = http.StatusBadRequest
+               fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code))
+               buf.WriteString("\r\n")
+               buf.Flush()
                return
        }
        conn = hs.NewServerConn(buf, rwc, req)
index 9732ae1..1e4036c 100644 (file)
@@ -9,14 +9,14 @@ package websocket
 import (
        "bufio"
        "crypto/tls"
-       "http"
+       "encoding/json"
        "io"
        "io/ioutil"
-       "json"
        "net"
+       "net/http"
+       "net/url"
        "os"
        "sync"
-       "url"
 )
 
 const (
index 69b5335..f41c355 100644 (file)
@@ -7,15 +7,15 @@ package websocket
 import (
        "bytes"
        "fmt"
-       "http"
-       "http/httptest"
        "io"
        "log"
        "net"
+       "net/http"
+       "net/http/httptest"
+       "net/url"
        "strings"
        "sync"
        "testing"
-       "url"
 )
 
 var serverAddr string
@@ -200,20 +200,19 @@ func TestHTTP(t *testing.T) {
        once.Do(startServer)
 
        // If the client did not send a handshake that matches the protocol
-       // specification, the server should abort the WebSocket connection.
-       _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
-       if err == nil {
-               t.Error("Get: unexpected success")
+       // specification, the server MUST return an HTTP respose with an
+       // appropriate error code (such as 400 Bad Request)
+       resp, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
+       if err != nil {
+               t.Errorf("Get: error %#v", err)
                return
        }
-       urlerr, ok := err.(*url.Error)
-       if !ok {
-               t.Errorf("Get: not url.Error %#v", err)
+       if resp == nil {
+               t.Error("Get: resp is null")
                return
        }
-       if urlerr.Err != io.ErrUnexpectedEOF {
-               t.Errorf("Get: error %#v", err)
-               return
+       if resp.StatusCode != http.StatusBadRequest {
+               t.Errorf("Get: expected %q got %q", http.StatusBadRequest, resp.StatusCode)
        }
 }
 
index 6288156..e6d7898 100755 (executable)
@@ -166,7 +166,7 @@ done
   done
 done
 
-runtime="chan.c cpuprof.c goc2c.c lock_futex.c lock_sema.c mcache.c mcentral.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c proc.c runtime.c runtime.h malloc.h malloc.goc mprof.goc runtime1.goc sema.goc sigqueue.goc string.goc"
+runtime="chan.c cpuprof.c goc2c.c lock_futex.c lock_sema.c mcache.c mcentral.c mfinal.c mfixalloc.c mgc0.c mheap.c msize.c proc.c runtime.c runtime.h malloc.h malloc.goc mprof.goc runtime1.goc sema.goc sigqueue.goc string.goc time.goc"
 for f in $runtime; do
   merge_c $f $f
 done
diff --git a/libgo/runtime/time.goc b/libgo/runtime/time.goc
new file mode 100644 (file)
index 0000000..f5a412a
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Runtime implementations to help package time.
+
+package time
+
+#include "runtime.h"
+
+func Nanoseconds() (ret int64) {
+       ret = runtime_nanotime();
+}