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: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Shulhan 2019-03-09 11:36:37 +07:00 committed by Ian Lance Taylor
parent 04845fe78a
commit ed7f323c8f
18 changed files with 717 additions and 757 deletions

View file

@ -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(),
},