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 {
var iselRegs = [2]int16{ppc64.REG_R0, ppc64.REGTMP}
var iselOps = map[ssa.Op]iselOp{
ssa.OpPPC64Equal: iselOp{cond: ppc64.C_COND_EQ, valueIfCond: 1},
ssa.OpPPC64NotEqual: iselOp{cond: ppc64.C_COND_EQ, valueIfCond: 0},
ssa.OpPPC64LessThan: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64GreaterEqual: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 0},
ssa.OpPPC64GreaterThan: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64LessEqual: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 0},
ssa.OpPPC64FLessThan: iselOp{cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64FGreaterThan: iselOp{cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64FLessEqual: iselOp{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.OpPPC64Equal: {cond: ppc64.C_COND_EQ, valueIfCond: 1},
ssa.OpPPC64NotEqual: {cond: ppc64.C_COND_EQ, valueIfCond: 0},
ssa.OpPPC64LessThan: {cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64GreaterEqual: {cond: ppc64.C_COND_LT, valueIfCond: 0},
ssa.OpPPC64GreaterThan: {cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64LessEqual: {cond: ppc64.C_COND_GT, valueIfCond: 0},
ssa.OpPPC64FLessThan: {cond: ppc64.C_COND_LT, valueIfCond: 1},
ssa.OpPPC64FGreaterThan: {cond: ppc64.C_COND_GT, valueIfCond: 1},
ssa.OpPPC64FLessEqual: {cond: ppc64.C_COND_LT, 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.
......
......@@ -62,7 +62,7 @@ func PseudoVersion(major, older string, t time.Time, rev string) string {
// Form (2), (3).
// Extract patch from vMAJOR.MINOR.PATCH
v := older[:len(older)]
v := older[:]
i := strings.LastIndex(v, ".") + 1
v, patch := v[:i], v[i:]
......
This diff is collapsed.
......@@ -164,9 +164,9 @@ func main() {
}`
want := map[string]map[string]bool{
"main.Foo": map[string]bool{"v": false},
"main.Bar": map[string]bool{"Foo": true, "name": false},
"main.Baz": map[string]bool{"Foo": true, "name": false},
"main.Foo": {"v": false},
"main.Bar": {"Foo": true, "name": false},
"main.Baz": {"Foo": true, "name": false},
}
dir, err := ioutil.TempDir("", "TestEmbeddedStructMarker")
......
......@@ -54,21 +54,21 @@ type wasmFuncType struct {
}
var wasmFuncTypes = map[string]*wasmFuncType{
"_rt0_wasm_js": &wasmFuncType{Params: []byte{}}, //
"wasm_export_run": &wasmFuncType{Params: []byte{I32, I32}}, // argc, argv
"wasm_export_resume": &wasmFuncType{Params: []byte{}}, //
"wasm_export_getsp": &wasmFuncType{Results: []byte{I32}}, // sp
"wasm_pc_f_loop": &wasmFuncType{Params: []byte{}}, //
"runtime.wasmMove": &wasmFuncType{Params: []byte{I32, I32, I32}}, // dst, src, len
"runtime.wasmZero": &wasmFuncType{Params: []byte{I32, I32}}, // ptr, len
"runtime.wasmDiv": &wasmFuncType{Params: []byte{I64, I64}, Results: []byte{I64}}, // x, y -> x/y
"runtime.wasmTruncS": &wasmFuncType{Params: []byte{F64}, Results: []byte{I64}}, // x -> int(x)
"runtime.wasmTruncU": &wasmFuncType{Params: []byte{F64}, Results: []byte{I64}}, // x -> uint(x)
"runtime.gcWriteBarrier": &wasmFuncType{Params: []byte{I64, I64}}, // ptr, val
"cmpbody": &wasmFuncType{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
"memcmp": &wasmFuncType{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
"_rt0_wasm_js": {Params: []byte{}}, //
"wasm_export_run": {Params: []byte{I32, I32}}, // argc, argv
"wasm_export_resume": {Params: []byte{}}, //
"wasm_export_getsp": {Results: []byte{I32}}, // sp
"wasm_pc_f_loop": {Params: []byte{}}, //
"runtime.wasmMove": {Params: []byte{I32, I32, I32}}, // dst, src, len
"runtime.wasmZero": {Params: []byte{I32, I32}}, // ptr, len
"runtime.wasmDiv": {Params: []byte{I64, I64}, Results: []byte{I64}}, // x, y -> x/y
"runtime.wasmTruncS": {Params: []byte{F64}, Results: []byte{I64}}, // x -> int(x)
"runtime.wasmTruncU": {Params: []byte{F64}, Results: []byte{I64}}, // x -> uint(x)
"runtime.gcWriteBarrier": {Params: []byte{I64, I64}}, // ptr, val
"cmpbody": {Params: []byte{I64, I64, I64, I64}, Results: []byte{I64}}, // a, alen, b, blen -> -1/0/1
"memeqbody": {Params: []byte{I64, I64, I64}, Results: []byte{I64}}, // a, b, len -> 0/1
"memcmp": {Params: []byte{I32, I32, I32}, Results: []byte{I32}}, // a, b, len -> <0/0/>0
"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) {
......@@ -105,12 +105,12 @@ func asmb2(ctxt *ld.Link) {
// For normal Go functions the return value is
// 0 if the function returned normally or
// 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)
hostImports := []*wasmFunc{
&wasmFunc{
{
Name: "debug",
Type: lookupType(&wasmFuncType{Params: []byte{I32}}, &types),
},
......
......@@ -358,7 +358,7 @@ func buildProfile(prof map[uint64]Record) *profile.Profile {
ID: uint64(len(p.Location) + 1),
Address: frame.PC,
Line: []profile.Line{
profile.Line{
{
Function: fn,
Line: int64(frame.Line),
},
......
......@@ -169,12 +169,12 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{
// 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",
sum: "cddefcf74ffec709a0b45a6a987564d5",
},
// 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",
sum: "fd9f41874ab240698e7bc9c3ae70c8e4",
},
......
......@@ -168,12 +168,12 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{
// 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",
sum: "bc6245c9959cc33e1c2592e5c9ea9b5d0431246c",
},
// 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",
sum: "8f2d1c0e4271768f35feb918bfe21ea1387a2072",
},
......
......@@ -241,19 +241,19 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{
// 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",
sum: "f5e06371f0c115e9968455c8e48a318aba548b9f15676fa41de123f7d1c99c55",
},
// 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",
sum: "a280b08df5eba060fcd0eb3d29320bbc038afb95781661f91bbfd0a6fc9fdd6e",
},
// 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'",
sum: "d2fffb762f105ab71e2d70069346c44c38c4fe183aad8cfcf5a76397c0457806",
},
......
......@@ -847,11 +847,11 @@ type unmarshalTest struct {
var largeUnmarshalTests = []unmarshalTest{
// 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",
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",
sum: "94a04b9a901254cd94ca0313557e4be3ab1ca86e920c1f3efdc22d361e9ae12be66bc6d6dc5db79a0a4aa6eca6f293c1e9095bbae127ae405f6c325478343299",
},
......
This diff is collapsed.
......@@ -369,7 +369,7 @@ func domainToReverseLabels(domain string) (reverseLabels []string, ok bool) {
reverseLabels = append(reverseLabels, domain)
domain = ""
} else {
reverseLabels = append(reverseLabels, domain[i+1:len(domain)])
reverseLabels = append(reverseLabels, domain[i+1:])
domain = domain[:i]
}
}
......
......@@ -439,7 +439,7 @@ func TestDriverArgs(t *testing.T) {
0: {
args: []interface{}{Valuer_V("foo")},
want: []driver.NamedValue{
driver.NamedValue{
{
Ordinal: 1,
Value: "FOO",
},
......@@ -448,7 +448,7 @@ func TestDriverArgs(t *testing.T) {
1: {
args: []interface{}{nilValuerVPtr},
want: []driver.NamedValue{
driver.NamedValue{
{
Ordinal: 1,
Value: nil,
},
......@@ -457,7 +457,7 @@ func TestDriverArgs(t *testing.T) {
2: {
args: []interface{}{nilValuerPPtr},
want: []driver.NamedValue{
driver.NamedValue{
{
Ordinal: 1,
Value: "nil-to-str",
},
......@@ -466,7 +466,7 @@ func TestDriverArgs(t *testing.T) {
3: {
args: []interface{}{"plain-str"},
want: []driver.NamedValue{
driver.NamedValue{
{
Ordinal: 1,
Value: "plain-str",
},
......@@ -475,7 +475,7 @@ func TestDriverArgs(t *testing.T) {
4: {
args: []interface{}{nilStrPtr},
want: []driver.NamedValue{
driver.NamedValue{
{
Ordinal: 1,
Value: nil,
},
......
......@@ -154,7 +154,7 @@ var fileTests = []fileTest{
nil,
nil,
map[string][]Reloc{
"__text": []Reloc{
"__text": {
{
Addr: 0x1d,
Type: uint8(GENERIC_RELOC_VANILLA),
......@@ -189,7 +189,7 @@ var fileTests = []fileTest{
nil,
nil,
map[string][]Reloc{
"__text": []Reloc{
"__text": {
{
Addr: 0x19,
Type: uint8(X86_64_RELOC_BRANCH),
......@@ -207,7 +207,7 @@ var fileTests = []fileTest{
Value: 2,
},
},
"__compact_unwind": []Reloc{
"__compact_unwind": {
{
Addr: 0x0,
Type: uint8(X86_64_RELOC_UNSIGNED),
......
......@@ -539,52 +539,52 @@ func TestBufferedDecodingSameError(t *testing.T) {
// NBSWY3DPO5XXE3DE == helloworld
// Test with "ZZ" as extra input
{"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZ"},
[]string{"NBSWY3DPO5XXE3DE", "ZZ"},
[]string{"NBSWY3DPO5XXE3DEZZ"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZ"},
[]string{"NBSWY3DPO5XXE3", "DEZZ"},
{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZ"},
{"NBSWY3DPO5XXE3DE", "ZZ"},
{"NBSWY3DPO5XXE3DEZZ"},
{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZ"},
{"NBSWY3DPO5XXE3", "DEZZ"},
}, io.ErrUnexpectedEOF},
// Test with "ZZY" as extra input
{"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZY"},
[]string{"NBSWY3DPO5XXE3DE", "ZZY"},
[]string{"NBSWY3DPO5XXE3DEZZY"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZY"},
[]string{"NBSWY3DPO5XXE3", "DEZZY"},
{"NBSW", "Y3DP", "O5XX", "E3DE", "ZZY"},
{"NBSWY3DPO5XXE3DE", "ZZY"},
{"NBSWY3DPO5XXE3DEZZY"},
{"NBS", "WY3", "DPO", "5XX", "E3D", "EZZY"},
{"NBSWY3DPO5XXE3", "DEZZY"},
}, io.ErrUnexpectedEOF},
// Normal case, this is valid input
{"helloworld", [][]string{
[]string{"NBSW", "Y3DP", "O5XX", "E3DE"},
[]string{"NBSWY3DPO5XXE3DE"},
[]string{"NBS", "WY3", "DPO", "5XX", "E3D", "E"},
[]string{"NBSWY3DPO5XXE3", "DE"},
{"NBSW", "Y3DP", "O5XX", "E3DE"},
{"NBSWY3DPO5XXE3DE"},
{"NBS", "WY3", "DPO", "5XX", "E3D", "E"},
{"NBSWY3DPO5XXE3", "DE"},
}, nil},
// MZXW6YTB = fooba
{"fooba", [][]string{
[]string{"MZXW6YTBZZ"},
[]string{"MZXW6YTBZ", "Z"},
[]string{"MZXW6YTB", "ZZ"},
[]string{"MZXW6YT", "BZZ"},
[]string{"MZXW6Y", "TBZZ"},
[]string{"MZXW6Y", "TB", "ZZ"},
[]string{"MZXW6", "YTBZZ"},
[]string{"MZXW6", "YTB", "ZZ"},
[]string{"MZXW6", "YT", "BZZ"},
{"MZXW6YTBZZ"},
{"MZXW6YTBZ", "Z"},
{"MZXW6YTB", "ZZ"},
{"MZXW6YT", "BZZ"},
{"MZXW6Y", "TBZZ"},
{"MZXW6Y", "TB", "ZZ"},
{"MZXW6", "YTBZZ"},
{"MZXW6", "YTB", "ZZ"},
{"MZXW6", "YT", "BZZ"},
}, io.ErrUnexpectedEOF},
// Normal case, this is valid input
{"fooba", [][]string{
[]string{"MZXW6YTB"},
[]string{"MZXW6YT", "B"},
[]string{"MZXW6Y", "TB"},
[]string{"MZXW6", "YTB"},
[]string{"MZXW6", "YT", "B"},
[]string{"MZXW", "6YTB"},
[]string{"MZXW", "6Y", "TB"},
{"MZXW6YTB"},
{"MZXW6YT", "B"},
{"MZXW6Y", "TB"},
{"MZXW6", "YTB"},
{"MZXW6", "YT", "B"},
{"MZXW", "6YTB"},
{"MZXW", "6Y", "TB"},
}, nil},
}
......
......@@ -132,12 +132,12 @@ func ExamplePutVarint() {
func ExampleUvarint() {
inputs := [][]byte{
[]byte{0x01},
[]byte{0x02},
[]byte{0x7f},
[]byte{0x80, 0x01},
[]byte{0xff, 0x01},
[]byte{0x80, 0x02},
{0x01},
{0x02},
{0x7f},
{0x80, 0x01},
{0xff, 0x01},
{0x80, 0x02},
}
for _, b := range inputs {
x, n := binary.Uvarint(b)
......@@ -157,15 +157,15 @@ func ExampleUvarint() {
func ExampleVarint() {
inputs := [][]byte{
[]byte{0x81, 0x01},
[]byte{0x7f},
[]byte{0x03},
[]byte{0x01},
[]byte{0x00},
[]byte{0x02},
[]byte{0x04},
[]byte{0x7e},
[]byte{0x80, 0x01},
{0x81, 0x01},
{0x7f},
{0x03},
{0x01},
{0x00},
{0x02},
{0x04},
{0x7e},
{0x80, 0x01},
}
for _, b := range inputs {
x, n := binary.Varint(b)
......
......@@ -25,8 +25,8 @@ var archTest = []archiveTest{
{"printhello.o", 860},
},
[]FileHeader{
FileHeader{U64_TOCMAGIC},
FileHeader{U64_TOCMAGIC},
{U64_TOCMAGIC},
{U64_TOCMAGIC},
},
},
{
......
......@@ -4430,37 +4430,37 @@ func TestStructOfFieldName(t *testing.T) {
// invalid field name "1nvalid"
shouldPanic(func() {
StructOf([]StructField{
StructField{Name: "valid", Type: TypeOf("")},
StructField{Name: "1nvalid", Type: TypeOf("")},
{Name: "valid", Type: TypeOf("")},
{Name: "1nvalid", Type: TypeOf("")},
})
})
// invalid field name "+"
shouldPanic(func() {
StructOf([]StructField{
StructField{Name: "val1d", Type: TypeOf("")},
StructField{Name: "+", Type: TypeOf("")},
{Name: "val1d", Type: TypeOf("")},
{Name: "+", Type: TypeOf("")},
})
})
// no field name
shouldPanic(func() {
StructOf([]StructField{
StructField{Name: "", Type: TypeOf("")},
{Name: "", Type: TypeOf("")},
})
})
// verify creation of a struct with valid struct fields
validFields := []StructField{
StructField{
{
Name: "φ",
Type: TypeOf(""),
},
StructField{
{
Name: "ValidName",
Type: TypeOf(""),
},
StructField{
{
Name: "Val1dNam5",
Type: TypeOf(""),
},
......@@ -4477,21 +4477,21 @@ func TestStructOfFieldName(t *testing.T) {
func TestStructOf(t *testing.T) {
// check construction and use of type not in binary
fields := []StructField{
StructField{
{
Name: "S",
Tag: "s",
Type: TypeOf(""),
},
StructField{
{
Name: "X",
Tag: "x",
Type: TypeOf(byte(0)),
},
StructField{
{
Name: "Y",
Type: TypeOf(uint64(0)),
},
StructField{
{
Name: "Z",
Type: TypeOf([3]uint16{}),
},
......@@ -4573,20 +4573,20 @@ func TestStructOf(t *testing.T) {
// check duplicate names
shouldPanic(func() {
StructOf([]StructField{
StructField{Name: "string", Type: TypeOf("")},
StructField{Name: "string", Type: TypeOf("")},
{Name: "string", Type: TypeOf("")},
{Name: "string", Type: TypeOf("")},
})
})
shouldPanic(func() {
StructOf([]StructField{
StructField{Type: TypeOf("")},
StructField{Name: "string", Type: TypeOf("")},
{Type: TypeOf("")},
{Name: "string", Type: TypeOf("")},
})
})
shouldPanic(func() {
StructOf([]StructField{
StructField{Type: TypeOf("")},
StructField{Type: TypeOf("")},
{Type: TypeOf("")},
{Type: TypeOf("")},
})
})
// check that type already in binary is found
......@@ -4596,7 +4596,7 @@ func TestStructOf(t *testing.T) {
type structFieldType interface{}
checkSameType(t,
StructOf([]StructField{
StructField{
{
Name: "F",
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