Permalink
Browse files

use gofmt -s

  • Loading branch information...
1 parent 2e1b391 commit c4672edfbd4b27ade879b1d0323347ad2d9f51aa @lukechampine lukechampine committed May 3, 2016
View
@@ -37,7 +37,7 @@ pkgs = ./api ./build ./compatibility ./crypto ./encoding ./modules ./modules/con
# fmt calls go fmt on all packages.
fmt:
- go fmt $(pkgs)
+ gofmt -s -l -w $(pkgs)
# vet calls go vet on all packages.
# NOTE: go vet requires packages to be built in order to obtain type info.
@@ -42,7 +42,7 @@ func verifyKeysSiag_1_0(uc types.UnlockConditions, folder string, keyname string
}
txn := types.Transaction{
SiafundInputs: []types.SiafundInput{
- types.SiafundInput{
+ {
UnlockConditions: loadedKeys[0].UnlockConditions,
},
},
@@ -154,7 +154,7 @@ func TestUnitCiphertextUnmarshalInvalidJSON(t *testing.T) {
// Test unmarshalling invalid JSON.
invalidJSONBytes := [][]byte{
nil,
- []byte{},
+ {},
[]byte("\""),
}
for _, jsonBytes := range invalidJSONBytes {
View
@@ -106,7 +106,7 @@ func TestUnitHashUnmarshalJSON(t *testing.T) {
invalidJSONBytes := [][]byte{
// Invalid JSON.
nil,
- []byte{},
+ {},
[]byte("\""),
// JSON of wrong length.
[]byte(""),
@@ -222,7 +222,7 @@ func TestUnitValidateHeaderAndBlock(t *testing.T) {
block: mockValidBlock,
// Create a dosBlocks map where mockValidBlock is marked as a bad block.
dosBlocks: map[types.BlockID]struct{}{
- mockValidBlock.ID(): struct{}{},
+ mockValidBlock.ID(): {},
},
earliestValidTimestamp: mockValidBlock.Timestamp,
marshaler: parentBlockUnmarshaler,
@@ -355,7 +355,7 @@ func TestUnitValidateHeader(t *testing.T) {
header: mockValidBlock.Header(),
// Create a dosBlocks map where mockValidBlock is marked as a bad block.
dosBlocks: map[types.BlockID]struct{}{
- mockValidBlock.ID(): struct{}{},
+ mockValidBlock.ID(): {},
},
blockMapPairs: serializedParentBlockMap,
earliestValidTimestamp: mockValidBlock.Timestamp,
@@ -23,9 +23,9 @@ func TestRPCID(t *testing.T) {
func TestHandlerName(t *testing.T) {
cases := map[string]rpcID{
- "": rpcID{},
- "foo": rpcID{'f', 'o', 'o'},
- "foobarbaz": rpcID{'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a'},
+ "": {},
+ "foo": {'f', 'o', 'o'},
+ "foobarbaz": {'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a'},
}
for s, id := range cases {
if hid := handlerName(s); hid != id {
@@ -319,7 +319,7 @@ func TestOutboundAndInboundRPCs(t *testing.T) {
// Call the "recv" RPC on g1. We don't know g1's address as g2 sees it, so we
// get it from the first address in g2's peer list.
var addr modules.NetAddress
- for p_addr, _ := range g2.peers {
+ for p_addr := range g2.peers {
addr = p_addr
break
}
@@ -187,7 +187,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single valid storage folder.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: minimumStorageFolderSize,
},
@@ -197,7 +197,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single full storage folder.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: 0,
},
@@ -207,7 +207,7 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Single nearly full storage folder.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize - 1,
},
@@ -217,11 +217,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Two valid storage folders, first is emptier.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize + 1,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
@@ -231,11 +231,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Two valid storage folders, second is emptier.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize + 1,
},
@@ -246,11 +246,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// hold a new sector.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize - 1,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 5,
SizeRemaining: modules.SectorSize,
},
@@ -261,11 +261,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// percentage.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
@@ -276,11 +276,11 @@ func TestEmptiestStorageFolder(t *testing.T) {
// percentage.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
@@ -291,15 +291,15 @@ func TestEmptiestStorageFolder(t *testing.T) {
// volume.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: modules.SectorSize,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize * 2,
},
@@ -309,15 +309,15 @@ func TestEmptiestStorageFolder(t *testing.T) {
// Three storage folders, none have room for a sector.
{
[]*storageFolder{
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: modules.SectorSize - 1,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize,
SizeRemaining: 0,
},
- &storageFolder{
+ {
Size: minimumStorageFolderSize * 4,
SizeRemaining: 1,
},
@@ -94,9 +94,9 @@ func TestNew(t *testing.T) {
func TestContracts(t *testing.T) {
c := &Contractor{
contracts: map[types.FileContractID]Contract{
- {1}: Contract{ID: types.FileContractID{1}, IP: "foo"},
- {2}: Contract{ID: types.FileContractID{2}, IP: "bar"},
- {3}: Contract{ID: types.FileContractID{3}, IP: "baz"},
+ {1}: {ID: types.FileContractID{1}, IP: "foo"},
+ {2}: {ID: types.FileContractID{2}, IP: "bar"},
+ {3}: {ID: types.FileContractID{3}, IP: "baz"},
},
}
for _, contract := range c.Contracts() {
@@ -54,7 +54,7 @@ func TestActiveHosts(t *testing.T) {
h1 := new(hostEntry)
h1.NetAddress = "foo"
hdb.activeHosts = map[modules.NetAddress]*hostNode{
- h1.NetAddress: &hostNode{hostEntry: h1},
+ h1.NetAddress: {hostEntry: h1},
}
if hosts := hdb.ActiveHosts(); len(hosts) != 1 {
t.Errorf("wrong number of hosts: expected %v, got %v", 1, len(hosts))
@@ -66,8 +66,8 @@ func TestActiveHosts(t *testing.T) {
h2 := new(hostEntry)
h2.NetAddress = "bar"
hdb.activeHosts = map[modules.NetAddress]*hostNode{
- h1.NetAddress: &hostNode{hostEntry: h1},
- h2.NetAddress: &hostNode{hostEntry: h2},
+ h1.NetAddress: {hostEntry: h1},
+ h2.NetAddress: {hostEntry: h2},
}
if hosts := hdb.ActiveHosts(); len(hosts) != 2 {
t.Errorf("wrong number of hosts: expected %v, got %v", 2, len(hosts))
@@ -116,9 +116,9 @@ func TestAveragePrice(t *testing.T) {
func TestIsOffline(t *testing.T) {
hdb := &HostDB{
allHosts: map[modules.NetAddress]*hostEntry{
- "foo.com:1234": &hostEntry{Online: true},
- "bar.com:1234": &hostEntry{Online: false},
- "baz.com:1234": &hostEntry{Online: true},
+ "foo.com:1234": {Online: true},
+ "bar.com:1234": {Online: false},
+ "baz.com:1234": {Online: true},
},
activeHosts: map[modules.NetAddress]*hostNode{
"foo.com:1234": nil,
@@ -32,9 +32,9 @@ func TestSaveLoad(t *testing.T) {
host3.NetAddress: &host3,
}
hdb.activeHosts = map[modules.NetAddress]*hostNode{
- host1.NetAddress: &hostNode{hostEntry: &host1},
- host2.NetAddress: &hostNode{hostEntry: &host2},
- host3.NetAddress: &hostNode{hostEntry: &host3},
+ host1.NetAddress: {hostEntry: &host1},
+ host2.NetAddress: {hostEntry: &host2},
+ host3.NetAddress: {hostEntry: &host3},
}
hdb.lastChange = modules.ConsensusChangeID{1, 2, 3}
@@ -121,9 +121,9 @@ func TestRescan(t *testing.T) {
host3.NetAddress: &host3,
}
hdb.activeHosts = map[modules.NetAddress]*hostNode{
- host1.NetAddress: &hostNode{hostEntry: &host1},
- host2.NetAddress: &hostNode{hostEntry: &host2},
- host3.NetAddress: &hostNode{hostEntry: &host3},
+ host1.NetAddress: {hostEntry: &host1},
+ host2.NetAddress: {hostEntry: &host2},
+ host3.NetAddress: {hostEntry: &host3},
}
// use a bogus change ID
@@ -31,7 +31,7 @@ func TestFindHostAnnouncements(t *testing.T) {
}
b := types.Block{
Transactions: []types.Transaction{
- types.Transaction{
+ {
ArbitraryData: [][]byte{annBytes},
},
},
@@ -66,7 +66,7 @@ func relatedObjectIDs(ts []types.Transaction) []ObjectID {
}
var oids []ObjectID
- for oid, _ := range oidMap {
+ for oid := range oidMap {
oids = append(oids, oid)
}
return oids
@@ -37,10 +37,10 @@ func TestAcceptTransactionSetBroadcasts(t *testing.T) {
t.Fatal(err)
}
mockPeers := []modules.Peer{
- modules.Peer{Version: "0.0.0"},
- modules.Peer{Version: "0.4.6"},
- modules.Peer{Version: "0.4.7"},
- modules.Peer{Version: "9.9.9"},
+ {Version: "0.0.0"},
+ {Version: "0.4.6"},
+ {Version: "0.4.7"},
+ {Version: "9.9.9"},
}
mg := &mockGatewayCheckBroadcast{
Gateway: tpt.tpool.gateway,
View
@@ -76,12 +76,12 @@ func TestUnitProcessConfig(t *testing.T) {
expectedOutputs [][]string
}{
inputs: [][]string{
- []string{"9980", "9981", "9982", "cghmrtwe"},
- []string{":9980", ":9981", ":9982", "CGHMRTWE"},
+ {"9980", "9981", "9982", "cghmrtwe"},
+ {":9980", ":9981", ":9982", "CGHMRTWE"},
},
expectedOutputs: [][]string{
- []string{":9980", ":9981", ":9982", "cghmrtwe"},
- []string{":9980", ":9981", ":9982", "cghmrtwe"},
+ {":9980", ":9981", ":9982", "cghmrtwe"},
+ {":9980", ":9981", ":9982", "cghmrtwe"},
},
}
var config Config
View
@@ -64,7 +64,7 @@ func TestBlockHeader(t *testing.T) {
b.Nonce[2] = 2
b.Timestamp = 3
b.MinerPayouts = []SiacoinOutput{{Value: NewCurrency64(4)}}
- b.Transactions = []Transaction{{ArbitraryData: [][]byte{[]byte{'5'}}}}
+ b.Transactions = []Transaction{{ArbitraryData: [][]byte{{'5'}}}}
id1 := b.ID()
id2 := BlockID(crypto.HashBytes(encoding.Marshal(b.Header())))
@@ -176,7 +176,7 @@ func TestBlockCalculateSubsidy(t *testing.T) {
// Add a single no-fee transaction and check again.
txn = Transaction{
- ArbitraryData: [][]byte{[]byte{'6'}},
+ ArbitraryData: [][]byte{{'6'}},
}
b.Transactions = append(b.Transactions, txn)
if b.CalculateSubsidy(0).Cmp(expected) != 0 {
@@ -199,7 +199,7 @@ func TestBlockCalculateSubsidy(t *testing.T) {
// Add an empty transaction to the beginning.
txn = Transaction{
- ArbitraryData: [][]byte{[]byte{'7'}},
+ ArbitraryData: [][]byte{{'7'}},
}
b.Transactions = append([]Transaction{txn}, b.Transactions...)
if b.CalculateSubsidy(0).Cmp(expected) != 0 {
Oops, something went wrong.

0 comments on commit c4672ed

Please sign in to comment.