diff options
author | Heschi Kreinick <heschi@google.com> | 2023-07-18 13:24:28 -0400 |
---|---|---|
committer | Heschi Kreinick <heschi@google.com> | 2023-07-18 13:25:02 -0400 |
commit | c2de6836c1baee533b13d23b47db6cc75481e763 (patch) | |
tree | c94928c9e423f128970fe63fd9f3b1a7299b828f | |
parent | 4aeac326b5cb41a24d6e48c01008abf2f0fda7ff (diff) | |
parent | 2639a17f146cc7df0778298c6039156d7ca68202 (diff) | |
download | go-c2de6836c1baee533b13d23b47db6cc75481e763.tar.gz go-c2de6836c1baee533b13d23b47db6cc75481e763.zip |
[release-branch.go1.21] all: merge master (2639a17) into release-branch.go1.21
Change-Id: I316578aec6c2b618c840d43a65ef87b8d2168ac0
-rw-r--r-- | doc/go1.21.html | 24 | ||||
-rw-r--r-- | src/bytes/compare_test.go | 3 | ||||
-rw-r--r-- | src/cmd/compile/internal/types2/const.go | 1 | ||||
-rw-r--r-- | src/cmd/covdata/doc.go | 150 | ||||
-rw-r--r-- | src/cmd/go/scriptconds_test.go | 1 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/README | 2 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/gotoolchain_net.txt | 4 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/gotoolchain_version.txt | 13 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/mod_prefer_compatible.txt | 20 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/mod_sumdb_file_path.txt | 4 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/mod_sumdb_golang.txt | 22 | ||||
-rw-r--r-- | src/go/types/const.go | 1 | ||||
-rw-r--r-- | src/log/slog/handler.go | 5 | ||||
-rw-r--r-- | src/log/slog/handler_test.go | 47 | ||||
-rw-r--r-- | src/log/slog/json_handler.go | 2 | ||||
-rw-r--r-- | src/log/slog/text_handler.go | 2 | ||||
-rw-r--r-- | src/math/huge_test.go | 16 | ||||
-rw-r--r-- | src/net/rpc/server.go | 6 | ||||
-rw-r--r-- | src/net/rpc/server_test.go | 6 |
19 files changed, 217 insertions, 112 deletions
diff --git a/doc/go1.21.html b/doc/go1.21.html index 6c58cb0590..97d73720f2 100644 --- a/doc/go1.21.html +++ b/doc/go1.21.html @@ -328,7 +328,7 @@ Do not send CLs removing the interior tags from such phrases. <h2 id="linker">Linker</h2> <p><!-- https://go.dev/issue/57302, CL 461749, CL 457455 --> - On Windows AMD64, the linker (with help from the compiler) now emits + On windows/amd64, the linker (with help from the compiler) now emits SEH unwinding data by default, which improves the integration of Go applications with Windows debuggers and other tools. </p> @@ -346,8 +346,8 @@ Do not send CLs removing the interior tags from such phrases. <h3 id="slog">New log/slog package</h3> <p><!-- https://go.dev/issue/59060, https://go.dev/issue/59141, https://go.dev/issue/59204, https://go.dev/issue/59280, - https://go.dev/issue/59282, https://go.dev/issue/59339, https://go.dev/issue/59345, - CL 477295, CL 484096, CL 486376, CL 486415, CL 487855 --> + https://go.dev/issue/59282, https://go.dev/issue/59339, https://go.dev/issue/59345, https://go.dev/issue/61200, + CL 477295, CL 484096, CL 486376, CL 486415, CL 487855, CL 508195 --> The new <a href="/pkg/log/slog">log/slog</a> package provides structured logging with levels. Structured logging emits key-value pairs to enable fast, accurate processing of large amounts of log data. @@ -367,7 +367,8 @@ Do not send CLs removing the interior tags from such phrases. <!-- https://go.dev/issue/45955, https://go.dev/issue/54768 --> <!-- https://go.dev/issue/57348, https://go.dev/issue/57433 --> <!-- https://go.dev/issue/58565, https://go.dev/issue/60091 --> - <!-- CL 467417, CL 468855, CL 483175, CL 496078, CL 498175 --> + <!-- https://go.dev/issue/60546 --> + <!-- CL 467417, CL 468855, CL 483175, CL 496078, CL 498175, CL 502955 --> The new <a href="/pkg/slices">slices</a> package provides many common operations on slices, using generic functions that work with slices of any element type. @@ -755,6 +756,14 @@ Do not send CLs removing the interior tags from such phrases. </dd> </dl><!-- go/token --> +<dl id="go/types"><dt><a href="/pkg/go/types/">go/types</a></dt> + <dd> + <p><!-- https://go.dev/issue/61175, CL 507975 --> + TODO: <a href="https://go.dev/cl/507975">https://go.dev/cl/507975</a>: go/types: record Config.GoVersion for reporting in Package.GoVersion method; modified api/go1.21.txt + </p> + </dd> +</dl><!-- go/types --> + <dl id="hash/maphash"><dt><a href="/pkg/hash/maphash/">hash/maphash</a></dt> <dd> <p><!-- https://go.dev/issue/47342, CL 468795 --> @@ -1235,18 +1244,21 @@ Do not send CLs removing the interior tags from such phrases. <code>c-archive</code>, <code>c-shared</code>, <code>shared</code>, <code>pie</code>, <code>plugin</code>. </p> - <!-- proposals for x repos that don't need to be mentioned here but are picked up by the relnote tool. --> <!-- https://go.dev/issue/54232 --> +<!-- https://go.dev/issue/57051 --> <!-- https://go.dev/issue/57792 --> <!-- https://go.dev/issue/57906 --> <!-- https://go.dev/issue/58668 --> +<!-- https://go.dev/issue/59016 --> <!-- https://go.dev/issue/59676 --> +<!-- https://go.dev/issue/60409 --> +<!-- https://go.dev/issue/61176 --> <!-- changes to cmd/api that don't need release notes. --> <!-- CL 469115, CL 469135, CL 499981 --> -<!-- proposals that don't need release enotes. --> +<!-- proposals that don't need release notes. --> <!-- https://go.dev/issue/10275 --> <!-- https://go.dev/issue/59719 --> diff --git a/src/bytes/compare_test.go b/src/bytes/compare_test.go index ac39f880f4..067530b6d8 100644 --- a/src/bytes/compare_test.go +++ b/src/bytes/compare_test.go @@ -7,7 +7,6 @@ package bytes_test import ( . "bytes" "fmt" - "internal/testenv" "testing" ) @@ -73,7 +72,7 @@ func TestCompareBytes(t *testing.T) { } lengths = append(lengths, 256, 512, 1024, 1333, 4095, 4096, 4097) - if !testing.Short() || testenv.Builder() != "" { + if !testing.Short() { lengths = append(lengths, 65535, 65536, 65537, 99999) } diff --git a/src/cmd/compile/internal/types2/const.go b/src/cmd/compile/internal/types2/const.go index 9be578c647..af27c727dd 100644 --- a/src/cmd/compile/internal/types2/const.go +++ b/src/cmd/compile/internal/types2/const.go @@ -73,7 +73,6 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c sizeof := func(T Type) int64 { s := conf.sizeof(T) - assert(s == 4 || s == 8) return s } diff --git a/src/cmd/covdata/doc.go b/src/cmd/covdata/doc.go index 924a742ed5..1836bb833c 100644 --- a/src/cmd/covdata/doc.go +++ b/src/cmd/covdata/doc.go @@ -3,82 +3,78 @@ // license that can be found in the LICENSE file. /* -// -// Covdata is a program for manipulating and generating reports -// from 2nd-generation coverage testing output files, those produced -// from running applications or integration tests. E.g. -// -// $ mkdir ./profiledir -// $ go build -cover -o myapp.exe . -// $ GOCOVERDIR=./profiledir ./myapp.exe <arguments> -// $ ls ./profiledir -// covcounters.cce1b350af34b6d0fb59cc1725f0ee27.821598.1663006712821344241 -// covmeta.cce1b350af34b6d0fb59cc1725f0ee27 -// $ -// -// Run covdata via "go tool covdata <mode>", where 'mode' is a subcommand -// selecting a specific reporting, merging, or data manipulation operation. -// Descriptions on the various modes (run "go tool cover <mode> -help" for -// specifics on usage of a given mode: -// -// 1. Report percent of statements covered in each profiled package -// -// $ go tool covdata percent -i=profiledir -// cov-example/p coverage: 41.1% of statements -// main coverage: 87.5% of statements -// $ -// -// -// 2. Report import paths of packages profiled -// -// $ go tool covdata pkglist -i=profiledir -// cov-example/p -// main -// $ -// -// 3. Report percent statements covered by function: -// -// $ go tool covdata func -i=profiledir -// cov-example/p/p.go:12: emptyFn 0.0% -// cov-example/p/p.go:32: Small 100.0% -// cov-example/p/p.go:47: Medium 90.9% -// ... -// $ -// -// 4. Convert coverage data to legacy textual format: -// -// $ go tool covdata textfmt -i=profiledir -o=cov.txt -// $ head cov.txt -// mode: set -// cov-example/p/p.go:12.22,13.2 0 0 -// cov-example/p/p.go:15.31,16.2 1 0 -// cov-example/p/p.go:16.3,18.3 0 0 -// cov-example/p/p.go:19.3,21.3 0 0 -// ... -// $ go tool cover -html=cov.txt -// $ -// -// 5. Merge profiles together: -// -// $ go tool covdata merge -i=indir1,indir2 -o=outdir -modpaths=github.com/go-delve/delve -// $ -// -// 6. Subtract one profile from another -// -// $ go tool covdata subtract -i=indir1,indir2 -o=outdir -// $ -// -// 7. Intersect profiles -// -// $ go tool covdata intersect -i=indir1,indir2 -o=outdir -// $ -// -// 8. Dump a profile for debugging purposes. -// -// $ go tool covdata debugdump -i=indir -// <human readable output> -// $ -// -*/ +Covdata is a program for manipulating and generating reports +from 2nd-generation coverage testing output files, those produced +from running applications or integration tests. E.g. + + $ mkdir ./profiledir + $ go build -cover -o myapp.exe . + $ GOCOVERDIR=./profiledir ./myapp.exe <arguments> + $ ls ./profiledir + covcounters.cce1b350af34b6d0fb59cc1725f0ee27.821598.1663006712821344241 + covmeta.cce1b350af34b6d0fb59cc1725f0ee27 + $ + +Run covdata via "go tool covdata <mode>", where 'mode' is a subcommand +selecting a specific reporting, merging, or data manipulation operation. +Descriptions on the various modes (run "go tool cover <mode> -help" for +specifics on usage of a given mode: + +1. Report percent of statements covered in each profiled package + + $ go tool covdata percent -i=profiledir + cov-example/p coverage: 41.1% of statements + main coverage: 87.5% of statements + $ + +2. Report import paths of packages profiled + + $ go tool covdata pkglist -i=profiledir + cov-example/p + main + $ + +3. Report percent statements covered by function: + + $ go tool covdata func -i=profiledir + cov-example/p/p.go:12: emptyFn 0.0% + cov-example/p/p.go:32: Small 100.0% + cov-example/p/p.go:47: Medium 90.9% + ... + $ + +4. Convert coverage data to legacy textual format: + $ go tool covdata textfmt -i=profiledir -o=cov.txt + $ head cov.txt + mode: set + cov-example/p/p.go:12.22,13.2 0 0 + cov-example/p/p.go:15.31,16.2 1 0 + cov-example/p/p.go:16.3,18.3 0 0 + cov-example/p/p.go:19.3,21.3 0 0 + ... + $ go tool cover -html=cov.txt + $ + +5. Merge profiles together: + + $ go tool covdata merge -i=indir1,indir2 -o=outdir -modpaths=github.com/go-delve/delve + $ + +6. Subtract one profile from another + + $ go tool covdata subtract -i=indir1,indir2 -o=outdir + $ + +7. Intersect profiles + + $ go tool covdata intersect -i=indir1,indir2 -o=outdir + $ + +8. Dump a profile for debugging purposes. + + $ go tool covdata debugdump -i=indir + <human readable output> + $ +*/ package main diff --git a/src/cmd/go/scriptconds_test.go b/src/cmd/go/scriptconds_test.go index 641f69f312..8dd9b0d1cd 100644 --- a/src/cmd/go/scriptconds_test.go +++ b/src/cmd/go/scriptconds_test.go @@ -49,6 +49,7 @@ func scriptConditions() map[string]script.Cond { add("git", lazyBool("the 'git' executable exists and provides the standard CLI", hasWorkingGit)) add("GODEBUG", script.PrefixCondition("GODEBUG contains <suffix>", hasGodebug)) add("GOEXPERIMENT", script.PrefixCondition("GOEXPERIMENT <suffix> is enabled", hasGoexperiment)) + add("go-builder", script.BoolCondition("GO_BUILDER_NAME is non-empty", testenv.Builder() != "")) add("link", lazyBool("testenv.HasLink()", testenv.HasLink)) add("mismatched-goroot", script.Condition("test's GOROOT_FINAL does not match the real GOROOT", isMismatchedGoroot)) add("msan", sysCondition("-msan", platform.MSanSupported, true)) diff --git a/src/cmd/go/testdata/script/README b/src/cmd/go/testdata/script/README index b7215e8f4f..792a158760 100644 --- a/src/cmd/go/testdata/script/README +++ b/src/cmd/go/testdata/script/README @@ -398,6 +398,8 @@ The available conditions are: GOOS/GOARCH supports -fuzz with instrumentation [git] the 'git' executable exists and provides the standard CLI +[go-builder] + GO_BUILDER_NAME is non-empty [link] testenv.HasLink() [mismatched-goroot] diff --git a/src/cmd/go/testdata/script/gotoolchain_net.txt b/src/cmd/go/testdata/script/gotoolchain_net.txt index 72bb2b7252..35f6696454 100644 --- a/src/cmd/go/testdata/script/gotoolchain_net.txt +++ b/src/cmd/go/testdata/script/gotoolchain_net.txt @@ -43,11 +43,13 @@ env GOSUMDB=$oldsumdb # Test a real GOTOOLCHAIN [short] skip [!net:golang.org] skip +[!net:sum.golang.org] skip [!GOOS:darwin] [!GOOS:windows] [!GOOS:linux] skip [!GOARCH:amd64] [!GOARCH:arm64] skip env GOPROXY= -env GOSUMDB= +[go-builder] env GOSUMDB= +[!go-builder] env GOSUMDB=sum.golang.org # Set explicitly in case GOROOT/go.env is modified. env GOTOOLCHAIN=go1.20.1 # Avoid resolving a "go1.20.1" from the user's real $PATH. diff --git a/src/cmd/go/testdata/script/gotoolchain_version.txt b/src/cmd/go/testdata/script/gotoolchain_version.txt index ba1bde6671..e0736ff980 100644 --- a/src/cmd/go/testdata/script/gotoolchain_version.txt +++ b/src/cmd/go/testdata/script/gotoolchain_version.txt @@ -1,6 +1,15 @@ -[!net:golang.org] skip +[!net:proxy.golang.org] skip -env GOPROXY= + # In the Go project's official release GOPROXY defaults to proxy.golang.org, + # but it may be changed in GOROOT/go.env (such as in third-party + # distributions). + # + # Make sure it is in use here, because the server for releases not served + # through the proxy (https://golang.org/toolchain?go-get=1) currently only + # serves the latest patch release for each of the supported stable releases. + +[go-builder] env GOPROXY= +[!go-builder] env GOPROXY=https://proxy.golang.org go list -m -versions go stdout 1.20.1 # among others diff --git a/src/cmd/go/testdata/script/mod_prefer_compatible.txt b/src/cmd/go/testdata/script/mod_prefer_compatible.txt index 57036b95be..4d583ff5f7 100644 --- a/src/cmd/go/testdata/script/mod_prefer_compatible.txt +++ b/src/cmd/go/testdata/script/mod_prefer_compatible.txt @@ -10,9 +10,9 @@ env GOPROXY= env GOSUMDB= # github.com/russross/blackfriday v2.0.0+incompatible exists, -# and should be resolved if we ask for v2.0 explicitly. +# and should be resolved if we ask for it explicitly. -go list -m github.com/russross/blackfriday@v2.0 +go list -m github.com/russross/blackfriday@v2.0.0+incompatible stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$' # blackfriday v1.5.2 has a go.mod file, so v1.5.2 should be preferred over @@ -27,6 +27,7 @@ stdout '^github.com/russross/blackfriday v1\.' ! go list -m github.com/russross/blackfriday@patch stderr '^go: github.com/russross/blackfriday@patch: can''t query version "patch" of module github.com/russross/blackfriday: no existing version is required$' + # If we're fetching directly from version control, ignored +incompatible # versions should also be omitted by 'go list'. @@ -38,10 +39,23 @@ stderr '^go: github.com/russross/blackfriday@patch: can''t query version "patch" [!git] stop env GOPROXY=direct -go list -versions -m github.com/russross/blackfriday github.com/russross/blackfriday +go list -versions -m github.com/russross/blackfriday stdout '^github.com/russross/blackfriday v1\.5\.1 v1\.5\.2' # and possibly others ! stdout ' v2\.' +# For this module, v2.1.0 exists and has a go.mod file. +# 'go list -m github.com/russross/blackfriday@v2.0' will check +# the latest v2.0 tag, discover that it isn't the right module, and stop there +# (instead of spending the time to check O(N) previous tags). + +! go list -m github.com/russross/blackfriday@v2.0 +stderr '^go: module github.com/russross/blackfriday: no matching versions for query "v2\.0\"' + +# (But asking for exactly v2.0.0+incompatible should still succeed.) +go list -m github.com/russross/blackfriday@v2.0.0+incompatible +stdout '^github.com/russross/blackfriday v2\.0\.0\+incompatible$' + + # However, if the latest compatible version does not include a go.mod file, # +incompatible versions should still be listed, as they may still reflect the # intent of the module author. diff --git a/src/cmd/go/testdata/script/mod_sumdb_file_path.txt b/src/cmd/go/testdata/script/mod_sumdb_file_path.txt index c95a667bfd..2f42cb54f5 100644 --- a/src/cmd/go/testdata/script/mod_sumdb_file_path.txt +++ b/src/cmd/go/testdata/script/mod_sumdb_file_path.txt @@ -1,7 +1,9 @@ [!net:proxy.golang.org] skip +[!net:sum.golang.org] skip env GO111MODULE=on -env GOSUMDB= +[go-builder] env GOSUMDB= +[!go-builder] env GOSUMDB=sum.golang.org # Set explicitly in case GOROOT/go.env is modified. env GOPATH=$WORK/gopath1 # With a file-based proxy with an empty checksum directory, diff --git a/src/cmd/go/testdata/script/mod_sumdb_golang.txt b/src/cmd/go/testdata/script/mod_sumdb_golang.txt index 8698412f78..067e2e3b31 100644 --- a/src/cmd/go/testdata/script/mod_sumdb_golang.txt +++ b/src/cmd/go/testdata/script/mod_sumdb_golang.txt @@ -1,13 +1,13 @@ # Test default GOPROXY and GOSUMDB -env GOPROXY= -env GOSUMDB= -go env GOPROXY -stdout '^https://proxy.golang.org,direct$' -go env GOSUMDB -stdout '^sum.golang.org$' -env GOPROXY=https://proxy.golang.org -go env GOSUMDB -stdout '^sum.golang.org$' +[go-builder] env GOPROXY= +[go-builder] env GOSUMDB= +[go-builder] go env GOPROXY +[go-builder] stdout '^https://proxy.golang.org,direct$' +[go-builder] go env GOSUMDB +[go-builder] stdout '^sum.golang.org$' +[go-builder] env GOPROXY=https://proxy.golang.org +[go-builder] go env GOSUMDB +[go-builder] stdout '^sum.golang.org$' # Download direct from github. @@ -26,8 +26,8 @@ cp go.sum saved.sum # files not listed in go.sum. go clean -modcache -env GOSUMDB= -env GOPROXY= +env GOSUMDB=sum.golang.org +env GOPROXY=https://proxy.golang.org,direct go list -x -m all # Download go.mod files. ! stderr github diff --git a/src/go/types/const.go b/src/go/types/const.go index 66fa60804f..bffea146a0 100644 --- a/src/go/types/const.go +++ b/src/go/types/const.go @@ -74,7 +74,6 @@ func representableConst(x constant.Value, check *Checker, typ *Basic, rounded *c sizeof := func(T Type) int64 { s := conf.sizeof(T) - assert(s == 4 || s == 8) return s } diff --git a/src/log/slog/handler.go b/src/log/slog/handler.go index e479ca8a4c..a73983cda3 100644 --- a/src/log/slog/handler.go +++ b/src/log/slog/handler.go @@ -193,7 +193,7 @@ type commonHandler struct { groupPrefix string groups []string // all groups started from WithGroup nOpenGroups int // the number of groups opened in preformattedAttrs - mu sync.Mutex + mu *sync.Mutex w io.Writer } @@ -207,6 +207,7 @@ func (h *commonHandler) clone() *commonHandler { groups: slices.Clip(h.groups), nOpenGroups: h.nOpenGroups, w: h.w, + mu: h.mu, // mutex shared among all clones of this handler } } @@ -252,6 +253,8 @@ func (h *commonHandler) withGroup(name string) *commonHandler { return h2 } +// handle is the internal implementation of Handler.Handle +// used by TextHandler and JSONHandler. func (h *commonHandler) handle(r Record) error { state := h.newHandleState(buffer.New(), true, "") defer state.free() diff --git a/src/log/slog/handler_test.go b/src/log/slog/handler_test.go index 3fb7360fc2..4f10ee5028 100644 --- a/src/log/slog/handler_test.go +++ b/src/log/slog/handler_test.go @@ -16,6 +16,7 @@ import ( "slices" "strconv" "strings" + "sync" "testing" "time" ) @@ -106,6 +107,52 @@ func TestDefaultHandle(t *testing.T) { } } +func TestConcurrentWrites(t *testing.T) { + ctx := context.Background() + count := 1000 + for _, handlerType := range []string{"text", "json"} { + t.Run(handlerType, func(t *testing.T) { + var buf bytes.Buffer + var h Handler + switch handlerType { + case "text": + h = NewTextHandler(&buf, nil) + case "json": + h = NewJSONHandler(&buf, nil) + default: + t.Fatalf("unexpected handlerType %q", handlerType) + } + sub1 := h.WithAttrs([]Attr{Bool("sub1", true)}) + sub2 := h.WithAttrs([]Attr{Bool("sub2", true)}) + var wg sync.WaitGroup + for i := 0; i < count; i++ { + sub1Record := NewRecord(time.Time{}, LevelInfo, "hello from sub1", 0) + sub1Record.AddAttrs(Int("i", i)) + sub2Record := NewRecord(time.Time{}, LevelInfo, "hello from sub2", 0) + sub2Record.AddAttrs(Int("i", i)) + wg.Add(1) + go func() { + defer wg.Done() + if err := sub1.Handle(ctx, sub1Record); err != nil { + t.Error(err) + } + if err := sub2.Handle(ctx, sub2Record); err != nil { + t.Error(err) + } + }() + } + wg.Wait() + for i := 1; i <= 2; i++ { + want := "hello from sub" + strconv.Itoa(i) + n := strings.Count(buf.String(), want) + if n != count { + t.Fatalf("want %d occurrences of %q, got %d", count, want, n) + } + } + }) + } +} + // Verify the common parts of TextHandler and JSONHandler. func TestJSONAndTextHandlers(t *testing.T) { // remove all Attrs diff --git a/src/log/slog/json_handler.go b/src/log/slog/json_handler.go index cebcfba45a..1c51ab05ff 100644 --- a/src/log/slog/json_handler.go +++ b/src/log/slog/json_handler.go @@ -13,6 +13,7 @@ import ( "io" "log/slog/internal/buffer" "strconv" + "sync" "time" "unicode/utf8" ) @@ -35,6 +36,7 @@ func NewJSONHandler(w io.Writer, opts *HandlerOptions) *JSONHandler { json: true, w: w, opts: *opts, + mu: &sync.Mutex{}, }, } } diff --git a/src/log/slog/text_handler.go b/src/log/slog/text_handler.go index 75b66b716f..58edb2f66d 100644 --- a/src/log/slog/text_handler.go +++ b/src/log/slog/text_handler.go @@ -11,6 +11,7 @@ import ( "io" "reflect" "strconv" + "sync" "unicode" "unicode/utf8" ) @@ -33,6 +34,7 @@ func NewTextHandler(w io.Writer, opts *HandlerOptions) *TextHandler { json: false, w: w, opts: *opts, + mu: &sync.Mutex{}, }, } } diff --git a/src/math/huge_test.go b/src/math/huge_test.go index bc28c6ff69..568b0c85eb 100644 --- a/src/math/huge_test.go +++ b/src/math/huge_test.go @@ -81,6 +81,10 @@ func TestHugeCos(t *testing.T) { if !close(f1, f2) { t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1) } + f3 := Cos(-trigHuge[i]) + if !close(f1, f3) { + t.Errorf("Cos(%g) = %g, want %g", -trigHuge[i], f3, f1) + } } } @@ -91,6 +95,10 @@ func TestHugeSin(t *testing.T) { if !close(f1, f2) { t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1) } + f3 := Sin(-trigHuge[i]) + if !close(-f1, f3) { + t.Errorf("Sin(%g) = %g, want %g", -trigHuge[i], f3, -f1) + } } } @@ -101,6 +109,10 @@ func TestHugeSinCos(t *testing.T) { if !close(f1, f2) || !close(g1, g2) { t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1) } + f3, g3 := Sincos(-trigHuge[i]) + if !close(-f1, f3) || !close(g1, g3) { + t.Errorf("Sincos(%g) = %g, %g, want %g, %g", -trigHuge[i], f3, g3, -f1, g1) + } } } @@ -111,5 +123,9 @@ func TestHugeTan(t *testing.T) { if !close(f1, f2) { t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1) } + f3 := Tan(-trigHuge[i]) + if !close(-f1, f3) { + t.Errorf("Tan(%g) = %g, want %g", -trigHuge[i], f3, -f1) + } } } diff --git a/src/net/rpc/server.go b/src/net/rpc/server.go index 109ebba541..5cea2cc507 100644 --- a/src/net/rpc/server.go +++ b/src/net/rpc/server.go @@ -86,9 +86,9 @@ The server calls (for HTTP service): arith := new(Arith) rpc.Register(arith) rpc.HandleHTTP() - l, e := net.Listen("tcp", ":1234") - if e != nil { - log.Fatal("listen error:", e) + l, err := net.Listen("tcp", ":1234") + if err != nil { + log.Fatal("listen error:", err) } go http.Serve(l, nil) diff --git a/src/net/rpc/server_test.go b/src/net/rpc/server_test.go index dc5f5decc7..6a94d6ebe8 100644 --- a/src/net/rpc/server_test.go +++ b/src/net/rpc/server_test.go @@ -110,9 +110,9 @@ func (BuiltinTypes) Array(args *Args, reply *[2]int) error { } func listenTCP() (net.Listener, string) { - l, e := net.Listen("tcp", "127.0.0.1:0") // any available address - if e != nil { - log.Fatalf("net.Listen tcp :0: %v", e) + l, err := net.Listen("tcp", "127.0.0.1:0") // any available address + if err != nil { + log.Fatalf("net.Listen tcp :0: %v", err) } return l, l.Addr().String() } |