Empty slice literal of type "[]test" used to define "tests"
299 }
300 return nil
301 }
302 tests := []test{303 // TODO test cases
304 /*
305 {
Empty slice literal of type "[]grpc.ServerOption" used to define "opts"
1060 {
1061 name: "not set when opts is nil",
1062 checkFunc: func(opt Option) error {
1063 opts := []grpc.ServerOption{}1064 got := new(server)
1065 got.grpc.opts = opts
1066 opt(got)
Empty slice literal of type "[]grpc.ServerOption" used to define "opts"
1040
1041 tests := []test{
1042 func() test {
1043 opts := []grpc.ServerOption{}1044
1045 return test{
1046 name: "set success",
Empty slice literal of type "[]struct {\n\tname\tstring\n\targs\targs\n\twant\t*DebugInfo\n}" used to define "tests"
94 type args struct {
95 v *info.Detail
96 }
97 tests := []struct { 98 name string
99 args args
100 want *DebugInfo
Empty slice literal of type "[]struct {\n\tname\t\tstring\n\targs\t\targs\n\twantDetails\t[]Detail\n}" used to define "tests"
31 type args struct {
32 objs []interface{}
33 }
34 tests := []struct { 35 name string
36 args args
37 wantDetails []Detail
Empty slice literal of type "[]struct {\n\tname\tstring\n\targs\targs\n\twant\tstring\n}" used to define "tests"
52 type args struct {
53 objs []interface{}
54 }
55 tests := []struct { 56 name string
57 args args
58 want string
Empty slice literal of type "[]struct {\n\tname\tstring\n\targs\targs\n\twant\tproto.Message\n}" used to define "tests"
73 type args struct {
74 a *types.Any
75 }
76 tests := []struct { 77 name string
78 args args
79 want proto.Message
Empty slice literal of type "[]test" used to define "tests"
1075 defaultCheckFunc := func(w want) error {
1076 return nil
1077 }
1078 tests := []test{1079 // {
1080 // name: "just call Fatal",
1081 // args: args{
Empty slice literal of type "[]test" used to define "tests"
1150 defaultCheckFunc := func(w want) error {
1151 return nil
1152 }
1153 tests := []test{1154 // {
1155 // name: "just call Fatalf",
1156 // args: args{
Empty slice literal of type "[]test" used to define "tests"
1607 defaultCheckFunc := func(w want) error {
1608 return nil
1609 }
1610 tests := []test{1611 // {
1612 // name: "just call Fatald",
1613 // args: args{
Empty slice literal of type "[]test" used to define "tests"
307 }
308 return nil
309 }
310 tests := []test{}311
312 for _, tc := range tests {
313 test := tc
Empty slice literal of type "[]backoff.Option" used to define "defaultOptions"
435 }
436 }(),
437 func() test {
438 defaultOptions := []backoff.Option{}439 opts := []backoff.Option{
440 backoff.WithRetryCount(1),
441 }
Description
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
Bad practice
package main
func foo() {
a := []int{}
}
Recommended
package main
func foo() {
var a []int
}