Skip to content

Commit 3342827

Browse files
Gofmt static analysis linter
The following changes introduce the gofmt linter. Most of the code changes are the consequence of getting the linter to pass. Using the `make simplify` command does this automatically for you.
1 parent 0879177 commit 3342827

File tree

181 files changed

+1078
-1079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+1078
-1079
lines changed

api/application/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (s *applicationSuite) TestDeploy(c *gc.C) {
9696
c.Assert(app.Constraints, gc.DeepEquals, constraints.MustParse("mem=4G"))
9797
c.Assert(app.Placement, gc.DeepEquals, []*instance.Placement{{"scope", "directive"}})
9898
c.Assert(app.EndpointBindings, gc.DeepEquals, map[string]string{"foo": "bar"})
99-
c.Assert(app.Storage, gc.DeepEquals, map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}})
99+
c.Assert(app.Storage, gc.DeepEquals, map[string]storage.Constraints{"data": {Pool: "pool"}})
100100
c.Assert(app.AttachStorage, gc.DeepEquals, []string{"storage-data-0"})
101101
c.Assert(app.Resources, gc.DeepEquals, map[string]string{"foo": "bar"})
102102

@@ -119,7 +119,7 @@ func (s *applicationSuite) TestDeploy(c *gc.C) {
119119
Config: map[string]string{"foo": "bar"},
120120
Cons: constraints.MustParse("mem=4G"),
121121
Placement: []*instance.Placement{{"scope", "directive"}},
122-
Storage: map[string]storage.Constraints{"data": storage.Constraints{Pool: "pool"}},
122+
Storage: map[string]storage.Constraints{"data": {Pool: "pool"}},
123123
AttachStorage: []string{"data/0"},
124124
Resources: map[string]string{"foo": "bar"},
125125
EndpointBindings: map[string]string{"foo": "bar"},

api/common/network_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ func (s *NetworkSuite) TestGetObservedNetworkConfigLoopbackInfrerred(c *gc.C) {
965965
func (s *NetworkSuite) TestGetObservedNetworkConfigVLANInfrerred(c *gc.C) {
966966
s.stubConfigSource.interfaces = exampleObservedInterfaces[6:7] // only eth0.100
967967
s.stubConfigSource.interfaceAddrs = map[string][]net.Addr{
968-
"eth0.100": []net.Addr{
968+
"eth0.100": {
969969
fakeAddr("fe80::5054:ff:fedd:eef0:100/64"),
970970
fakeAddr("10.100.19.123/24"),
971971
},
@@ -1108,7 +1108,7 @@ func (s *NetworkSuite) TestGetObservedNetworkConfigAddressNotInCIDRFormat(c *gc.
11081108
// Simulate running on Windows, where net.InterfaceAddrs() returns
11091109
// non-CIDR-formatted addresses.
11101110
s.stubConfigSource.interfaceAddrs = map[string][]net.Addr{
1111-
"eth0": []net.Addr{fakeAddr("10.20.19.42")},
1111+
"eth0": {fakeAddr("10.20.19.42")},
11121112
}
11131113

11141114
observedConfig, err := common.GetObservedNetworkConfig(s.stubConfigSource)
@@ -1131,7 +1131,7 @@ func (s *NetworkSuite) TestGetObservedNetworkConfigEmptyAddressValue(c *gc.C) {
11311131
s.stubConfigSource.interfaces = exampleObservedInterfaces[1:2] // only eth0
11321132
s.stubConfigSource.makeSysClassNetInterfacePath(c, "eth0", "")
11331133
s.stubConfigSource.interfaceAddrs = map[string][]net.Addr{
1134-
"eth0": []net.Addr{fakeAddr("")},
1134+
"eth0": {fakeAddr("")},
11351135
}
11361136

11371137
observedConfig, err := common.GetObservedNetworkConfig(s.stubConfigSource)
@@ -1153,7 +1153,7 @@ func (s *NetworkSuite) TestGetObservedNetworkConfigInvalidAddressValue(c *gc.C)
11531153
s.stubConfigSource.interfaces = exampleObservedInterfaces[1:2] // only eth0
11541154
s.stubConfigSource.makeSysClassNetInterfacePath(c, "eth0", "")
11551155
s.stubConfigSource.interfaceAddrs = map[string][]net.Addr{
1156-
"eth0": []net.Addr{fakeAddr("invalid")},
1156+
"eth0": {fakeAddr("invalid")},
11571157
}
11581158

11591159
observedConfig, err := common.GetObservedNetworkConfig(s.stubConfigSource)

api/controller/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (s *Suite) TestModelStatus(c *gc.C) {
307307

308308
out := result.(*params.ModelStatusResults)
309309
out.Results = []params.ModelStatus{
310-
params.ModelStatus{
310+
{
311311
ModelTag: coretesting.ModelTag.String(),
312312
OwnerTag: "user-glenda",
313313
ApplicationCount: 3,
@@ -319,7 +319,7 @@ func (s *Suite) TestModelStatus(c *gc.C) {
319319
Status: "pending",
320320
}},
321321
},
322-
params.ModelStatus{Error: common.ServerError(errors.New("model error"))},
322+
{Error: common.ServerError(errors.New("model error"))},
323323
}
324324
return nil
325325
},

api/firewaller/machine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (s *machineSuite) TestOpenedPorts(c *gc.C) {
131131
ports, err = s.apiMachine.OpenedPorts(names.SubnetTag{})
132132
c.Assert(err, jc.ErrorIsNil)
133133
c.Assert(ports, jc.DeepEquals, map[network.PortRange]names.UnitTag{
134-
network.PortRange{FromPort: 1234, ToPort: 1234, Protocol: "tcp"}: unitTag,
134+
{FromPort: 1234, ToPort: 1234, Protocol: "tcp"}: unitTag,
135135
})
136136
}
137137

api/imagemetadatamanager/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (s *imagemetadataSuite) TestList(c *gc.C) {
5757

5858
if results, k := result.(*params.ListCloudImageMetadataResult); k {
5959
instances := []params.CloudImageMetadata{
60-
params.CloudImageMetadata{
60+
{
6161
ImageId: imageId,
6262
Stream: args.Stream,
6363
Region: args.Region,
@@ -85,7 +85,7 @@ func (s *imagemetadataSuite) TestList(c *gc.C) {
8585

8686
c.Assert(called, jc.IsTrue)
8787
expected := []params.CloudImageMetadata{
88-
params.CloudImageMetadata{
88+
{
8989
ImageId: imageId,
9090
Stream: stream,
9191
Region: region,

api/migrationmaster/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (s *ClientSuite) TestExport(c *gc.C) {
261261
Username: "xena",
262262
},
263263
UnitRevisions: map[string]params.SerializedModelResourceRevision{
264-
"fooapp/0": params.SerializedModelResourceRevision{
264+
"fooapp/0": {
265265
Revision: 1,
266266
Type: "file",
267267
Path: "blink.tar.gz",
@@ -323,7 +323,7 @@ func (s *ClientSuite) TestExport(c *gc.C) {
323323
Username: "xena",
324324
},
325325
UnitRevisions: map[string]resource.Resource{
326-
"fooapp/0": resource.Resource{
326+
"fooapp/0": {
327327
Resource: charmresource.Resource{
328328
Meta: charmresource.Meta{
329329
Name: "bin",

api/modelmanager/modelmanager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func (s *modelmanagerSuite) TestModelStatus(c *gc.C) {
352352

353353
out := result.(*params.ModelStatusResults)
354354
out.Results = []params.ModelStatus{
355-
params.ModelStatus{
355+
{
356356
ModelTag: coretesting.ModelTag.String(),
357357
OwnerTag: "user-glenda",
358358
ApplicationCount: 3,
@@ -364,7 +364,7 @@ func (s *modelmanagerSuite) TestModelStatus(c *gc.C) {
364364
Status: "pending",
365365
}},
366366
},
367-
params.ModelStatus{Error: common.ServerError(errors.New("model error"))},
367+
{Error: common.ServerError(errors.New("model error"))},
368368
}
369369
return nil
370370
},

api/provisioner/provisioner_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func (s *provisionerSuite) TestDistributionGroupByMachineId(c *gc.C) {
437437
c.Assert(err, jc.ErrorIsNil)
438438
c.Assert(len(results), gc.Equals, 1)
439439
c.Assert(results, gc.DeepEquals, []provisioner.DistributionGroupResult{
440-
provisioner.DistributionGroupResult{MachineIds: nil, Err: nil},
440+
{MachineIds: nil, Err: nil},
441441
})
442442

443443
machine1, err := s.State.AddMachine("quantal", state.JobHostUnits)
@@ -455,8 +455,8 @@ func (s *provisionerSuite) TestDistributionGroupByMachineId(c *gc.C) {
455455
c.Assert(err, jc.ErrorIsNil)
456456
c.Assert(len(results), gc.Equals, 2)
457457
c.Assert(results, gc.DeepEquals, []provisioner.DistributionGroupResult{
458-
provisioner.DistributionGroupResult{MachineIds: nil, Err: nil},
459-
provisioner.DistributionGroupResult{MachineIds: nil, Err: nil},
458+
{MachineIds: nil, Err: nil},
459+
{MachineIds: nil, Err: nil},
460460
})
461461

462462
machine2, err := s.State.AddMachine("quantal", state.JobHostUnits)
@@ -474,9 +474,9 @@ func (s *provisionerSuite) TestDistributionGroupByMachineId(c *gc.C) {
474474
c.Assert(err, jc.ErrorIsNil)
475475
c.Assert(len(results), gc.Equals, 3)
476476
c.Assert(results, gc.DeepEquals, []provisioner.DistributionGroupResult{
477-
provisioner.DistributionGroupResult{MachineIds: nil, Err: nil},
478-
provisioner.DistributionGroupResult{MachineIds: []string{"2"}, Err: nil},
479-
provisioner.DistributionGroupResult{MachineIds: []string{"1"}, Err: nil},
477+
{MachineIds: nil, Err: nil},
478+
{MachineIds: []string{"2"}, Err: nil},
479+
{MachineIds: []string{"1"}, Err: nil},
480480
})
481481
}
482482

@@ -527,8 +527,8 @@ func (s *provisionerSuite) TestProvisioningInfo(c *gc.C) {
527527
c.Assert(provisioningInfo.Placement, gc.Equals, template.Placement)
528528
c.Assert(provisioningInfo.Constraints, jc.DeepEquals, template.Constraints)
529529
c.Assert(provisioningInfo.SubnetsToZones, jc.DeepEquals, map[string][]string{
530-
"subnet-2": []string{"zone2"},
531-
"subnet-3": []string{"zone3"},
530+
"subnet-2": {"zone2"},
531+
"subnet-3": {"zone3"},
532532
})
533533
}
534534

api/proxyupdater/proxyupdater_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (s *ProxyUpdaterSuite) TestNilTagFails(c *gc.C) {
5656

5757
func (s *ProxyUpdaterSuite) TestWatchForProxyConfigAndAPIHostPortChanges(c *gc.C) {
5858
res := params.NotifyWatchResults{
59-
Results: []params.NotifyWatchResult{params.NotifyWatchResult{
59+
Results: []params.NotifyWatchResult{{
6060
NotifyWatcherId: "4242",
6161
}},
6262
}

api/spaces/spaces_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func makeArgs(name string, subnets []string) (string, []string, apitesting.APICa
5656

5757
expectArgs := params.CreateSpacesParams{
5858
Spaces: []params.CreateSpaceParams{
59-
params.CreateSpaceParams{
59+
{
6060
SpaceTag: spaceTag,
6161
SubnetTags: subnetTags,
6262
Public: true,

api/storage/client_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func (s *storageMockSuite) TestStorageDetails(c *gc.C) {
5050

5151
if results, k := result.(*params.StorageDetailsResults); k {
5252
instances := []params.StorageDetailsResult{
53-
params.StorageDetailsResult{
53+
{
5454
Result: &params.StorageDetails{StorageTag: oneTag.String()},
5555
},
56-
params.StorageDetailsResult{
56+
{
5757
Result: &params.StorageDetails{
5858
StorageTag: twoTag.String(),
5959
Status: params.EntityStatus{
@@ -62,7 +62,7 @@ func (s *storageMockSuite) TestStorageDetails(c *gc.C) {
6262
Persistent: true,
6363
},
6464
},
65-
params.StorageDetailsResult{
65+
{
6666
Error: common.ServerError(errors.New(msg)),
6767
},
6868
}
@@ -172,9 +172,9 @@ func (s *storageMockSuite) TestListStorageDetailsFacadeCallError(c *gc.C) {
172172

173173
func (s *storageMockSuite) TestListPools(c *gc.C) {
174174
expected := []params.StoragePool{
175-
params.StoragePool{Name: "name0", Provider: "type0"},
176-
params.StoragePool{Name: "name1", Provider: "type1"},
177-
params.StoragePool{Name: "name2", Provider: "type2"},
175+
{Name: "name0", Provider: "type0"},
176+
{Name: "name1", Provider: "type1"},
177+
{Name: "name2", Provider: "type2"},
178178
}
179179
want := len(expected)
180180

@@ -408,7 +408,7 @@ func (s *storageMockSuite) TestListFilesystems(c *gc.C) {
408408
Status: "attached",
409409
},
410410
MachineAttachments: map[string]params.FilesystemAttachmentDetails{
411-
"0": params.FilesystemAttachmentDetails{
411+
"0": {
412412
FilesystemAttachmentInfo: params.FilesystemAttachmentInfo{
413413
MountPoint: "/mnt/kinabalu",
414414
ReadOnly: false,
@@ -510,9 +510,9 @@ func (s *storageMockSuite) TestAddToUnit(c *gc.C) {
510510

511511
errOut := "error"
512512
unitStorages := []params.StorageAddParams{
513-
params.StorageAddParams{UnitTag: "u-a", StorageName: "one", Constraints: cons},
514-
params.StorageAddParams{UnitTag: "u-b", StorageName: errOut, Constraints: cons},
515-
params.StorageAddParams{UnitTag: "u-b", StorageName: "nil-constraints"},
513+
{UnitTag: "u-a", StorageName: "one", Constraints: cons},
514+
{UnitTag: "u-b", StorageName: errOut, Constraints: cons},
515+
{UnitTag: "u-b", StorageName: "nil-constraints"},
516516
}
517517

518518
storageN := 3
@@ -567,7 +567,7 @@ func (s *storageMockSuite) TestAddToUnit(c *gc.C) {
567567

568568
func (s *storageMockSuite) TestAddToUnitFacadeCallError(c *gc.C) {
569569
unitStorages := []params.StorageAddParams{
570-
params.StorageAddParams{UnitTag: "u-a", StorageName: "one"},
570+
{UnitTag: "u-a", StorageName: "one"},
571571
}
572572

573573
msg := "facade failure"

api/uniter/goal-state_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *goalStateSuite) TestGoalStateTwoRelatedUnits(c *gc.C) {
6464
"mysql/0": paramsBaseGoalStateStatus,
6565
},
6666
Relations: map[string]params.UnitsGoalState{
67-
"db": params.UnitsGoalState{
67+
"db": {
6868
"wordpress/0": paramsBaseGoalStateStatus,
6969
},
7070
},
@@ -77,7 +77,7 @@ func (s *goalStateSuite) TestGoalStateTwoRelatedUnits(c *gc.C) {
7777
"mysql/0": apiBaseGoalStateStatus,
7878
},
7979
Relations: map[string]application.UnitsGoalState{
80-
"db": application.UnitsGoalState{
80+
"db": {
8181
"wordpress/0": apiBaseGoalStateStatus,
8282
},
8383
},

api/uniter/state_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func (s *stateSuite) TestAllMachinePorts(c *gc.C) {
6565
portsMap, err := s.uniter.AllMachinePorts(s.wordpressMachine.Tag().(names.MachineTag))
6666
c.Assert(err, jc.ErrorIsNil)
6767
c.Assert(portsMap, jc.DeepEquals, map[network.PortRange]params.RelationUnit{
68-
network.PortRange{100, 200, "tcp"}: {Unit: s.wordpressUnit.Tag().String()},
69-
network.PortRange{10, 20, "udp"}: {Unit: s.wordpressUnit.Tag().String()},
70-
network.PortRange{201, 250, "tcp"}: {Unit: wordpressUnit1.Tag().String()},
71-
network.PortRange{1, 8, "udp"}: {Unit: wordpressUnit1.Tag().String()},
68+
{100, 200, "tcp"}: {Unit: s.wordpressUnit.Tag().String()},
69+
{10, 20, "udp"}: {Unit: s.wordpressUnit.Tag().String()},
70+
{201, 250, "tcp"}: {Unit: wordpressUnit1.Tag().String()},
71+
{1, 8, "udp"}: {Unit: wordpressUnit1.Tag().String()},
7272
})
7373
}

api/uniter/unitstorage_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func (s *unitStorageSuite) createTestUnit(c *gc.C, t string, apiCaller basetesti
3232
func (s *unitStorageSuite) TestAddUnitStorage(c *gc.C) {
3333
count := uint64(1)
3434
args := map[string][]params.StorageConstraints{
35-
"data": []params.StorageConstraints{
36-
params.StorageConstraints{Count: &count}},
35+
"data": {
36+
{Count: &count}},
3737
}
3838

3939
expected := params.StoragesAddParams{
@@ -64,7 +64,7 @@ func (s *unitStorageSuite) TestAddUnitStorage(c *gc.C) {
6464
func (s *unitStorageSuite) TestAddUnitStorageError(c *gc.C) {
6565
count := uint64(1)
6666
args := map[string][]params.StorageConstraints{
67-
"data": []params.StorageConstraints{params.StorageConstraints{Count: &count}},
67+
"data": {{Count: &count}},
6868
}
6969

7070
expected := params.StoragesAddParams{

apiserver/common/modelstatus_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (s *modelStatusSuite) TestModelStatus(c *gc.C) {
185185
Mem: &mem,
186186
}
187187
c.Assert(results.Results, jc.DeepEquals, []params.ModelStatus{
188-
params.ModelStatus{
188+
{
189189
ModelTag: controllerModelTag,
190190
HostedMachineCount: 1,
191191
ApplicationCount: 1,
@@ -204,7 +204,7 @@ func (s *modelStatusSuite) TestModelStatus(c *gc.C) {
204204
Id: "1/1", Status: "pending", Detachable: false,
205205
}},
206206
},
207-
params.ModelStatus{
207+
{
208208
ModelTag: hostedModelTag,
209209
HostedMachineCount: 2,
210210
ApplicationCount: 1,
@@ -248,14 +248,14 @@ func (s *modelStatusSuite) TestModelStatusCAAS(c *gc.C) {
248248
c.Assert(err, jc.ErrorIsNil)
249249

250250
c.Assert(results.Results, jc.DeepEquals, []params.ModelStatus{
251-
params.ModelStatus{
251+
{
252252
ModelTag: controllerModelTag,
253253
HostedMachineCount: 0,
254254
ApplicationCount: 0,
255255
OwnerTag: s.Owner.String(),
256256
Life: params.Alive,
257257
},
258-
params.ModelStatus{
258+
{
259259
ModelTag: hostedModelTag,
260260
HostedMachineCount: 0,
261261
ApplicationCount: 1,
@@ -274,9 +274,9 @@ func (s *modelStatusSuite) TestModelStatusRunsForAllModels(c *gc.C) {
274274
}
275275
expected := params.ModelStatusResults{
276276
Results: []params.ModelStatus{
277-
params.ModelStatus{
277+
{
278278
Error: common.ServerError(errors.New(`"fail.me" is not a valid tag`))},
279-
params.ModelStatus{
279+
{
280280
ModelTag: s.IAASModel.ModelTag().String(),
281281
Life: params.Life(s.IAASModel.Life().String()),
282282
OwnerTag: s.IAASModel.Owner().String(),

apiserver/common/networkingcommon/subnets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (cache *addSubnetsCache) cacheSubnets(ctx context.ProviderCallContext) erro
208208
cache.providerIdsByCIDR = make(map[string]set.Strings)
209209
cache.subnetsByProviderId = make(map[string]*network.SubnetInfo)
210210

211-
for i, _ := range subnetInfo {
211+
for i := range subnetInfo {
212212
subnet := subnetInfo[i]
213213
cidr := subnet.CIDR
214214
providerId := string(subnet.ProviderId)

apiserver/facades/agent/machineactions/machineactions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,4 @@ func (mock *mockBackend) ConvertActions(ar state.ActionReceiver, fn common.GetAc
156156
return actions, nil
157157
}
158158

159-
var actions = []params.ActionResult{params.ActionResult{Action: &params.Action{Name: "foo"}}}
159+
var actions = []params.ActionResult{{Action: &params.Action{Name: "foo"}}}

apiserver/facades/agent/metricsender/metricsender.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func SendMetrics(st ModelBackend, sender MetricSender, clock clock.Clock, batchS
158158
}
159159

160160
func setHeldBatchUnitMeterStatus(st ModelBackend, units map[string]bool) {
161-
for unitID, _ := range units {
161+
for unitID := range units {
162162
unit, err := st.Unit(unitID)
163163
if err != nil {
164164
logger.Warningf("failed to get unit for setting held batch meter status: %v", err)

0 commit comments

Comments
 (0)