1
0
mirror of https://github.com/golang/go synced 2024-09-29 15:34:30 -06:00

go/printer, gofmt: tuned table alignment for better results

The go/printer (and thus gofmt) uses a heuristic to determine
whether to break alignment between elements of an expression
list which is spread across multiple lines. The heuristic only
kicked in if the entry sizes (character length) was above a
certain threshold (20) and the ratio between the previous and
current entry size was above a certain value (4).

This heuristic worked reasonably most of the time, but also
led to unfortunate breaks in many cases where a single entry
was suddenly much smaller (or larger) then the previous one.

The behavior of gofmt was sufficiently mysterious in some of
these situations that many issues were filed against it.

The simplest solution to address this problem is to remove
the heuristic altogether and have a programmer introduce
empty lines to force different alignments if it improves
readability. The problem with that approach is that the
places where it really matters, very long tables with many
(hundreds, or more) entries, may be machine-generated and
not "post-processed" by a human (e.g., unicode/utf8/tables.go).

If a single one of those entries is overlong, the result
would be that the alignment would force all comments or
values in key:value pairs to be adjusted to that overlong
value, making the table hard to read (e.g., that entry may
not even be visible on screen and all other entries seem
spaced out too wide).

Instead, we opted for a slightly improved heuristic that
behaves much better for "normal", human-written code.

1) The threshold is increased from 20 to 40. This disables
the heuristic for many common cases yet even if the alignment
is not "ideal", 40 is not that many characters per line with
todays screens, making it very likely that the entire line
remains "visible" in an editor.

2) Changed the heuristic to not simply look at the size ratio
between current and previous line, but instead considering the
geometric mean of the sizes of the previous (aligned) lines.
This emphasizes the "overall picture" of the previous lines,
rather than a single one (which might be an outlier).

3) Changed the ratio from 4 to 2.5. Now that we ignore sizes
below 40, a ratio of 4 would mean that a new entry would have
to be 4 times bigger (160) or smaller (10) before alignment
would be broken. A ratio of 2.5 seems more sensible.

Applied updated gofmt to all of src and misc. Also tested
against several former issues that complained about this
and verified that the output for the given examples is
satisfactory (added respective test cases).

Some of the files changed because they were not gofmt-ed
in the first place.

For #644.
For #7335.
For #10392.
(and probably more related issues)

Fixes #22852.

Change-Id: I5e48b3d3b157a5cf2d649833b7297b33f43a6f6e
This commit is contained in:
Robert Griesemer 2018-04-03 17:05:47 -07:00
parent d7c7d88b2c
commit 542ea5ad91
32 changed files with 2782 additions and 2500 deletions

View File

@ -378,9 +378,9 @@ func TestReader(t *testing.T) {
"security.selinux": "unconfined_u:object_r:default_t:s0\x00",
},
PAXRecords: map[string]string{
"mtime": "1386065770.449252304",
"atime": "1389782991.41987522",
"ctime": "1386065770.449252304",
"mtime": "1386065770.449252304",
"atime": "1389782991.41987522",
"ctime": "1386065770.449252304",
"SCHILY.xattr.security.selinux": "unconfined_u:object_r:default_t:s0\x00",
},
Format: FormatPAX,

View File

@ -115,7 +115,7 @@ var tests = []test{
`var MultiLineVar = map\[struct{ ... }\]struct{ ... }{ ... }`, // Multi line variable.
`func MultiLineFunc\(x interface{ ... }\) \(r struct{ ... }\)`, // Multi line function.
`var LongLine = newLongLine\(("someArgument[1-4]", ){4}...\)`, // Long list of arguments.
`type T1 = T2`, // Type alias
`type T1 = T2`, // Type alias
},
[]string{
`const internalConstant = 2`, // No internal constants.

View File

@ -1,2 +1,3 @@
package p2
import _ "dupload/vendor/p"

View File

@ -1,4 +1,3 @@
// +build windows
package x

View File

@ -1,5 +1,7 @@
package main
import "my.pkg"
func main() {
println(pkg.Text)
}

View File

@ -1,11 +1,12 @@
package p
type (
_ interface{ m(B1) }
_ interface{ m(B1) }
A1 interface{ a(D1) }
B1 interface{ A1 }
C1 interface{ B1 /* ERROR issue #18395 */ }
C1 interface {
B1 /* ERROR issue #18395 */
}
D1 interface{ C1 }
)

View File

@ -911,4 +911,4 @@ const (
ARNG_H
ARNG_S
ARNG_D
)
)

View File

@ -1668,13 +1668,13 @@ func cmp(a int, b int) bool {
case C_PSOREG_4:
switch b {
case C_ZOREG, C_PSOREG_8:
case C_ZOREG, C_PSOREG_8:
return true
}
case C_PSOREG:
switch b {
case C_ZOREG, C_PSOREG_8, C_PSOREG_4:
case C_ZOREG, C_PSOREG_8, C_PSOREG_4:
return true
}
@ -4014,7 +4014,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rt := int((p.To.Reg) & 31)
r := int((p.Reg) & 31)
o1 |= ((Q&1) << 30) | ((size&3) << 22) | (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31)
o1 |= ((Q & 1) << 30) | ((size & 3) << 22) | (uint32(rf&31) << 16) | (uint32(r&31) << 5) | uint32(rt&31)
case 94: /* vext $imm4, Vm.<T>, Vn.<T>, Vd.<T> */
if p.From3Type() != obj.TYPE_REG {
@ -4053,7 +4053,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rt := int((p.To.Reg) & 31)
r := int((p.Reg) & 31)
o1 |= ((Q&1) << 30) | (uint32(r&31) << 16) | (uint32(index&15) << 11) | (uint32(rf&31) << 5) | uint32(rt&31)
o1 |= ((Q & 1) << 30) | (uint32(r&31) << 16) | (uint32(index&15) << 11) | (uint32(rf&31) << 5) | uint32(rt&31)
case 95: /* vushr $shift, Vn.<T>, Vd.<T> */
at := int((p.To.Reg >> 5) & 15)
@ -4111,7 +4111,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
rt := int((p.To.Reg) & 31)
rf := int((p.Reg) & 31)
o1 |= ((Q&1) << 30) | (uint32(imm&127) << 16) | (uint32(rf&31) << 5) | uint32(rt&31)
o1 |= ((Q & 1) << 30) | (uint32(imm&127) << 16) | (uint32(rf&31) << 5) | uint32(rt&31)
case 96: /* vst1 Vt1.<T>[index], offset(Rn) */
af := int((p.From.Reg >> 5) & 15)
@ -4183,7 +4183,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
o1 |= 26 << 23
}
o1 |= (uint32(Q&1) << 30) | (uint32(r&31) << 16) | ((opcode&7) << 13) | (uint32(S&1) << 12) | (uint32(size&3) << 10) | (uint32(rf&31) << 5) | uint32(rt&31)
o1 |= (uint32(Q&1) << 30) | (uint32(r&31) << 16) | ((opcode & 7) << 13) | (uint32(S&1) << 12) | (uint32(size&3) << 10) | (uint32(rf&31) << 5) | uint32(rt&31)
case 97: /* vld1 offset(Rn), vt.<T>[index] */
at := int((p.To.Reg >> 5) & 15)
@ -4257,7 +4257,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
o1 |= 106 << 21
}
o1 |= (uint32(Q&1) << 30) | (uint32(r&31) << 16) | ((opcode&7) << 13) | (uint32(S&1) << 12) | (uint32(size&3) << 10) | (uint32(rf&31) << 5) | uint32(rt&31)
o1 |= (uint32(Q&1) << 30) | (uint32(r&31) << 16) | ((opcode & 7) << 13) | (uint32(S&1) << 12) | (uint32(size&3) << 10) | (uint32(rf&31) << 5) | uint32(rt&31)
}
out[0] = o1
out[1] = o2

View File

@ -75,8 +75,8 @@ func getProfile(source string, timeout time.Duration) (*profile.Profile, error)
client := &http.Client{
Transport: &http.Transport{
ResponseHeaderTimeout: timeout + 5*time.Second,
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
},
}
resp, err := client.Get(source)

View File

@ -598,8 +598,8 @@ var httpGet = func(source string, timeout time.Duration) (*http.Response, error)
client := &http.Client{
Transport: &http.Transport{
ResponseHeaderTimeout: timeout + 5*time.Second,
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: tlsConfig,
},
}
return client.Get(source)

View File

@ -115,6 +115,6 @@ var goodNamedPointerSliceLiteral = []*unicode.CaseRange{
&unicode.CaseRange{Lo: 1, Hi: 2},
}
var badNamedPointerSliceLiteral = []*unicode.CaseRange{
{1, 2}, // ERROR "unkeyed fields"
{1, 2}, // ERROR "unkeyed fields"
&unicode.CaseRange{1, 2}, // ERROR "unkeyed fields"
}

View File

@ -194,9 +194,9 @@ func TestDontSelectRSAWithECDSAKey(t *testing.T) {
func TestRenegotiationExtension(t *testing.T) {
clientHello := &clientHelloMsg{
vers: VersionTLS12,
compressionMethods: []uint8{compressionNone},
random: make([]byte, 32),
vers: VersionTLS12,
compressionMethods: []uint8{compressionNone},
random: make([]byte, 32),
secureRenegotiationSupported: true,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
}
@ -992,7 +992,7 @@ func TestFallbackSCSV(t *testing.T) {
name: "FallbackSCSV",
config: &serverConfig,
// OpenSSL 1.0.1j is needed for the -fallback_scsv option.
command: []string{"openssl", "s_client", "-fallback_scsv"},
command: []string{"openssl", "s_client", "-fallback_scsv"},
expectHandshakeErrorIncluding: "inappropriate protocol fallback",
}
runServerTestTLS11(t, test)

View File

@ -1573,7 +1573,7 @@ func makeConstraintsCACert(constraints constraintsSpec, name string, key *ecdsa.
NotAfter: time.Unix(2000, 0),
KeyUsage: KeyUsageCertSign,
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}
if err := addConstraintsToTemplate(constraints, template); err != nil {
@ -1611,7 +1611,7 @@ func makeConstraintsLeafCert(leaf leafSpec, key *ecdsa.PrivateKey, parent *Certi
NotAfter: time.Unix(2000, 0),
KeyUsage: KeyUsageDigitalSignature,
BasicConstraintsValid: true,
IsCA: false,
IsCA: false,
}
for _, name := range leaf.sans {

View File

@ -2556,7 +2556,7 @@ func ParseCertificateRequest(asn1Data []byte) (*CertificateRequest, error) {
func parseCertificateRequest(in *certificateRequest) (*CertificateRequest, error) {
out := &CertificateRequest{
Raw: in.Raw,
Raw: in.Raw,
RawTBSCertificateRequest: in.TBSCSR.Raw,
RawSubjectPublicKeyInfo: in.TBSCSR.PublicKey.Raw,
RawSubject: in.TBSCSR.Subject.FullBytes,

View File

@ -551,7 +551,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
UnknownExtKeyUsage: testUnknownExtKeyUsage,
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
OCSPServer: []string{"http://ocsp.example.com"},
IssuingCertificateURL: []string{"http://crt.example.com/ca1.crt"},
@ -1399,7 +1399,7 @@ func TestMaxPathLen(t *testing.T) {
NotAfter: time.Unix(100000, 0),
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}
cert1 := serialiseAndParse(t, template)
@ -1440,8 +1440,8 @@ func TestNoAuthorityKeyIdInSelfSignedCert(t *testing.T) {
NotAfter: time.Unix(100000, 0),
BasicConstraintsValid: true,
IsCA: true,
SubjectKeyId: []byte{1, 2, 3, 4},
IsCA: true,
SubjectKeyId: []byte{1, 2, 3, 4},
}
if cert := serialiseAndParse(t, template); len(cert.AuthorityKeyId) != 0 {

View File

@ -615,9 +615,9 @@ var unmarshalTests = []unmarshalTest{
out: S5{S8: S8{S9: S9{Y: 2}}},
},
{
in: `{"X": 1,"Y":2}`,
ptr: new(S5),
err: fmt.Errorf("json: unknown field \"X\""),
in: `{"X": 1,"Y":2}`,
ptr: new(S5),
err: fmt.Errorf("json: unknown field \"X\""),
disallowUnknownFields: true,
},
{
@ -626,9 +626,9 @@ var unmarshalTests = []unmarshalTest{
out: S10{S13: S13{S8: S8{S9: S9{Y: 2}}}},
},
{
in: `{"X": 1,"Y":2}`,
ptr: new(S10),
err: fmt.Errorf("json: unknown field \"X\""),
in: `{"X": 1,"Y":2}`,
ptr: new(S10),
err: fmt.Errorf("json: unknown field \"X\""),
disallowUnknownFields: true,
},
@ -835,8 +835,8 @@ var unmarshalTests = []unmarshalTest{
"Q": 18,
"extra": true
}`,
ptr: new(Top),
err: fmt.Errorf("json: unknown field \"extra\""),
ptr: new(Top),
err: fmt.Errorf("json: unknown field \"extra\""),
disallowUnknownFields: true,
},
{
@ -862,8 +862,8 @@ var unmarshalTests = []unmarshalTest{
"Z": 17,
"Q": 18
}`,
ptr: new(Top),
err: fmt.Errorf("json: unknown field \"extra\""),
ptr: new(Top),
err: fmt.Errorf("json: unknown field \"extra\""),
disallowUnknownFields: true,
},
}

View File

@ -229,49 +229,49 @@ var pkgDeps = map[string][]string{
"go/types": {"L4", "GOPARSER", "container/heap", "go/constant"},
// One of a kind.
"archive/tar": {"L4", "OS", "syscall", "os/user"},
"archive/zip": {"L4", "OS", "compress/flate"},
"container/heap": {"sort"},
"compress/bzip2": {"L4"},
"compress/flate": {"L4"},
"compress/gzip": {"L4", "compress/flate"},
"compress/lzw": {"L4"},
"compress/zlib": {"L4", "compress/flate"},
"context": {"errors", "fmt", "reflect", "sync", "time"},
"database/sql": {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
"database/sql/driver": {"L4", "context", "time", "database/sql/internal"},
"debug/dwarf": {"L4"},
"debug/elf": {"L4", "OS", "debug/dwarf", "compress/zlib"},
"debug/gosym": {"L4"},
"debug/macho": {"L4", "OS", "debug/dwarf"},
"debug/pe": {"L4", "OS", "debug/dwarf"},
"debug/plan9obj": {"L4", "OS"},
"encoding": {"L4"},
"encoding/ascii85": {"L4"},
"encoding/asn1": {"L4", "math/big"},
"encoding/csv": {"L4"},
"encoding/gob": {"L4", "OS", "encoding"},
"encoding/hex": {"L4"},
"encoding/json": {"L4", "encoding"},
"encoding/pem": {"L4"},
"encoding/xml": {"L4", "encoding"},
"flag": {"L4", "OS"},
"go/build": {"L4", "OS", "GOPARSER"},
"html": {"L4"},
"image/draw": {"L4", "image/internal/imageutil"},
"image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"},
"image/internal/imageutil": {"L4"},
"image/jpeg": {"L4", "image/internal/imageutil"},
"image/png": {"L4", "compress/zlib"},
"index/suffixarray": {"L4", "regexp"},
"internal/singleflight": {"sync"},
"internal/trace": {"L4", "OS"},
"math/big": {"L4"},
"mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
"mime/quotedprintable": {"L4"},
"net/internal/socktest": {"L4", "OS", "syscall", "internal/syscall/windows"},
"net/url": {"L4"},
"plugin": {"L0", "OS", "CGO"},
"archive/tar": {"L4", "OS", "syscall", "os/user"},
"archive/zip": {"L4", "OS", "compress/flate"},
"container/heap": {"sort"},
"compress/bzip2": {"L4"},
"compress/flate": {"L4"},
"compress/gzip": {"L4", "compress/flate"},
"compress/lzw": {"L4"},
"compress/zlib": {"L4", "compress/flate"},
"context": {"errors", "fmt", "reflect", "sync", "time"},
"database/sql": {"L4", "container/list", "context", "database/sql/driver", "database/sql/internal"},
"database/sql/driver": {"L4", "context", "time", "database/sql/internal"},
"debug/dwarf": {"L4"},
"debug/elf": {"L4", "OS", "debug/dwarf", "compress/zlib"},
"debug/gosym": {"L4"},
"debug/macho": {"L4", "OS", "debug/dwarf"},
"debug/pe": {"L4", "OS", "debug/dwarf"},
"debug/plan9obj": {"L4", "OS"},
"encoding": {"L4"},
"encoding/ascii85": {"L4"},
"encoding/asn1": {"L4", "math/big"},
"encoding/csv": {"L4"},
"encoding/gob": {"L4", "OS", "encoding"},
"encoding/hex": {"L4"},
"encoding/json": {"L4", "encoding"},
"encoding/pem": {"L4"},
"encoding/xml": {"L4", "encoding"},
"flag": {"L4", "OS"},
"go/build": {"L4", "OS", "GOPARSER"},
"html": {"L4"},
"image/draw": {"L4", "image/internal/imageutil"},
"image/gif": {"L4", "compress/lzw", "image/color/palette", "image/draw"},
"image/internal/imageutil": {"L4"},
"image/jpeg": {"L4", "image/internal/imageutil"},
"image/png": {"L4", "compress/zlib"},
"index/suffixarray": {"L4", "regexp"},
"internal/singleflight": {"sync"},
"internal/trace": {"L4", "OS"},
"math/big": {"L4"},
"mime": {"L4", "OS", "syscall", "internal/syscall/windows/registry"},
"mime/quotedprintable": {"L4"},
"net/internal/socktest": {"L4", "OS", "syscall", "internal/syscall/windows"},
"net/url": {"L4"},
"plugin": {"L0", "OS", "CGO"},
"runtime/pprof/internal/profile": {"L4", "OS", "compress/gzip", "regexp"},
"testing/internal/testdeps": {"L4", "internal/testlog", "runtime/pprof", "regexp"},
"text/scanner": {"L4", "OS"},

View File

@ -12,6 +12,7 @@ import (
"bytes"
"go/ast"
"go/token"
"math"
"strconv"
"strings"
"unicode"
@ -147,15 +148,15 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
// list entries span multiple lines;
// use source code positions to guide line breaks
// don't add extra indentation if noIndent is set;
// i.e., pretend that the first line is already indented
// Don't add extra indentation if noIndent is set;
// i.e., pretend that the first line is already indented.
ws := ignore
if mode&noIndent == 0 {
ws = indent
}
// the first linebreak is always a formfeed since this section must not
// depend on any previous formatting
// The first linebreak is always a formfeed since this section must not
// depend on any previous formatting.
prevBreak := -1 // index of last expression that was followed by a linebreak
if prev.IsValid() && prev.Line < line && p.linebreak(line, 0, ws, true) {
ws = ignore
@ -165,22 +166,29 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
// initialize expression/key size: a zero value indicates expr/key doesn't fit on a single line
size := 0
// We use the ratio between the geometric mean of the previous key sizes and
// the current size to determine if there should be a break in the alignment.
// To compute the geometric mean we accumulate the ln(size) values (lnsum)
// and the number of sizes included (count).
lnsum := 0.0
count := 0
// print all list elements
prevLine := prev.Line
for i, x := range list {
line = p.lineFor(x.Pos())
// determine if the next linebreak, if any, needs to use formfeed:
// Determine if the next linebreak, if any, needs to use formfeed:
// in general, use the entire node size to make the decision; for
// key:value expressions, use the key size
// key:value expressions, use the key size.
// TODO(gri) for a better result, should probably incorporate both
// the key and the node size into the decision process
useFF := true
// determine element size: all bets are off if we don't have
// Determine element size: All bets are off if we don't have
// position information for the previous and next token (likely
// generated code - simply ignore the size in this case by setting
// it to 0)
// it to 0).
prevSize := size
const infinity = 1e6 // larger than any source line
size = p.nodeSize(x, infinity)
@ -195,35 +203,45 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
size = 0
}
// if the previous line and the current line had single-
// If the previous line and the current line had single-
// line-expressions and the key sizes are small or the
// ratio between the key sizes does not exceed a
// threshold, align columns and do not use formfeed
// ratio between the current key and the geometric mean
// if the previous key sizes does not exceed a threshold,
// align columns and do not use formfeed.
if prevSize > 0 && size > 0 {
const smallSize = 20
if prevSize <= smallSize && size <= smallSize {
const smallSize = 40
if count == 0 || prevSize <= smallSize && size <= smallSize {
useFF = false
} else {
const r = 4 // threshold
ratio := float64(size) / float64(prevSize)
useFF = ratio <= 1.0/r || r <= ratio
const r = 2.5 // threshold
geomean := math.Exp(lnsum / float64(count)) // count > 0
ratio := float64(size) / geomean
useFF = r*ratio <= 1 || r <= ratio
}
}
if useFF {
lnsum = 0
count = 0
}
if size > 0 {
lnsum += math.Log(float64(size))
count++
}
needsLinebreak := 0 < prevLine && prevLine < line
if i > 0 {
// use position of expression following the comma as
// Use position of expression following the comma as
// comma position for correct comment placement, but
// only if the expression is on the same line
// only if the expression is on the same line.
if !needsLinebreak {
p.print(x.Pos())
}
p.print(token.COMMA)
needsBlank := true
if needsLinebreak {
// lines are broken using newlines so comments remain aligned
// unless forceFF is set or there are multiple expressions on
// the same line in which case formfeed is used
// Lines are broken using newlines so comments remain aligned
// unless useFF is set or there are multiple expressions on
// the same line in which case formfeed is used.
if p.linebreak(line, 0, ws, useFF || prevBreak+1 < i) {
ws = ignore
prevBreak = i
@ -236,10 +254,10 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
}
if len(list) > 1 && isPair && size > 0 && needsLinebreak {
// we have a key:value expression that fits onto one line
// We have a key:value expression that fits onto one line
// and it's not on the same line as the prior expression:
// use a column for the key such that consecutive entries
// can align if possible
// Use a column for the key such that consecutive entries
// can align if possible.
// (needsLinebreak is set if we started a new line before)
p.expr(pair.Key)
p.print(pair.Colon, token.COLON, vtab)
@ -252,7 +270,7 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
}
if mode&commaTerm != 0 && next.IsValid() && p.pos.Line < next.Line {
// print a terminating comma if the next token is on a new line
// Print a terminating comma if the next token is on a new line.
p.print(token.COMMA)
if ws == ignore && mode&noIndent == 0 {
// unindent if we indented

View File

@ -188,6 +188,7 @@ var data = []entry{
{"comments.input", "comments.golden", 0},
{"comments.input", "comments.x", export},
{"comments2.input", "comments2.golden", idempotent},
{"alignment.input", "alignment.golden", idempotent},
{"linebreaks.input", "linebreaks.golden", idempotent},
{"expressions.input", "expressions.golden", idempotent},
{"expressions.input", "expressions.raw", rawFormat | idempotent},

130
src/go/printer/testdata/alignment.golden vendored Normal file
View File

@ -0,0 +1,130 @@
// Copyright 2018 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 alignment
// ----------------------------------------------------------------------------
// Examples from issue #7335.
func main() {
z := MyStruct{
Foo: "foo",
Bar: "bar",
Name: "name",
LongName: "longname",
Baz: "baz",
}
y := MyStruct{
Foo: "foo",
Bar: "bar",
NameXX: "name",
LongNameXXXXXXXXXXXXX: "longname",
Baz: "baz",
}
z := MyStruct{
Foo: "foo",
Bar: "bar",
Name: "name",
LongNameXXXXXXXXXXXXX: "longname",
Baz: "baz",
}
}
// ----------------------------------------------------------------------------
// Examples from issue #10392.
var kcfg = KubeletConfig{
Address: s.Address,
AllowPrivileged: s.AllowPrivileged,
HostNetworkSources: hostNetworkSources,
HostnameOverride: s.HostnameOverride,
RootDirectory: s.RootDirectory,
ConfigFile: s.Config,
ManifestURL: s.ManifestURL,
FileCheckFrequency: s.FileCheckFrequency,
HTTPCheckFrequency: s.HTTPCheckFrequency,
PodInfraContainerImage: s.PodInfraContainerImage,
SyncFrequency: s.SyncFrequency,
RegistryPullQPS: s.RegistryPullQPS,
RegistryBurst: s.RegistryBurst,
MinimumGCAge: s.MinimumGCAge,
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
MaxContainerCount: s.MaxContainerCount,
ClusterDomain: s.ClusterDomain,
ClusterDNS: s.ClusterDNS,
Runonce: s.RunOnce,
Port: s.Port,
ReadOnlyPort: s.ReadOnlyPort,
CadvisorInterface: cadvisorInterface,
EnableServer: s.EnableServer,
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
KubeClient: client,
MasterServiceNamespace: s.MasterServiceNamespace,
VolumePlugins: ProbeVolumePlugins(),
NetworkPlugins: ProbeNetworkPlugins(),
NetworkPluginName: s.NetworkPluginName,
StreamingConnectionIdleTimeout: s.StreamingConnectionIdleTimeout,
TLSOptions: tlsOptions,
ImageGCPolicy: imageGCPolicy, imageGCPolicy,
Cloud: cloud,
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency,
}
var a = A{
Long: 1,
LongLong: 1,
LongLongLong: 1,
LongLongLongLong: 1,
LongLongLongLongLong: 1,
LongLongLongLongLongLong: 1,
LongLongLongLongLongLongLong: 1,
LongLongLongLongLongLongLongLong: 1,
Short: 1,
LongLongLongLongLongLongLongLongLong: 3,
}
// ----------------------------------------------------------------------------
// Examples from issue #22852.
var fmtMap = map[string]string{
"1": "123",
"12": "123",
"123": "123",
"1234": "123",
"12345": "123",
"123456": "123",
"12345678901234567890123456789": "123",
"abcde": "123",
"123456789012345678901234567890": "123",
"1234567": "123",
"abcdefghijklmnopqrstuvwxyzabcd": "123",
"abcd": "123",
}
type Fmt struct {
abcdefghijklmnopqrstuvwx string
abcdefghijklmnopqrstuvwxy string
abcdefghijklmnopqrstuvwxyz string
abcdefghijklmnopqrstuvwxyza string
abcdefghijklmnopqrstuvwxyzab string
abcdefghijklmnopqrstuvwxyzabc string
abcde string
abcdefghijklmnopqrstuvwxyzabcde string
abcdefg string
}
func main() {
_ := Fmt{
abcdefghijklmnopqrstuvwx: "foo",
abcdefghijklmnopqrstuvwxyza: "foo",
abcdefghijklmnopqrstuvwxyzab: "foo",
abcdefghijklmnopqrstuvwxyzabc: "foo",
abcde: "foo",
abcdefghijklmnopqrstuvwxyzabcde: "foo",
abcdefg: "foo",
abcdefghijklmnopqrstuvwxy: "foo",
abcdefghijklmnopqrstuvwxyz: "foo",
}
}

130
src/go/printer/testdata/alignment.input vendored Normal file
View File

@ -0,0 +1,130 @@
// Copyright 2018 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 alignment
// ----------------------------------------------------------------------------
// Examples from issue #7335.
func main() {
z := MyStruct{
Foo: "foo",
Bar: "bar",
Name: "name",
LongName: "longname",
Baz: "baz",
}
y := MyStruct{
Foo: "foo",
Bar: "bar",
NameXX: "name",
LongNameXXXXXXXXXXXXX: "longname",
Baz: "baz",
}
z := MyStruct{
Foo: "foo",
Bar: "bar",
Name: "name",
LongNameXXXXXXXXXXXXX: "longname",
Baz: "baz",
}
}
// ----------------------------------------------------------------------------
// Examples from issue #10392.
var kcfg = KubeletConfig{
Address: s.Address,
AllowPrivileged: s.AllowPrivileged,
HostNetworkSources: hostNetworkSources,
HostnameOverride: s.HostnameOverride,
RootDirectory: s.RootDirectory,
ConfigFile: s.Config,
ManifestURL: s.ManifestURL,
FileCheckFrequency: s.FileCheckFrequency,
HTTPCheckFrequency: s.HTTPCheckFrequency,
PodInfraContainerImage: s.PodInfraContainerImage,
SyncFrequency: s.SyncFrequency,
RegistryPullQPS: s.RegistryPullQPS,
RegistryBurst: s.RegistryBurst,
MinimumGCAge: s.MinimumGCAge,
MaxPerPodContainerCount: s.MaxPerPodContainerCount,
MaxContainerCount: s.MaxContainerCount,
ClusterDomain: s.ClusterDomain,
ClusterDNS: s.ClusterDNS,
Runonce: s.RunOnce,
Port: s.Port,
ReadOnlyPort: s.ReadOnlyPort,
CadvisorInterface: cadvisorInterface,
EnableServer: s.EnableServer,
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
KubeClient: client,
MasterServiceNamespace: s.MasterServiceNamespace,
VolumePlugins: ProbeVolumePlugins(),
NetworkPlugins: ProbeNetworkPlugins(),
NetworkPluginName: s.NetworkPluginName,
StreamingConnectionIdleTimeout: s.StreamingConnectionIdleTimeout,
TLSOptions: tlsOptions,
ImageGCPolicy: imageGCPolicy,imageGCPolicy,
Cloud: cloud,
NodeStatusUpdateFrequency: s.NodeStatusUpdateFrequency,
}
var a = A{
Long: 1,
LongLong: 1,
LongLongLong: 1,
LongLongLongLong: 1,
LongLongLongLongLong: 1,
LongLongLongLongLongLong: 1,
LongLongLongLongLongLongLong: 1,
LongLongLongLongLongLongLongLong: 1,
Short: 1,
LongLongLongLongLongLongLongLongLong: 3,
}
// ----------------------------------------------------------------------------
// Examples from issue #22852.
var fmtMap = map[string]string{
"1": "123",
"12": "123",
"123": "123",
"1234": "123",
"12345": "123",
"123456": "123",
"12345678901234567890123456789": "123",
"abcde": "123",
"123456789012345678901234567890": "123",
"1234567": "123",
"abcdefghijklmnopqrstuvwxyzabcd": "123",
"abcd": "123",
}
type Fmt struct {
abcdefghijklmnopqrstuvwx string
abcdefghijklmnopqrstuvwxy string
abcdefghijklmnopqrstuvwxyz string
abcdefghijklmnopqrstuvwxyza string
abcdefghijklmnopqrstuvwxyzab string
abcdefghijklmnopqrstuvwxyzabc string
abcde string
abcdefghijklmnopqrstuvwxyzabcde string
abcdefg string
}
func main() {
_ := Fmt{
abcdefghijklmnopqrstuvwx: "foo",
abcdefghijklmnopqrstuvwxyza: "foo",
abcdefghijklmnopqrstuvwxyzab: "foo",
abcdefghijklmnopqrstuvwxyzabc: "foo",
abcde: "foo",
abcdefghijklmnopqrstuvwxyzabcde: "foo",
abcdefg: "foo",
abcdefghijklmnopqrstuvwxy: "foo",
abcdefghijklmnopqrstuvwxyz: "foo",
}
}

View File

@ -688,8 +688,8 @@ var _ = T1{
// not aligned
var _ = T2{
a: x,
b: y,
a: x,
b: y,
ccccccccccccccccccccc: z,
}
@ -703,8 +703,8 @@ var _ = T3{
// not aligned
var _ = T4{
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: x,
b: y,
c: z,
b: y,
c: z,
}
// no alignment of map composite entries if they are not the first entry on a line

View File

@ -29,9 +29,9 @@ func TestIsAlias(t *testing.T) {
name *TypeName
alias bool
}{
{NewTypeName(0, nil, "t0", nil), false}, // no type yet
{NewTypeName(0, pkg, "t0", nil), false}, // no type yet
{t1, false}, // type name refers to named type and vice versa
{NewTypeName(0, nil, "t0", nil), false}, // no type yet
{NewTypeName(0, pkg, "t0", nil), false}, // no type yet
{t1, false}, // type name refers to named type and vice versa
{NewTypeName(0, nil, "t2", &emptyInterface), true}, // type name refers to unnamed type
{NewTypeName(0, pkg, "t3", n1), true}, // type name refers to named type with different type name
{NewTypeName(0, nil, "t4", Typ[Int32]), true}, // type name refers to basic type with different name

File diff suppressed because it is too large Load Diff

View File

@ -103,7 +103,7 @@ var _lgamA = [...]float64{
4.48640949618915160150e-05, // 0x3F07858E90A45837
}
var _lgamR = [...]float64{
1.0, // placeholder
1.0, // placeholder
1.39200533467621045958e+00, // 0x3FF645A762C4AB74
7.21935547567138069525e-01, // 0x3FE71A1893D3DCDC
1.71933865632803078993e-01, // 0x3FC601EDCCFBDF27

View File

@ -121,219 +121,219 @@ func TestRegress(t *testing.T) {
}
var regressGolden = []interface{}{
float64(4.668112973579268), // ExpFloat64()
float64(0.1601593871172866), // ExpFloat64()
float64(3.0465834105636), // ExpFloat64()
float64(0.06385839451671879), // ExpFloat64()
float64(1.8578917487258961), // ExpFloat64()
float64(0.784676123472182), // ExpFloat64()
float64(0.11225477361256932), // ExpFloat64()
float64(0.20173283329802255), // ExpFloat64()
float64(0.3468619496201105), // ExpFloat64()
float64(0.35601103454384536), // ExpFloat64()
float64(0.888376329507869), // ExpFloat64()
float64(1.4081362450365698), // ExpFloat64()
float64(1.0077753823151994), // ExpFloat64()
float64(0.23594100766227588), // ExpFloat64()
float64(2.777245612300007), // ExpFloat64()
float64(0.5202997830662377), // ExpFloat64()
float64(1.2842705247770294), // ExpFloat64()
float64(0.030307408362776206), // ExpFloat64()
float64(2.204156824853721), // ExpFloat64()
float64(2.09891923895058), // ExpFloat64()
float32(0.94519615), // Float32()
float32(0.24496509), // Float32()
float32(0.65595627), // Float32()
float32(0.05434384), // Float32()
float32(0.3675872), // Float32()
float32(0.28948045), // Float32()
float32(0.1924386), // Float32()
float32(0.65533215), // Float32()
float32(0.8971697), // Float32()
float32(0.16735445), // Float32()
float32(0.28858566), // Float32()
float32(0.9026048), // Float32()
float32(0.84978026), // Float32()
float32(0.2730468), // Float32()
float32(0.6090802), // Float32()
float32(0.253656), // Float32()
float32(0.7746542), // Float32()
float32(0.017480763), // Float32()
float32(0.78707397), // Float32()
float32(0.7993937), // Float32()
float64(0.9451961492941164), // Float64()
float64(0.24496508529377975), // Float64()
float64(0.6559562651954052), // Float64()
float64(0.05434383959970039), // Float64()
float64(0.36758720663245853), // Float64()
float64(0.2894804331565928), // Float64()
float64(0.19243860967493215), // Float64()
float64(0.6553321508148324), // Float64()
float64(0.897169713149801), // Float64()
float64(0.16735444255905835), // Float64()
float64(0.2885856518054551), // Float64()
float64(0.9026048462705047), // Float64()
float64(0.8497802817628735), // Float64()
float64(0.2730468047134829), // Float64()
float64(0.6090801919903561), // Float64()
float64(0.25365600644283687), // Float64()
float64(0.7746542391859803), // Float64()
float64(0.017480762156647272), // Float64()
float64(0.7870739563039942), // Float64()
float64(0.7993936979594545), // Float64()
int64(8717895732742165505), // Int()
int64(2259404117704393152), // Int()
int64(6050128673802995827), // Int()
int64(501233450539197794), // Int()
int64(3390393562759376202), // Int()
int64(2669985732393126063), // Int()
int64(1774932891286980153), // Int()
int64(6044372234677422456), // Int()
int64(8274930044578894929), // Int()
int64(1543572285742637646), // Int()
int64(2661732831099943416), // Int()
int64(8325060299420976708), // Int()
int64(7837839688282259259), // Int()
int64(2518412263346885298), // Int()
int64(5617773211005988520), // Int()
int64(2339563716805116249), // Int()
int64(7144924247938981575), // Int()
int64(161231572858529631), // Int()
int64(7259475919510918339), // Int()
int64(7373105480197164748), // Int()
int32(2029793274), // Int31()
int32(526058514), // Int31()
int32(1408655353), // Int31()
int32(116702506), // Int31()
int32(789387515), // Int31()
int32(621654496), // Int31()
int32(413258767), // Int31()
int32(1407315077), // Int31()
int32(1926657288), // Int31()
int32(359390928), // Int31()
int32(619732968), // Int31()
int32(1938329147), // Int31()
int32(1824889259), // Int31()
int32(586363548), // Int31()
int32(1307989752), // Int31()
int32(544722126), // Int31()
int32(1663557311), // Int31()
int32(37539650), // Int31()
int32(1690228450), // Int31()
int32(1716684894), // Int31()
int32(0), // Int31n(1)
int32(4), // Int31n(10)
int32(25), // Int31n(32)
int32(310570), // Int31n(1048576)
int32(857611), // Int31n(1048577)
int32(621654496), // Int31n(1000000000)
int32(413258767), // Int31n(1073741824)
int32(1407315077), // Int31n(2147483646)
int32(1926657288), // Int31n(2147483647)
int32(0), // Int31n(1)
int32(8), // Int31n(10)
int32(27), // Int31n(32)
int32(367019), // Int31n(1048576)
int32(209005), // Int31n(1048577)
int32(307989752), // Int31n(1000000000)
int32(544722126), // Int31n(1073741824)
int32(1663557311), // Int31n(2147483646)
int32(37539650), // Int31n(2147483647)
int32(0), // Int31n(1)
int32(4), // Int31n(10)
int64(8717895732742165505), // Int63()
int64(2259404117704393152), // Int63()
int64(6050128673802995827), // Int63()
int64(501233450539197794), // Int63()
int64(3390393562759376202), // Int63()
int64(2669985732393126063), // Int63()
int64(1774932891286980153), // Int63()
int64(6044372234677422456), // Int63()
int64(8274930044578894929), // Int63()
int64(1543572285742637646), // Int63()
int64(2661732831099943416), // Int63()
int64(8325060299420976708), // Int63()
int64(7837839688282259259), // Int63()
int64(2518412263346885298), // Int63()
int64(5617773211005988520), // Int63()
int64(2339563716805116249), // Int63()
int64(7144924247938981575), // Int63()
int64(161231572858529631), // Int63()
int64(7259475919510918339), // Int63()
int64(7373105480197164748), // Int63()
int64(0), // Int63n(1)
int64(2), // Int63n(10)
int64(19), // Int63n(32)
int64(959842), // Int63n(1048576)
int64(688912), // Int63n(1048577)
int64(393126063), // Int63n(1000000000)
int64(89212473), // Int63n(1073741824)
int64(834026388), // Int63n(2147483646)
int64(1577188963), // Int63n(2147483647)
int64(543572285742637646), // Int63n(1000000000000000000)
int64(355889821886249464), // Int63n(1152921504606846976)
int64(8325060299420976708), // Int63n(9223372036854775806)
int64(7837839688282259259), // Int63n(9223372036854775807)
int64(0), // Int63n(1)
int64(0), // Int63n(10)
int64(25), // Int63n(32)
int64(679623), // Int63n(1048576)
int64(882178), // Int63n(1048577)
int64(510918339), // Int63n(1000000000)
int64(782454476), // Int63n(1073741824)
int64(0), // Intn(1)
int64(4), // Intn(10)
int64(25), // Intn(32)
int64(310570), // Intn(1048576)
int64(857611), // Intn(1048577)
int64(621654496), // Intn(1000000000)
int64(413258767), // Intn(1073741824)
int64(1407315077), // Intn(2147483646)
int64(1926657288), // Intn(2147483647)
int64(543572285742637646), // Intn(1000000000000000000)
int64(355889821886249464), // Intn(1152921504606846976)
int64(8325060299420976708), // Intn(9223372036854775806)
int64(7837839688282259259), // Intn(9223372036854775807)
int64(0), // Intn(1)
int64(2), // Intn(10)
int64(14), // Intn(32)
int64(515775), // Intn(1048576)
int64(839455), // Intn(1048577)
int64(690228450), // Intn(1000000000)
int64(642943070), // Intn(1073741824)
float64(-0.28158587086436215), // NormFloat64()
float64(0.570933095808067), // NormFloat64()
float64(-1.6920196326157044), // NormFloat64()
float64(0.1996229111693099), // NormFloat64()
float64(1.9195199291234621), // NormFloat64()
float64(0.8954838794918353), // NormFloat64()
float64(0.41457072128813166), // NormFloat64()
float64(-0.48700161491544713), // NormFloat64()
float64(-0.1684059662402393), // NormFloat64()
float64(0.37056410998929545), // NormFloat64()
float64(1.0156889027029008), // NormFloat64()
float64(-0.5174422210625114), // NormFloat64()
float64(-0.5565834214413804), // NormFloat64()
float64(0.778320596648391), // NormFloat64()
float64(-1.8970718197702225), // NormFloat64()
float64(0.5229525761688676), // NormFloat64()
float64(-1.5515595563231523), // NormFloat64()
float64(0.0182029289376123), // NormFloat64()
float64(-0.6820951356608795), // NormFloat64()
float64(-0.5987943422687668), // NormFloat64()
[]int{}, // Perm(0)
[]int{0}, // Perm(1)
[]int{0, 4, 1, 3, 2}, // Perm(5)
[]int{3, 1, 0, 4, 7, 5, 2, 6}, // Perm(8)
[]int{5, 0, 3, 6, 7, 4, 2, 1, 8}, // Perm(9)
[]int{4, 5, 0, 2, 6, 9, 3, 1, 8, 7}, // Perm(10)
float64(4.668112973579268), // ExpFloat64()
float64(0.1601593871172866), // ExpFloat64()
float64(3.0465834105636), // ExpFloat64()
float64(0.06385839451671879), // ExpFloat64()
float64(1.8578917487258961), // ExpFloat64()
float64(0.784676123472182), // ExpFloat64()
float64(0.11225477361256932), // ExpFloat64()
float64(0.20173283329802255), // ExpFloat64()
float64(0.3468619496201105), // ExpFloat64()
float64(0.35601103454384536), // ExpFloat64()
float64(0.888376329507869), // ExpFloat64()
float64(1.4081362450365698), // ExpFloat64()
float64(1.0077753823151994), // ExpFloat64()
float64(0.23594100766227588), // ExpFloat64()
float64(2.777245612300007), // ExpFloat64()
float64(0.5202997830662377), // ExpFloat64()
float64(1.2842705247770294), // ExpFloat64()
float64(0.030307408362776206), // ExpFloat64()
float64(2.204156824853721), // ExpFloat64()
float64(2.09891923895058), // ExpFloat64()
float32(0.94519615), // Float32()
float32(0.24496509), // Float32()
float32(0.65595627), // Float32()
float32(0.05434384), // Float32()
float32(0.3675872), // Float32()
float32(0.28948045), // Float32()
float32(0.1924386), // Float32()
float32(0.65533215), // Float32()
float32(0.8971697), // Float32()
float32(0.16735445), // Float32()
float32(0.28858566), // Float32()
float32(0.9026048), // Float32()
float32(0.84978026), // Float32()
float32(0.2730468), // Float32()
float32(0.6090802), // Float32()
float32(0.253656), // Float32()
float32(0.7746542), // Float32()
float32(0.017480763), // Float32()
float32(0.78707397), // Float32()
float32(0.7993937), // Float32()
float64(0.9451961492941164), // Float64()
float64(0.24496508529377975), // Float64()
float64(0.6559562651954052), // Float64()
float64(0.05434383959970039), // Float64()
float64(0.36758720663245853), // Float64()
float64(0.2894804331565928), // Float64()
float64(0.19243860967493215), // Float64()
float64(0.6553321508148324), // Float64()
float64(0.897169713149801), // Float64()
float64(0.16735444255905835), // Float64()
float64(0.2885856518054551), // Float64()
float64(0.9026048462705047), // Float64()
float64(0.8497802817628735), // Float64()
float64(0.2730468047134829), // Float64()
float64(0.6090801919903561), // Float64()
float64(0.25365600644283687), // Float64()
float64(0.7746542391859803), // Float64()
float64(0.017480762156647272), // Float64()
float64(0.7870739563039942), // Float64()
float64(0.7993936979594545), // Float64()
int64(8717895732742165505), // Int()
int64(2259404117704393152), // Int()
int64(6050128673802995827), // Int()
int64(501233450539197794), // Int()
int64(3390393562759376202), // Int()
int64(2669985732393126063), // Int()
int64(1774932891286980153), // Int()
int64(6044372234677422456), // Int()
int64(8274930044578894929), // Int()
int64(1543572285742637646), // Int()
int64(2661732831099943416), // Int()
int64(8325060299420976708), // Int()
int64(7837839688282259259), // Int()
int64(2518412263346885298), // Int()
int64(5617773211005988520), // Int()
int64(2339563716805116249), // Int()
int64(7144924247938981575), // Int()
int64(161231572858529631), // Int()
int64(7259475919510918339), // Int()
int64(7373105480197164748), // Int()
int32(2029793274), // Int31()
int32(526058514), // Int31()
int32(1408655353), // Int31()
int32(116702506), // Int31()
int32(789387515), // Int31()
int32(621654496), // Int31()
int32(413258767), // Int31()
int32(1407315077), // Int31()
int32(1926657288), // Int31()
int32(359390928), // Int31()
int32(619732968), // Int31()
int32(1938329147), // Int31()
int32(1824889259), // Int31()
int32(586363548), // Int31()
int32(1307989752), // Int31()
int32(544722126), // Int31()
int32(1663557311), // Int31()
int32(37539650), // Int31()
int32(1690228450), // Int31()
int32(1716684894), // Int31()
int32(0), // Int31n(1)
int32(4), // Int31n(10)
int32(25), // Int31n(32)
int32(310570), // Int31n(1048576)
int32(857611), // Int31n(1048577)
int32(621654496), // Int31n(1000000000)
int32(413258767), // Int31n(1073741824)
int32(1407315077), // Int31n(2147483646)
int32(1926657288), // Int31n(2147483647)
int32(0), // Int31n(1)
int32(8), // Int31n(10)
int32(27), // Int31n(32)
int32(367019), // Int31n(1048576)
int32(209005), // Int31n(1048577)
int32(307989752), // Int31n(1000000000)
int32(544722126), // Int31n(1073741824)
int32(1663557311), // Int31n(2147483646)
int32(37539650), // Int31n(2147483647)
int32(0), // Int31n(1)
int32(4), // Int31n(10)
int64(8717895732742165505), // Int63()
int64(2259404117704393152), // Int63()
int64(6050128673802995827), // Int63()
int64(501233450539197794), // Int63()
int64(3390393562759376202), // Int63()
int64(2669985732393126063), // Int63()
int64(1774932891286980153), // Int63()
int64(6044372234677422456), // Int63()
int64(8274930044578894929), // Int63()
int64(1543572285742637646), // Int63()
int64(2661732831099943416), // Int63()
int64(8325060299420976708), // Int63()
int64(7837839688282259259), // Int63()
int64(2518412263346885298), // Int63()
int64(5617773211005988520), // Int63()
int64(2339563716805116249), // Int63()
int64(7144924247938981575), // Int63()
int64(161231572858529631), // Int63()
int64(7259475919510918339), // Int63()
int64(7373105480197164748), // Int63()
int64(0), // Int63n(1)
int64(2), // Int63n(10)
int64(19), // Int63n(32)
int64(959842), // Int63n(1048576)
int64(688912), // Int63n(1048577)
int64(393126063), // Int63n(1000000000)
int64(89212473), // Int63n(1073741824)
int64(834026388), // Int63n(2147483646)
int64(1577188963), // Int63n(2147483647)
int64(543572285742637646), // Int63n(1000000000000000000)
int64(355889821886249464), // Int63n(1152921504606846976)
int64(8325060299420976708), // Int63n(9223372036854775806)
int64(7837839688282259259), // Int63n(9223372036854775807)
int64(0), // Int63n(1)
int64(0), // Int63n(10)
int64(25), // Int63n(32)
int64(679623), // Int63n(1048576)
int64(882178), // Int63n(1048577)
int64(510918339), // Int63n(1000000000)
int64(782454476), // Int63n(1073741824)
int64(0), // Intn(1)
int64(4), // Intn(10)
int64(25), // Intn(32)
int64(310570), // Intn(1048576)
int64(857611), // Intn(1048577)
int64(621654496), // Intn(1000000000)
int64(413258767), // Intn(1073741824)
int64(1407315077), // Intn(2147483646)
int64(1926657288), // Intn(2147483647)
int64(543572285742637646), // Intn(1000000000000000000)
int64(355889821886249464), // Intn(1152921504606846976)
int64(8325060299420976708), // Intn(9223372036854775806)
int64(7837839688282259259), // Intn(9223372036854775807)
int64(0), // Intn(1)
int64(2), // Intn(10)
int64(14), // Intn(32)
int64(515775), // Intn(1048576)
int64(839455), // Intn(1048577)
int64(690228450), // Intn(1000000000)
int64(642943070), // Intn(1073741824)
float64(-0.28158587086436215), // NormFloat64()
float64(0.570933095808067), // NormFloat64()
float64(-1.6920196326157044), // NormFloat64()
float64(0.1996229111693099), // NormFloat64()
float64(1.9195199291234621), // NormFloat64()
float64(0.8954838794918353), // NormFloat64()
float64(0.41457072128813166), // NormFloat64()
float64(-0.48700161491544713), // NormFloat64()
float64(-0.1684059662402393), // NormFloat64()
float64(0.37056410998929545), // NormFloat64()
float64(1.0156889027029008), // NormFloat64()
float64(-0.5174422210625114), // NormFloat64()
float64(-0.5565834214413804), // NormFloat64()
float64(0.778320596648391), // NormFloat64()
float64(-1.8970718197702225), // NormFloat64()
float64(0.5229525761688676), // NormFloat64()
float64(-1.5515595563231523), // NormFloat64()
float64(0.0182029289376123), // NormFloat64()
float64(-0.6820951356608795), // NormFloat64()
float64(-0.5987943422687668), // NormFloat64()
[]int{}, // Perm(0)
[]int{0}, // Perm(1)
[]int{0, 4, 1, 3, 2}, // Perm(5)
[]int{3, 1, 0, 4, 7, 5, 2, 6}, // Perm(8)
[]int{5, 0, 3, 6, 7, 4, 2, 1, 8}, // Perm(9)
[]int{4, 5, 0, 2, 6, 9, 3, 1, 8, 7}, // Perm(10)
[]int{14, 2, 0, 8, 3, 5, 13, 12, 1, 4, 6, 7, 11, 9, 15, 10}, // Perm(16)
[]int{}, // Perm(0)
[]int{0}, // Perm(1)
[]int{3, 0, 1, 2, 4}, // Perm(5)
[]int{5, 1, 2, 0, 4, 7, 3, 6}, // Perm(8)
[]int{4, 0, 6, 8, 1, 5, 2, 7, 3}, // Perm(9)
[]int{8, 6, 1, 7, 5, 4, 3, 2, 9, 0}, // Perm(10)
[]int{}, // Perm(0)
[]int{0}, // Perm(1)
[]int{3, 0, 1, 2, 4}, // Perm(5)
[]int{5, 1, 2, 0, 4, 7, 3, 6}, // Perm(8)
[]int{4, 0, 6, 8, 1, 5, 2, 7, 3}, // Perm(9)
[]int{8, 6, 1, 7, 5, 4, 3, 2, 9, 0}, // Perm(10)
[]int{0, 3, 13, 2, 15, 4, 10, 1, 8, 14, 7, 6, 12, 9, 5, 11}, // Perm(16)
[]int{}, // Perm(0)
[]int{0}, // Perm(1)
@ -346,7 +346,7 @@ var regressGolden = []interface{}{
[]byte{0x41, 0xd3, 0xff, 0x12, 0x4, 0x5b, 0x73, 0xc8}, // Read([0 0 0 0 0 0 0 0])
[]byte{0x6e, 0x4f, 0xf9, 0x5f, 0xf6, 0x62, 0xa5, 0xee, 0xe8}, // Read([0 0 0 0 0 0 0 0 0])
[]byte{0x2a, 0xbd, 0xf4, 0x4a, 0x2d, 0xb, 0x75, 0xfb, 0x18, 0xd}, // Read([0 0 0 0 0 0 0 0 0 0])
[]byte{0xaf}, // Read([0])
[]byte{0xaf}, // Read([0])
[]byte{0x48, 0xa7, 0x9e, 0xe0, 0xb1, 0xd, 0x39}, // Read([0 0 0 0 0 0 0])
[]byte{0x46, 0x51, 0x85, 0xf, 0xd4, 0xa1, 0x78, 0x89}, // Read([0 0 0 0 0 0 0 0])
[]byte{0x2e, 0xe2, 0x85, 0xec, 0xe1, 0x51, 0x14, 0x55, 0x78}, // Read([0 0 0 0 0 0 0 0 0])
@ -356,49 +356,49 @@ var regressGolden = []interface{}{
[]byte{0xc6, 0xb1, 0xf8, 0x3b, 0x8e, 0x88, 0x3b, 0xbf}, // Read([0 0 0 0 0 0 0 0])
[]byte{0x85, 0x7a, 0xab, 0x99, 0xc5, 0xb2, 0x52, 0xc7, 0x42}, // Read([0 0 0 0 0 0 0 0 0])
[]byte{0x9c, 0x32, 0xf3, 0xa8, 0xae, 0xb7, 0x9e, 0xf8, 0x56, 0xf6}, // Read([0 0 0 0 0 0 0 0 0 0])
[]byte{0x59}, // Read([0])
[]byte{0x59}, // Read([0])
[]byte{0xc1, 0x8f, 0xd, 0xce, 0xcc, 0x77, 0xc7}, // Read([0 0 0 0 0 0 0])
[]byte{0x5e, 0x7a, 0x81, 0xbf, 0xde, 0x27, 0x5f, 0x67}, // Read([0 0 0 0 0 0 0 0])
[]byte{0xcf, 0xe2, 0x42, 0xcf, 0x3c, 0xc3, 0x54, 0xf3, 0xed}, // Read([0 0 0 0 0 0 0 0 0])
[]byte{0xe2, 0xd6, 0xbe, 0xcc, 0x4e, 0xa3, 0xae, 0x5e, 0x88, 0x52}, // Read([0 0 0 0 0 0 0 0 0 0])
uint32(4059586549), // Uint32()
uint32(1052117029), // Uint32()
uint32(2817310706), // Uint32()
uint32(233405013), // Uint32()
uint32(1578775030), // Uint32()
uint32(1243308993), // Uint32()
uint32(826517535), // Uint32()
uint32(2814630155), // Uint32()
uint32(3853314576), // Uint32()
uint32(718781857), // Uint32()
uint32(1239465936), // Uint32()
uint32(3876658295), // Uint32()
uint32(3649778518), // Uint32()
uint32(1172727096), // Uint32()
uint32(2615979505), // Uint32()
uint32(1089444252), // Uint32()
uint32(3327114623), // Uint32()
uint32(75079301), // Uint32()
uint32(3380456901), // Uint32()
uint32(3433369789), // Uint32()
uint64(8717895732742165505), // Uint64()
uint64(2259404117704393152), // Uint64()
uint64(6050128673802995827), // Uint64()
uint64(9724605487393973602), // Uint64()
uint64(12613765599614152010), // Uint64()
uint64(11893357769247901871), // Uint64()
uint64(1774932891286980153), // Uint64()
uint64(15267744271532198264), // Uint64()
uint64(17498302081433670737), // Uint64()
uint64(1543572285742637646), // Uint64()
uint64(11885104867954719224), // Uint64()
uint64(17548432336275752516), // Uint64()
uint64(7837839688282259259), // Uint64()
uint64(2518412263346885298), // Uint64()
uint64(5617773211005988520), // Uint64()
uint64(11562935753659892057), // Uint64()
uint64(16368296284793757383), // Uint64()
uint64(161231572858529631), // Uint64()
uint64(16482847956365694147), // Uint64()
uint64(16596477517051940556), // Uint64()
uint32(4059586549), // Uint32()
uint32(1052117029), // Uint32()
uint32(2817310706), // Uint32()
uint32(233405013), // Uint32()
uint32(1578775030), // Uint32()
uint32(1243308993), // Uint32()
uint32(826517535), // Uint32()
uint32(2814630155), // Uint32()
uint32(3853314576), // Uint32()
uint32(718781857), // Uint32()
uint32(1239465936), // Uint32()
uint32(3876658295), // Uint32()
uint32(3649778518), // Uint32()
uint32(1172727096), // Uint32()
uint32(2615979505), // Uint32()
uint32(1089444252), // Uint32()
uint32(3327114623), // Uint32()
uint32(75079301), // Uint32()
uint32(3380456901), // Uint32()
uint32(3433369789), // Uint32()
uint64(8717895732742165505), // Uint64()
uint64(2259404117704393152), // Uint64()
uint64(6050128673802995827), // Uint64()
uint64(9724605487393973602), // Uint64()
uint64(12613765599614152010), // Uint64()
uint64(11893357769247901871), // Uint64()
uint64(1774932891286980153), // Uint64()
uint64(15267744271532198264), // Uint64()
uint64(17498302081433670737), // Uint64()
uint64(1543572285742637646), // Uint64()
uint64(11885104867954719224), // Uint64()
uint64(17548432336275752516), // Uint64()
uint64(7837839688282259259), // Uint64()
uint64(2518412263346885298), // Uint64()
uint64(5617773211005988520), // Uint64()
uint64(11562935753659892057), // Uint64()
uint64(16368296284793757383), // Uint64()
uint64(161231572858529631), // Uint64()
uint64(16482847956365694147), // Uint64()
uint64(16596477517051940556), // Uint64()
}

View File

@ -524,7 +524,7 @@ func TestEnvOverride(t *testing.T) {
"PATH=/wibble"},
}
expectedMap := map[string]string{
"cwd": cwd,
"cwd": cwd,
"env-SCRIPT_FILENAME": cgifile,
"env-REQUEST_URI": "/foo/bar",
"env-PATH": "/wibble",

View File

@ -114,12 +114,12 @@ func afterTest(t testing.TB) {
}
var bad string
badSubstring := map[string]string{
").readLoop(": "a Transport",
").writeLoop(": "a Transport",
").readLoop(": "a Transport",
").writeLoop(": "a Transport",
"created by net/http/httptest.(*Server).Start": "an httptest.Server",
"timeoutHandler": "a TimeoutHandler",
"net.(*netFD).connect(": "a timing out dial",
").noteClientGone(": "a closenotifier sender",
"timeoutHandler": "a TimeoutHandler",
"net.(*netFD).connect(": "a timing out dial",
").noteClientGone(": "a closenotifier sender",
}
var stacks string
for i := 0; i < 4; i++ {

View File

@ -1433,8 +1433,8 @@ func TestParseErrors(t *testing.T) {
{"mysql://x@y(1.2.3.4:123)/foo", false},
{"http://[]%20%48%54%54%50%2f%31%2e%31%0a%4d%79%48%65%61%64%65%72%3a%20%31%32%33%0a%0a/", true}, // golang.org/issue/11208
{"http://a b.com/", true}, // no space in host name please
{"cache_object://foo", true}, // scheme cannot have _, relative path cannot have : in first segment
{"http://a b.com/", true}, // no space in host name please
{"cache_object://foo", true}, // scheme cannot have _, relative path cannot have : in first segment
{"cache_object:foo", true},
{"cache_object:foo/bar", true},
{"cache_object/:foo/bar", false},

View File

@ -423,11 +423,11 @@ func TestEmptyKeyAndValue(t *testing.T) {
// ("quick keys") as well as long keys.
func TestSingleBucketMapStringKeys_DupLen(t *testing.T) {
testMapLookups(t, map[string]string{
"x": "x1val",
"xx": "x2val",
"foo": "fooval",
"bar": "barval", // same key length as "foo"
"xxxx": "x4val",
"x": "x1val",
"xx": "x2val",
"foo": "fooval",
"bar": "barval", // same key length as "foo"
"xxxx": "x4val",
strings.Repeat("x", 128): "longval1",
strings.Repeat("y", 128): "longval2",
})

View File

@ -673,7 +673,7 @@ var gobTests = []Time{
Date(0, 1, 2, 3, 4, 5, 6, UTC),
Date(7, 8, 9, 10, 11, 12, 13, FixedZone("", 0)),
Unix(81985467080890095, 0x76543210), // Time.sec: 0x0123456789ABCDEF
{}, // nil location
{}, // nil location
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", 32767*60)),
Date(1, 2, 3, 4, 5, 6, 7, FixedZone("", -32768*60)),
}

View File

@ -109,41 +109,41 @@ var abbrs = map[string]abbr{
"Lord Howe Standard Time": {"+1030", "+11"}, // Australia/Lord_Howe
"W. Australia Standard Time": {"AWST", "AWST"}, // Australia/Perth
"AUS Eastern Standard Time": {"AEST", "AEDT"}, // Australia/Sydney
"UTC": {"GMT", "GMT"}, // Etc/GMT
"UTC-11": {"-11", "-11"}, // Etc/GMT+11
"Dateline Standard Time": {"-12", "-12"}, // Etc/GMT+12
"UTC-02": {"-02", "-02"}, // Etc/GMT+2
"UTC-08": {"-08", "-08"}, // Etc/GMT+8
"UTC-09": {"-09", "-09"}, // Etc/GMT+9
"UTC+12": {"+12", "+12"}, // Etc/GMT-12
"UTC+13": {"+13", "+13"}, // Etc/GMT-13
"Astrakhan Standard Time": {"+04", "+04"}, // Europe/Astrakhan
"W. Europe Standard Time": {"CET", "CEST"}, // Europe/Berlin
"GTB Standard Time": {"EET", "EEST"}, // Europe/Bucharest
"Central Europe Standard Time": {"CET", "CEST"}, // Europe/Budapest
"E. Europe Standard Time": {"EET", "EEST"}, // Europe/Chisinau
"Turkey Standard Time": {"+03", "+03"}, // Europe/Istanbul
"Kaliningrad Standard Time": {"EET", "EET"}, // Europe/Kaliningrad
"FLE Standard Time": {"EET", "EEST"}, // Europe/Kiev
"GMT Standard Time": {"GMT", "BST"}, // Europe/London
"Belarus Standard Time": {"+03", "+03"}, // Europe/Minsk
"Russian Standard Time": {"MSK", "MSK"}, // Europe/Moscow
"Romance Standard Time": {"CET", "CEST"}, // Europe/Paris
"Russia Time Zone 3": {"+04", "+04"}, // Europe/Samara
"Saratov Standard Time": {"+03", "+04"}, // Europe/Saratov
"Central European Standard Time": {"CET", "CEST"}, // Europe/Warsaw
"Mauritius Standard Time": {"+04", "+04"}, // Indian/Mauritius
"Samoa Standard Time": {"+13", "+14"}, // Pacific/Apia
"New Zealand Standard Time": {"NZST", "NZDT"}, // Pacific/Auckland
"Bougainville Standard Time": {"+11", "+11"}, // Pacific/Bougainville
"Chatham Islands Standard Time": {"+1245", "+1345"}, // Pacific/Chatham
"Easter Island Standard Time": {"-06", "-05"}, // Pacific/Easter
"Fiji Standard Time": {"+12", "+13"}, // Pacific/Fiji
"Central Pacific Standard Time": {"+11", "+11"}, // Pacific/Guadalcanal
"Hawaiian Standard Time": {"HST", "HST"}, // Pacific/Honolulu
"Line Islands Standard Time": {"+14", "+14"}, // Pacific/Kiritimati
"Marquesas Standard Time": {"-0930", "-0930"}, // Pacific/Marquesas
"Norfolk Standard Time": {"+11", "+11"}, // Pacific/Norfolk
"West Pacific Standard Time": {"+10", "+10"}, // Pacific/Port_Moresby
"Tonga Standard Time": {"+13", "+14"}, // Pacific/Tongatapu
"UTC": {"GMT", "GMT"}, // Etc/GMT
"UTC-11": {"-11", "-11"}, // Etc/GMT+11
"Dateline Standard Time": {"-12", "-12"}, // Etc/GMT+12
"UTC-02": {"-02", "-02"}, // Etc/GMT+2
"UTC-08": {"-08", "-08"}, // Etc/GMT+8
"UTC-09": {"-09", "-09"}, // Etc/GMT+9
"UTC+12": {"+12", "+12"}, // Etc/GMT-12
"UTC+13": {"+13", "+13"}, // Etc/GMT-13
"Astrakhan Standard Time": {"+04", "+04"}, // Europe/Astrakhan
"W. Europe Standard Time": {"CET", "CEST"}, // Europe/Berlin
"GTB Standard Time": {"EET", "EEST"}, // Europe/Bucharest
"Central Europe Standard Time": {"CET", "CEST"}, // Europe/Budapest
"E. Europe Standard Time": {"EET", "EEST"}, // Europe/Chisinau
"Turkey Standard Time": {"+03", "+03"}, // Europe/Istanbul
"Kaliningrad Standard Time": {"EET", "EET"}, // Europe/Kaliningrad
"FLE Standard Time": {"EET", "EEST"}, // Europe/Kiev
"GMT Standard Time": {"GMT", "BST"}, // Europe/London
"Belarus Standard Time": {"+03", "+03"}, // Europe/Minsk
"Russian Standard Time": {"MSK", "MSK"}, // Europe/Moscow
"Romance Standard Time": {"CET", "CEST"}, // Europe/Paris
"Russia Time Zone 3": {"+04", "+04"}, // Europe/Samara
"Saratov Standard Time": {"+03", "+04"}, // Europe/Saratov
"Central European Standard Time": {"CET", "CEST"}, // Europe/Warsaw
"Mauritius Standard Time": {"+04", "+04"}, // Indian/Mauritius
"Samoa Standard Time": {"+13", "+14"}, // Pacific/Apia
"New Zealand Standard Time": {"NZST", "NZDT"}, // Pacific/Auckland
"Bougainville Standard Time": {"+11", "+11"}, // Pacific/Bougainville
"Chatham Islands Standard Time": {"+1245", "+1345"}, // Pacific/Chatham
"Easter Island Standard Time": {"-06", "-05"}, // Pacific/Easter
"Fiji Standard Time": {"+12", "+13"}, // Pacific/Fiji
"Central Pacific Standard Time": {"+11", "+11"}, // Pacific/Guadalcanal
"Hawaiian Standard Time": {"HST", "HST"}, // Pacific/Honolulu
"Line Islands Standard Time": {"+14", "+14"}, // Pacific/Kiritimati
"Marquesas Standard Time": {"-0930", "-0930"}, // Pacific/Marquesas
"Norfolk Standard Time": {"+11", "+11"}, // Pacific/Norfolk
"West Pacific Standard Time": {"+10", "+10"}, // Pacific/Port_Moresby
"Tonga Standard Time": {"+13", "+14"}, // Pacific/Tongatapu
}