Commit ed7f323c authored by Shulhan's avatar Shulhan Committed by Ian Lance Taylor

all: simplify code using "gofmt -s -w"

Most changes are removing redundant declaration of type when direct
instantiating value of map or slice, e.g. []T{T{}} become []T{{}}.

Small changes are removing the high order of subslice if its value
is the length of slice itself, e.g. T[:len(T)] become T[:].

The following file is excluded due to incompatibility with go1.4,

- src/cmd/compile/internal/gc/ssa.go

Change-Id: Id3abb09401795ce1e6da591a89749cba8502fb26
Reviewed-on: https://go-review.googlesource.com/c/go/+/166437
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 04845fe7
...@@ -25,16 +25,16 @@ type iselOp struct { ...@@ -25,16 +25,16 @@ type iselOp struct {
var iselRegs = [2]int16{ppc64.REG_R0, ppc64.REGTMP} var iselRegs = [2]int16{ppc64.REG_R0, ppc64.REGTMP}
var iselOps = map[ssa.Op]iselOp{ var iselOps = map[ssa.Op]iselOp{
ssa.OpPPC64Equal: iselOp{cond: ppc64.C_COND_EQ, valueIfCond: 1}, ssa.OpPPC64Equal: {cond: ppc64.C_COND_EQ, valueIfCond: 1},
ssa.OpPPC64NotEqual: iselOp{cond: ppc64.C_COND_EQ, valueIfCond: 0}, ssa.OpPPC64NotEqual: {cond: ppc64.C_COND_EQ, valueIfCond: 0},
ssa.OpPPC64LessThan: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 1}, ssa.OpPPC64LessThan: {cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64GreaterEqual: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 0}, ssa.OpPPC64GreaterEqual: {cond: ppc64.C_COND_LT, valueIfCond: 0},
ssa.OpPPC64GreaterThan: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 1}, ssa.OpPPC64GreaterThan: {cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64LessEqual: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 0}, ssa.OpPPC64LessEqual: {cond: ppc64.C_COND_GT, valueIfCond: 0},
ssa.OpPPC64FLessThan: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 1}, ssa.OpPPC64FLessThan: {cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64FGreaterThan: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 1}, ssa.OpPPC64FGreaterThan: {cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64FLessEqual: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 1}, // 2 comparisons, 2nd is EQ ssa.OpPPC64FLessEqual: {cond: ppc64.C_COND_LT, valueIfCond: 1}, // 2 comparisons, 2nd is EQ
ssa.OpPPC64FGreaterEqual: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 1}, // 2 comparisons, 2nd is EQ ssa.OpPPC64FGreaterEqual: {cond: ppc64.C_COND_GT, valueIfCond: 1}, // 2 comparisons, 2nd is EQ
} }
// markMoves marks any MOVXconst ops that need to avoid clobbering flags. // markMoves marks any MOVXconst ops that need to avoid clobbering flags.
......
...@@ -62,7 +62,7 @@ func PseudoVersion(major, older string, t time.Time, rev string) string { ...@@ -62,7 +62,7 @@ func PseudoVersion(major, older string, t time.Time, rev string) string {
// Form (2), (3). // Form (2), (3).
// Extract patch from vMAJOR.MINOR.PATCH // Extract patch from vMAJOR.MINOR.PATCH
v := older[:len(older)] v := older[:]
i := strings.LastIndex(v, ".") + 1 i := strings.LastIndex(v, ".") + 1
v, patch := v[:i], v[i:] v, patch := v[:i], v[i:]
......
This diff is collapsed.
...@@ -164,9 +164,9 @@ func main() { ...@@ -164,9 +164,9 @@ func main() {
}` }`
want := map[string]map[string]bool{ want := map[string]map[string]bool{
"main.Foo": map[string]bool{"v": false}, "main.Foo": {"v": false},
"main.Bar": map[string]bool{"Foo": true, "name": false}, "main.Bar": {"Foo": true, "name": false},
"main.Baz": map[string]bool{"Foo": true, "name": false}, "main.Baz": {"Foo": true, "name": false},
} }
dir, err := ioutil.TempDir("", "TestEmbeddedStructMarker") dir, err := ioutil.TempDir("", "TestEmbeddedStructMarker")
......
...@@ -54,21 +54,21 @@ type wasmFuncType struct { ...@@ -54,21 +54,21 @@ type wasmFuncType struct {
} }
var wasmFuncTypes = map[string]*wasmFuncType{ var wasmFuncTypes = map[string]*wasmFuncType{
"_rt0_wasm_js": &wasmFuncType{Params: []byte{}}, // "_rt0_wasm_js": {Params: []byte{}}, //
"wasm_export_run": &wasmFuncType{Params: []byte{I32, I32}}, // argc, argv "wasm_export_run": {Params: []byte{I32, I32}}, // argc, argv
"wasm_export_resume": &wasmFuncType{Params: []byte{}}, // "wasm_export_resume": {Params: []byte{}}, //
"wasm_export_getsp": &wasmFuncType{Results: []byte{I32}}, // sp "wasm_export_getsp": {Results: []byte{I32}}, // sp
"wasm_pc_f_loop": &wasmFuncType{Params: []byte{}}, // "wasm_pc_f_loop": {Params: []byte{}}, //
"runtime.wasmMove": &wasmFuncType{Params: []byte{I32, I32, I32}}, // dst, src, len "runtime.wasmMove": {Params: []byte{I32, I32, I32}}, // dst, src, len
"runtime.wasmZero": &wasmFuncType{Params: []byte{I32, I32}}, // ptr, len "runtime.wasmZero": {Params: []byte{I32, I32}}, // ptr, len
"runtime.wasmDiv": &wasmFuncType{Params: []byte{I64, I64}, Results: []byte{I64}}, // x, y -> x/y "runtime.wasmDiv": {Params: []byte{I64, I64}, Results: []byte{I64}}, // x, y -> x/y
"runtime.wasmTruncS": &wasmFuncType{Params: []byte{F64}, Results: []byte{I64}}, // x -> int(x) "runtime.wasmTruncS": {Params: []byte{F64}, Results: []byte{I64}}, // x -> int(x)
"runtime.wasmTruncU": &wasmFuncType{Params: []byte{F64}, Results: []byte{I64}}, // x -> uint(x) "runtime.wasmTruncU": {Params: []byte{F64}, Results: []byte{I64}}, // x -> uint(x)
"runtime.gcWriteBarrier": &wasmFuncType{Params: []byte{I64, I64}}, // ptr, val "runtime.gcWriteBarrier": {Params: []byte{I64, I64}}, // ptr, val
"cmpbody": &wasmFuncType{Params: []byte{I64, I64, I64, I64}, Results: []byte{I64}}, // a, alen, b, blen -> -1/0/1 "cmpbody": {Params: []byte{I64, I64, I64, I64}, Results: []byte{I64}}, // a, alen, b, blen -> -1/0/1
"memeqbody": &wasmFuncType{Params: []byte{I64, I64, I64}, Results: []byte{I64}}, // a, b, len -> 0/1 "memeqbody": {Params: []byte{I64, I64, I64}, Results: []byte{I64}}, // a, b, len -> 0/1
"memcmp": &wasmFuncType{Params: []byte{I32, I32, I32}, Results: []byte{I32}}, // a, b, len -> <0/0/>0 "memcmp": {Params: []byte{I32, I32, I32}, Results: []byte{I32}}, // a, b, len -> <0/0/>0
"memchr": &wasmFuncType{Params: []byte{I32, I32, I32}, Results: []byte{I32}}, // s, c, len -> index "memchr": {Params: []byte{I32, I32, I32}, Results: []byte{I32}}, // s, c, len -> index
} }
func assignAddress(ctxt *ld.Link, sect *sym.Section, n int, s *sym.Symbol, va uint64, isTramp bool) (*sym.Section, int, uint64) { func assignAddress(ctxt *ld.Link, sect *sym.Section, n int, s *sym.Symbol, va uint64, isTramp bool) (*sym.Section, int, uint64) {
...@@ -105,12 +105,12 @@ func asmb2(ctxt *ld.Link) { ...@@ -105,12 +105,12 @@ func asmb2(ctxt *ld.Link) {
// For normal Go functions the return value is // For normal Go functions the return value is
// 0 if the function returned normally or // 0 if the function returned normally or
// 1 if the stack needs to be unwound. // 1 if the stack needs to be unwound.
&wasmFuncType{Results: []byte{I32}}, {Results: []byte{I32}},
} }
// collect host imports (functions that get imported from the WebAssembly host, usually JavaScript) // collect host imports (functions that get imported from the WebAssembly host, usually JavaScript)
hostImports := []*wasmFunc{ hostImports := []*wasmFunc{
&wasmFunc{ {
Name: "debug", Name: "debug",
Type: lookupType(&wasmFuncType{Params: []byte{I32}}, &types), Type: lookupType(&wasmFuncType{Params: []byte{I32}}, &types),
}, },
......
...@@ -358,7 +358,7 @@ func buildProfile(prof map[uint64]Record) *profile.Profile { ...@@ -358,7 +358,7 @@ func buildProfile(prof map[uint64]Record) *profile.Profile {
ID: uint64(len(p.Location) + 1), ID: uint64(len(p.Location) + 1),
Address: frame.PC, Address: frame.PC,
Line: []profile.Line{ Line: []profile.Line{
profile.Line{ {
Function: fn, Function: fn,
Line: int64(frame.Line), Line: int64(frame.Line),
}, },
......
...@@ -169,12 +169,12 @@ type unmarshalTest struct { ...@@ -169,12 +169,12 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{ var largeUnmarshalTests = []unmarshalTest{
// Data length: 7_102_415_735 // Data length: 7_102_415_735
unmarshalTest{ {
state: "md5\x01\xa5\xf7\xf0=\xd6S\x85\xd9M\n}\xc3\u0601\x89\xe7@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", state: "md5\x01\xa5\xf7\xf0=\xd6S\x85\xd9M\n}\xc3\u0601\x89\xe7@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw",
sum: "cddefcf74ffec709a0b45a6a987564d5", sum: "cddefcf74ffec709a0b45a6a987564d5",
}, },
// Data length: 6_565_544_823 // Data length: 6_565_544_823
unmarshalTest{ {
state: "md5\x01{\xda\x1a\xc7\xc9'?\x83EX\xe0\x88q\xfeG\x18@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", state: "md5\x01{\xda\x1a\xc7\xc9'?\x83EX\xe0\x88q\xfeG\x18@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw",
sum: "fd9f41874ab240698e7bc9c3ae70c8e4", sum: "fd9f41874ab240698e7bc9c3ae70c8e4",
}, },
......
...@@ -168,12 +168,12 @@ type unmarshalTest struct { ...@@ -168,12 +168,12 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{ var largeUnmarshalTests = []unmarshalTest{
// Data length: 7_102_415_735 // Data length: 7_102_415_735
unmarshalTest{ {
state: "sha\x01\x13\xbc\xfe\x83\x8c\xbd\xdfP\x1f\xd8ڿ<\x9eji8t\xe1\xa5@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", state: "sha\x01\x13\xbc\xfe\x83\x8c\xbd\xdfP\x1f\xd8ڿ<\x9eji8t\xe1\xa5@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw",
sum: "bc6245c9959cc33e1c2592e5c9ea9b5d0431246c", sum: "bc6245c9959cc33e1c2592e5c9ea9b5d0431246c",
}, },
// Data length: 6_565_544_823 // Data length: 6_565_544_823
unmarshalTest{ {
state: "sha\x01m;\x16\xa6R\xbe@\xa9\xf9S\x03\x00B\xc2\xdcv\xcf@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", state: "sha\x01m;\x16\xa6R\xbe@\xa9\xf9S\x03\x00B\xc2\xdcv\xcf@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw",
sum: "8f2d1c0e4271768f35feb918bfe21ea1387a2072", sum: "8f2d1c0e4271768f35feb918bfe21ea1387a2072",
}, },
......
...@@ -241,19 +241,19 @@ type unmarshalTest struct { ...@@ -241,19 +241,19 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{ var largeUnmarshalTests = []unmarshalTest{
// Data length: 7_115_087_207 // Data length: 7_115_087_207
unmarshalTest{ {
state: "sha\x03yX\xaf\xb7\x04*\x8f\xaa\x9bx\xc5#\x1f\xeb\x94\xfdz1\xaf\xfb\n\xc93\xcf\x02\v.\xa5\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa8\x17\x9dg", state: "sha\x03yX\xaf\xb7\x04*\x8f\xaa\x9bx\xc5#\x1f\xeb\x94\xfdz1\xaf\xfb\n\xc93\xcf\x02\v.\xa5\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa8\x17\x9dg",
sum: "f5e06371f0c115e9968455c8e48a318aba548b9f15676fa41de123f7d1c99c55", sum: "f5e06371f0c115e9968455c8e48a318aba548b9f15676fa41de123f7d1c99c55",
}, },
// Data length: 7_070_038_086 // Data length: 7_070_038_086
unmarshalTest{ {
state: "sha\x03$\x933u\nV\v\xe2\xf7:0!ʳ\xa4\x13\xd3 6\xdcBB\xb5\x19\xcd=\xc1h\xee=\xb4\x9c@ABCDE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa5h8F", state: "sha\x03$\x933u\nV\v\xe2\xf7:0!ʳ\xa4\x13\xd3 6\xdcBB\xb5\x19\xcd=\xc1h\xee=\xb4\x9c@ABCDE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa5h8F",
sum: "a280b08df5eba060fcd0eb3d29320bbc038afb95781661f91bbfd0a6fc9fdd6e", sum: "a280b08df5eba060fcd0eb3d29320bbc038afb95781661f91bbfd0a6fc9fdd6e",
}, },
// Data length: 6_464_878_887 // Data length: 6_464_878_887
unmarshalTest{ {
state: "sha\x03\x9f\x12\x87G\xf2\xdf<\x82\xa0\x11/*W\x02&IKWlh\x03\x95\xb1\xab\f\n\xf6Ze\xf9\x1d\x1b\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x81V9'", state: "sha\x03\x9f\x12\x87G\xf2\xdf<\x82\xa0\x11/*W\x02&IKWlh\x03\x95\xb1\xab\f\n\xf6Ze\xf9\x1d\x1b\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x81V9'",
sum: "d2fffb762f105ab71e2d70069346c44c38c4fe183aad8cfcf5a76397c0457806", sum: "d2fffb762f105ab71e2d70069346c44c38c4fe183aad8cfcf5a76397c0457806",
}, },
......
...@@ -847,11 +847,11 @@ type unmarshalTest struct { ...@@ -847,11 +847,11 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{ var largeUnmarshalTests = []unmarshalTest{
// Data length: 6_565_544_823 // Data length: 6_565_544_823
unmarshalTest{ {
state: "sha\aηe\x0f\x0f\xe1r]#\aoJ!.{5B\xe4\x140\x91\xdd\x00a\xe1\xb3E&\xb9\xbb\aJ\x9f^\x9f\x03ͺD\x96H\x80\xb0X\x9d\xdeʸ\f\xf7:\xd5\xe6'\xb9\x93f\xddA\xf0~\xe1\x02\x14\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw", state: "sha\aηe\x0f\x0f\xe1r]#\aoJ!.{5B\xe4\x140\x91\xdd\x00a\xe1\xb3E&\xb9\xbb\aJ\x9f^\x9f\x03ͺD\x96H\x80\xb0X\x9d\xdeʸ\f\xf7:\xd5\xe6'\xb9\x93f\xddA\xf0~\xe1\x02\x14\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x87VCw",
sum: "12d612357a1dbc74a28883dff79b83e7d2b881ae40d7a67fd7305490bc8a641cd1ce9ece598192080d6e9ac7e75d5988567a58a9812991299eb99a04ecb69523", sum: "12d612357a1dbc74a28883dff79b83e7d2b881ae40d7a67fd7305490bc8a641cd1ce9ece598192080d6e9ac7e75d5988567a58a9812991299eb99a04ecb69523",
}, },
unmarshalTest{ {
state: "sha\a2\xd2\xdc\xf5\xd7\xe2\xf9\x97\xaa\xe7}Fϱ\xbc\x8e\xbf\x12h\x83Z\xa1\xc7\xf5p>bfS T\xea\xee\x1e\xa6Z\x9c\xa4ڶ\u0086\bn\xe47\x8fsGs3\xe0\xda\\\x9dqZ\xa5\xf6\xd0kM\xa1\xf2\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw", state: "sha\a2\xd2\xdc\xf5\xd7\xe2\xf9\x97\xaa\xe7}Fϱ\xbc\x8e\xbf\x12h\x83Z\xa1\xc7\xf5p>bfS T\xea\xee\x1e\xa6Z\x9c\xa4ڶ\u0086\bn\xe47\x8fsGs3\xe0\xda\\\x9dqZ\xa5\xf6\xd0kM\xa1\xf2\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuv\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xa7VCw",
sum: "94a04b9a901254cd94ca0313557e4be3ab1ca86e920c1f3efdc22d361e9ae12be66bc6d6dc5db79a0a4aa6eca6f293c1e9095bbae127ae405f6c325478343299", sum: "94a04b9a901254cd94ca0313557e4be3ab1ca86e920c1f3efdc22d361e9ae12be66bc6d6dc5db79a0a4aa6eca6f293c1e9095bbae127ae405f6c325478343299",
}, },
......
This diff is collapsed.
...@@ -369,7 +369,7 @@ func domainToReverseLabels(domain string) (reverseLabels []string, ok bool) { ...@@ -369,7 +369,7 @@ func domainToReverseLabels(domain string) (reverseLabels []string, ok bool) {
reverseLabels = append(reverseLabels, domain) reverseLabels = append(reverseLabels, domain)
domain = "" domain = ""
} else { } else {
reverseLabels = append(reverseLabels, domain[i+1:len(domain)]) reverseLabels = append(reverseLabels, domain[i+1:])
domain = domain[:i] domain = domain[:i]
} }
} }
......
...@@ -439,7 +439,7 @@ func TestDriverArgs(t *testing.T) { ...@@ -439,7 +439,7 @@ func TestDriverArgs(t *testing.T) {
0: { 0: {
args: []interface{}{Valuer_V("foo")}, args: []interface{}{Valuer_V("foo")},
want: []driver.NamedValue{ want: []driver.NamedValue{
driver.NamedValue{ {
Ordinal: 1, Ordinal: 1,
Value: "FOO", Value: "FOO",
}, },
...@@ -448,7 +448,7 @@ func TestDriverArgs(t *testing.T) { ...@@ -448,7 +448,7 @@ func TestDriverArgs(t *testing.T) {
1: { 1: {
args: []interface{}{nilValuerVPtr}, args: []interface{}{nilValuerVPtr},
want: []driver.NamedValue{ want: []driver.NamedValue{
driver.NamedValue{ {
Ordinal: 1, Ordinal: 1,
Value: nil, Value: nil,
}, },
...@@ -457,7 +457,7 @@ func TestDriverArgs(t *testing.T) { ...@@ -457,7 +457,7 @@ func TestDriverArgs(t *testing.T) {
2: { 2: {
args: []interface{}{nilValuerPPtr}, args: []interface{}{nilValuerPPtr},
want: []driver.NamedValue{ want: []driver.NamedValue{
driver.NamedValue{ {
Ordinal: 1, Ordinal: 1,
Value: "nil-to-str", Value: "nil-to-str",
}, },
...@@ -466,7 +466,7 @@ func TestDriverArgs(t *testing.T) { ...@@ -466,7 +466,7 @@ func TestDriverArgs(t *testing.T) {
3: { 3: {
args: []interface{}{"plain-str"}, args: []interface{}{"plain-str"},
want: []driver.NamedValue{ want: []driver.NamedValue{
driver.NamedValue{ {
Ordinal: 1, Ordinal: 1,
Value: "plain-str", Value: "plain-str",
}, },
...@@ -475,7 +475,7 @@ func TestDriverArgs(t *testing.T) { ...@@ -475,7 +475,7 @@ func TestDriverArgs(t *testing.T) {
4: { 4: {
args: []interface{}{nilStrPtr}, args: []interface{}{nilStrPtr},
want: []driver.NamedValue{ want: []driver.NamedValue{
driver.NamedValue{ {
Ordinal: 1, Ordinal: 1,
Value: nil, Value: nil,
}, },
......
...@@ -154,7 +154,7 @@ var fileTests = []fileTest{ ...@@ -154,7 +154,7 @@ var fileTests = []fileTest{
nil, nil,
nil, nil,
map[string][]Reloc{ map[string][]Reloc{
"__text": []Reloc{ "__text": {
{ {
Addr: 0x1d, Addr: 0x1d,
Type: uint8(GENERIC_RELOC_VANILLA), Type: uint8(GENERIC_RELOC_VANILLA),
...@@ -189,7 +189,7 @@ var fileTests = []fileTest{ ...@@ -189,7 +189,7 @@ var fileTests = []fileTest{
nil, nil,
nil, nil,
map[string][]Reloc{ map[string][]Reloc{
"__text": []Reloc{ "__text": {
{ {
Addr: 0x19, Addr: 0x19,
Type: uint8(X86_64_RELOC_BRANCH), Type: uint8(X86_64_RELOC_BRANCH),
...@@ -207,7 +207,7 @@ var fileTests = []fileTest{ ...@@ -207,7 +207,7 @@ var fileTests = []fileTest{
Value: 2, Value: 2,
}, },
}, },
"__compact_unwind": []Reloc{ "__compact_unwind": {
{ {
Addr: 0x0, Addr: 0x0,
Type: uint8(X86_64_RELOC_UNSIGNED), Type: uint8(X86_64_RELOC_UNSIGNED),
......
...@@ -539,52 +539,52 @@ func TestBufferedDecodingSameError(t *testing.T) { ...@@ -539,52 +539,52 @@ func TestBufferedDecodingSameError(t *testing.T) {
// NBSWY3DPO5XXE3DE == helloworld // NBSWY3DPO5XXE3DE == helloworld
// Test with "ZZ" as extra input // Test with "ZZ" as extra input
{"helloworld", [][]string{ {"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZ"}, {"NBSW", "Y3DP", "O5XX", "E3DE", "ZZ"},
[]string{"NBSWY3DPO5XXE3DE", "ZZ"}, {"NBSWY3DPO5XXE3DE", "ZZ"},
[]string{"NBSWY3DPO5XXE3DEZZ"}, {"NBSWY3DPO5XXE3DEZZ"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZ"}, {"NBS", "WY3", "DPO", "5XX", "E3D", "EZZ"},
[]string{"NBSWY3DPO5XXE3", "DEZZ"}, {"NBSWY3DPO5XXE3", "DEZZ"},
}, io.ErrUnexpectedEOF}, }, io.ErrUnexpectedEOF},
// Test with "ZZY" as extra input // Test with "ZZY" as extra input
{"helloworld", [][]string{ {"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZY"}, {"NBSW", "Y3DP", "O5XX", "E3DE", "ZZY"},
[]string{"NBSWY3DPO5XXE3DE", "ZZY"}, {"NBSWY3DPO5XXE3DE", "ZZY"},
[]string{"NBSWY3DPO5XXE3DEZZY"}, {"NBSWY3DPO5XXE3DEZZY"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZY"}, {"NBS", "WY3", "DPO", "5XX", "E3D", "EZZY"},
[]string{"NBSWY3DPO5XXE3", "DEZZY"}, {"NBSWY3DPO5XXE3", "DEZZY"},
}, io.ErrUnexpectedEOF}, }, io.ErrUnexpectedEOF},
// Normal case, this is valid input // Normal case, this is valid input
{"helloworld", [][]string{ {"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE"}, {"NBSW", "Y3DP", "O5XX", "E3DE"},
[]string{"NBSWY3DPO5XXE3DE"}, {"NBSWY3DPO5XXE3DE"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "E"}, {"NBS", "WY3", "DPO", "5XX", "E3D", "E"},
[]string{"NBSWY3DPO5XXE3", "DE"}, {"NBSWY3DPO5XXE3", "DE"},
}, nil}, }, nil},
// MZXW6YTB = fooba // MZXW6YTB = fooba
{"fooba", [][]string{ {"fooba", [][]string{
[]string{"MZXW6YTBZZ"}, {"MZXW6YTBZZ"},
[]string{"MZXW6YTBZ", "Z"}, {"MZXW6YTBZ", "Z"},
[]string{"MZXW6YTB", "ZZ"}, {"MZXW6YTB", "ZZ"},
[]string{"MZXW6YT", "BZZ"}, {"MZXW6YT", "BZZ"},
[]string{"MZXW6Y", "TBZZ"}, {"MZXW6Y", "TBZZ"},
[]string{"MZXW6Y", "TB", "ZZ"}, {"MZXW6Y", "TB", "ZZ"},
[]string{"MZXW6", "YTBZZ"}, {"MZXW6", "YTBZZ"},
[]string{"MZXW6", "YTB", "ZZ"}, {"MZXW6", "YTB", "ZZ"},
[]string{"MZXW6", "YT", "BZZ"}, {"MZXW6", "YT", "BZZ"},
}, io.ErrUnexpectedEOF}, }, io.ErrUnexpectedEOF},
// Normal case, this is valid input // Normal case, this is valid input
{"fooba", [][]string{ {"fooba", [][]string{
[]string{"MZXW6YTB"}, {"MZXW6YTB"},
[]string{"MZXW6YT", "B"}, {"MZXW6YT", "B"},
[]string{"MZXW6Y", "TB"}, {"MZXW6Y", "TB"},
[]string{"MZXW6", "YTB"}, {"MZXW6", "YTB"},
[]string{"MZXW6", "YT", "B"}, {"MZXW6", "YT", "B"},
[]string{"MZXW", "6YTB"}, {"MZXW", "6YTB"},
[]string{"MZXW", "6Y", "TB"}, {"MZXW", "6Y", "TB"},
}, nil}, }, nil},
} }
......
...@@ -132,12 +132,12 @@ func ExamplePutVarint() { ...@@ -132,12 +132,12 @@ func ExamplePutVarint() {
func ExampleUvarint() { func ExampleUvarint() {
inputs := [][]byte{ inputs := [][]byte{
[]byte{0x01}, {0x01},
[]byte{0x02}, {0x02},
[]byte{0x7f}, {0x7f},
[]byte{0x80, 0x01}, {0x80, 0x01},
[]byte{0xff, 0x01}, {0xff, 0x01},
[]byte{0x80, 0x02}, {0x80, 0x02},
} }
for _, b := range inputs { for _, b := range inputs {
x, n := binary.Uvarint(b) x, n := binary.Uvarint(b)
...@@ -157,15 +157,15 @@ func ExampleUvarint() { ...@@ -157,15 +157,15 @@ func ExampleUvarint() {
func ExampleVarint() { func ExampleVarint() {
inputs := [][]byte{ inputs := [][]byte{
[]byte{0x81, 0x01}, {0x81, 0x01},
[]byte{0x7f}, {0x7f},
[]byte{0x03}, {0x03},
[]byte{0x01}, {0x01},
[]byte{0x00}, {0x00},
[]byte{0x02}, {0x02},
[]byte{0x04}, {0x04},
[]byte{0x7e}, {0x7e},
[]byte{0x80, 0x01}, {0x80, 0x01},
} }
for _, b := range inputs { for _, b := range inputs {
x, n := binary.Varint(b) x, n := binary.Varint(b)
......
...@@ -25,8 +25,8 @@ var archTest = []archiveTest{ ...@@ -25,8 +25,8 @@ var archTest = []archiveTest{
{"printhello.o", 860}, {"printhello.o", 860},
}, },
[]FileHeader{ []FileHeader{
FileHeader{U64_TOCMAGIC}, {U64_TOCMAGIC},
FileHeader{U64_TOCMAGIC}, {U64_TOCMAGIC},
}, },
}, },
{ {
......
...@@ -4430,37 +4430,37 @@ func TestStructOfFieldName(t *testing.T) { ...@@ -4430,37 +4430,37 @@ func TestStructOfFieldName(t *testing.T) {
// invalid field name "1nvalid" // invalid field name "1nvalid"
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Name: "valid", Type: TypeOf("")}, {Name: "valid", Type: TypeOf("")},
StructField{Name: "1nvalid", Type: TypeOf("")}, {Name: "1nvalid", Type: TypeOf("")},
}) })
}) })
// invalid field name "+" // invalid field name "+"
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Name: "val1d", Type: TypeOf("")}, {Name: "val1d", Type: TypeOf("")},
StructField{Name: "+", Type: TypeOf("")}, {Name: "+", Type: TypeOf("")},
}) })
}) })
// no field name // no field name
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Name: "", Type: TypeOf("")}, {Name: "", Type: TypeOf("")},
}) })
}) })
// verify creation of a struct with valid struct fields // verify creation of a struct with valid struct fields
validFields := []StructField{ validFields := []StructField{
StructField{ {
Name: "φ", Name: "φ",
Type: TypeOf(""), Type: TypeOf(""),
}, },
StructField{ {
Name: "ValidName", Name: "ValidName",
Type: TypeOf(""), Type: TypeOf(""),
}, },
StructField{ {
Name: "Val1dNam5", Name: "Val1dNam5",
Type: TypeOf(""), Type: TypeOf(""),
}, },
...@@ -4477,21 +4477,21 @@ func TestStructOfFieldName(t *testing.T) { ...@@ -4477,21 +4477,21 @@ func TestStructOfFieldName(t *testing.T) {
func TestStructOf(t *testing.T) { func TestStructOf(t *testing.T) {
// check construction and use of type not in binary // check construction and use of type not in binary
fields := []StructField{ fields := []StructField{
StructField{ {
Name: "S", Name: "S",
Tag: "s", Tag: "s",
Type: TypeOf(""), Type: TypeOf(""),
}, },
StructField{ {
Name: "X", Name: "X",
Tag: "x", Tag: "x",
Type: TypeOf(byte(0)), Type: TypeOf(byte(0)),
}, },
StructField{ {
Name: "Y", Name: "Y",
Type: TypeOf(uint64(0)), Type: TypeOf(uint64(0)),
}, },
StructField{ {
Name: "Z", Name: "Z",
Type: TypeOf([3]uint16{}), Type: TypeOf([3]uint16{}),
}, },
...@@ -4573,20 +4573,20 @@ func TestStructOf(t *testing.T) { ...@@ -4573,20 +4573,20 @@ func TestStructOf(t *testing.T) {
// check duplicate names // check duplicate names
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Name: "string", Type: TypeOf("")}, {Name: "string", Type: TypeOf("")},
StructField{Name: "string", Type: TypeOf("")}, {Name: "string", Type: TypeOf("")},
}) })
}) })
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Type: TypeOf("")}, {Type: TypeOf("")},
StructField{Name: "string", Type: TypeOf("")}, {Name: "string", Type: TypeOf("")},
}) })
}) })
shouldPanic(func() { shouldPanic(func() {
StructOf([]StructField{ StructOf([]StructField{
StructField{Type: TypeOf("")}, {Type: TypeOf("")},
StructField{Type: TypeOf("")}, {Type: TypeOf("")},
}) })
}) })
// check that type already in binary is found // check that type already in binary is found
...@@ -4596,7 +4596,7 @@ func TestStructOf(t *testing.T) { ...@@ -4596,7 +4596,7 @@ func TestStructOf(t *testing.T) {
type structFieldType interface{} type structFieldType interface{}
checkSameType(t, checkSameType(t,
StructOf([]StructField{ StructOf([]StructField{
StructField{ {
Name: "F", Name: "F",
Type: TypeOf((*structFieldType)(nil)).Elem(), Type: TypeOf((*structFieldType)(nil)).Elem(),
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment