diff --git a/cmd/ipfs/ipfs.go b/cmd/ipfs/ipfs.go index d056eb3bc..349184c55 100644 --- a/cmd/ipfs/ipfs.go +++ b/cmd/ipfs/ipfs.go @@ -97,17 +97,17 @@ func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo // properties so that other code can make decisions about whether to invoke a // command or return an error to the user. var cmdDetailsMap = map[*cmds.Command]cmdDetails{ - initCmd: cmdDetails{doesNotUseConfigAsInput: true, cannotRunOnDaemon: true, doesNotUseRepo: true}, + initCmd: {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true, doesNotUseRepo: true}, // daemonCmd allows user to initialize the config. Thus, it may be called // without using the config as input - daemonCmd: cmdDetails{doesNotUseConfigAsInput: true, cannotRunOnDaemon: true}, - commandsClientCmd: cmdDetails{doesNotUseRepo: true}, - commands.CommandsDaemonCmd: cmdDetails{doesNotUseRepo: true}, - commands.DiagCmd: cmdDetails{cannotRunOnClient: true}, - commands.VersionCmd: cmdDetails{doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init - commands.UpdateCmd: cmdDetails{preemptsAutoUpdate: true, cannotRunOnDaemon: true}, - commands.UpdateCheckCmd: cmdDetails{preemptsAutoUpdate: true}, - commands.UpdateLogCmd: cmdDetails{preemptsAutoUpdate: true}, - commands.LogCmd: cmdDetails{cannotRunOnClient: true}, + daemonCmd: {doesNotUseConfigAsInput: true, cannotRunOnDaemon: true}, + commandsClientCmd: {doesNotUseRepo: true}, + commands.CommandsDaemonCmd: {doesNotUseRepo: true}, + commands.DiagCmd: {cannotRunOnClient: true}, + commands.VersionCmd: {doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init + commands.UpdateCmd: {preemptsAutoUpdate: true, cannotRunOnDaemon: true}, + commands.UpdateCheckCmd: {preemptsAutoUpdate: true}, + commands.UpdateLogCmd: {preemptsAutoUpdate: true}, + commands.LogCmd: {cannotRunOnClient: true}, } diff --git a/commands/cli/parse_test.go b/commands/cli/parse_test.go index 5a1895a3d..3685c9f48 100644 --- a/commands/cli/parse_test.go +++ b/commands/cli/parse_test.go @@ -1,11 +1,11 @@ package cli import ( - "strings" - "testing" "io" "io/ioutil" "os" + "strings" + "testing" "github.com/ipfs/go-ipfs/commands" ) @@ -122,35 +122,35 @@ func TestOptionParsing(t *testing.T) { func TestArgumentParsing(t *testing.T) { rootCmd := &commands.Command{ Subcommands: map[string]*commands.Command{ - "noarg": &commands.Command{}, - "onearg": &commands.Command{ + "noarg": {}, + "onearg": { Arguments: []commands.Argument{ commands.StringArg("a", true, false, "some arg"), }, }, - "twoargs": &commands.Command{ + "twoargs": { Arguments: []commands.Argument{ commands.StringArg("a", true, false, "some arg"), commands.StringArg("b", true, false, "another arg"), }, }, - "variadic": &commands.Command{ + "variadic": { Arguments: []commands.Argument{ commands.StringArg("a", true, true, "some arg"), }, }, - "optional": &commands.Command{ + "optional": { Arguments: []commands.Argument{ commands.StringArg("b", false, true, "another arg"), }, }, - "reversedoptional": &commands.Command{ + "reversedoptional": { Arguments: []commands.Argument{ commands.StringArg("a", false, false, "some arg"), commands.StringArg("b", true, false, "another arg"), }, }, - "stdinenabled": &commands.Command{ + "stdinenabled": { Arguments: []commands.Argument{ commands.StringArg("a", true, true, "some arg").EnableStdin(), }, @@ -221,7 +221,7 @@ func TestArgumentParsing(t *testing.T) { testFail([]string{"reversedoptional", "value1", "value2", "value3"}, "provided too many args, only takes 1") // Use a temp file to simulate stdin - fileToSimulateStdin := func(t *testing.T, content string) (*os.File) { + fileToSimulateStdin := func(t *testing.T, content string) *os.File { fstdin, err := ioutil.TempFile("", "") if err != nil { t.Fatal(err) diff --git a/core/commands/diag_test.go b/core/commands/diag_test.go index 5e6c383e2..ad3748bd7 100644 --- a/core/commands/diag_test.go +++ b/core/commands/diag_test.go @@ -8,15 +8,15 @@ import ( func TestPrintDiagnostics(t *testing.T) { output := DiagnosticOutput{ Peers: []DiagnosticPeer{ - DiagnosticPeer{ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg", + {ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg", UptimeSeconds: 14, Connections: []DiagnosticConnection{ - DiagnosticConnection{ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg", + {ID: "QmNrjRuUtBNZAigzLRdZGN1YCNUxdF2WY2HnKyEFJqoTeg", NanosecondsLatency: 1347899, }, }, }, - DiagnosticPeer{ID: "QmUaUZDp6QWJabBYSKfiNmXLAXD8HNKnWZh9Zoz6Zri9Ti", + {ID: "QmUaUZDp6QWJabBYSKfiNmXLAXD8HNKnWZh9Zoz6Zri9Ti", UptimeSeconds: 14, }, }, diff --git a/core/core_test.go b/core/core_test.go index ebde1c543..f4d2e5bfe 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -14,7 +14,7 @@ func TestInitialization(t *testing.T) { id := testIdentity good := []*config.Config{ - &config.Config{ + { Identity: id, Datastore: config.Datastore{ Type: "memory", @@ -25,7 +25,7 @@ func TestInitialization(t *testing.T) { }, }, - &config.Config{ + { Identity: id, Datastore: config.Datastore{ Type: "leveldb", @@ -39,8 +39,8 @@ func TestInitialization(t *testing.T) { } bad := []*config.Config{ - &config.Config{}, - &config.Config{Datastore: config.Datastore{Type: "memory"}}, + {}, + {Datastore: config.Datastore{Type: "memory"}}, } for i, c := range good { diff --git a/diagnostics/diag.go b/diagnostics/diag.go index 248d627da..06f204337 100644 --- a/diagnostics/diag.go +++ b/diagnostics/diag.go @@ -179,7 +179,7 @@ func decodeDiagJson(data []byte) (*DiagInfo, error) { func (d *Diagnostics) getDiagnosticFromPeers(ctx context.Context, peers map[peer.ID]int, pmes *pb.Message) (<-chan *DiagInfo, error) { respdata := make(chan *DiagInfo) wg := sync.WaitGroup{} - for p, _ := range peers { + for p := range peers { wg.Add(1) log.Debugf("Sending diagnostic request to peer: %s", p) go func(p peer.ID) { diff --git a/diagnostics/vis.go b/diagnostics/vis.go index 1ac7d8dc6..b32609d24 100644 --- a/diagnostics/vis.go +++ b/diagnostics/vis.go @@ -35,7 +35,7 @@ func GetGraphJson(dinfo []*DiagInfo) []byte { var links []*link linkexists := make([][]bool, len(nodes)) - for i, _ := range linkexists { + for i := range linkexists { linkexists[i] = make([]bool, len(nodes)) } diff --git a/exchange/bitswap/decision/engine_test.go b/exchange/bitswap/decision/engine_test.go index b69f8b1df..afe6ba9ad 100644 --- a/exchange/bitswap/decision/engine_test.go +++ b/exchange/bitswap/decision/engine_test.go @@ -128,10 +128,10 @@ func TestPartnerWantsThenCancels(t *testing.T) { type testCase [][]string testcases := []testCase{ - testCase{ + { alphabet, vowels, }, - testCase{ + { alphabet, stringsComplement(alphabet, vowels), }, } diff --git a/exchange/bitswap/message/message_test.go b/exchange/bitswap/message/message_test.go index dc10dcc70..cbeed8892 100644 --- a/exchange/bitswap/message/message_test.go +++ b/exchange/bitswap/message/message_test.go @@ -27,7 +27,7 @@ func TestNewMessageFromProto(t *testing.T) { protoMessage := new(pb.Message) protoMessage.Wantlist = new(pb.Message_Wantlist) protoMessage.Wantlist.Entries = []*pb.Message_Wantlist_Entry{ - &pb.Message_Wantlist_Entry{Block: proto.String(str)}, + {Block: proto.String(str)}, } if !wantlistContains(protoMessage.Wantlist, str) { t.Fail() diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index ebb10dac8..8f2a772a2 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -183,7 +183,7 @@ func (r *Root) Forget() { func (r *Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { log.Debug("Root ReadDirAll") listing := []fuse.Dirent{ - fuse.Dirent{ + { Name: "local", Type: fuse.DT_Link, }, diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index be8753f71..2ca5552f1 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -181,7 +181,7 @@ func (ds *dagService) GetNodes(ctx context.Context, keys []u.Key) []NodeGetter { promises := make([]NodeGetter, len(keys)) sendChans := make([]chan<- *Node, len(keys)) - for i, _ := range keys { + for i := range keys { promises[i], sendChans[i] = newNodePromise(ctx) } diff --git a/merkledag/merkledag_test.go b/merkledag/merkledag_test.go index 1c5f18a26..07525b891 100644 --- a/merkledag/merkledag_test.go +++ b/merkledag/merkledag_test.go @@ -132,7 +132,7 @@ func SubtestNodeStat(t *testing.T, n *Node) { type devZero struct{} func (_ devZero) Read(b []byte) (int, error) { - for i, _ := range b { + for i := range b { b[i] = 0 } return len(b), nil diff --git a/p2p/net/mock/mock_notif_test.go b/p2p/net/mock/mock_notif_test.go index a75175d18..1ef9fc6aa 100644 --- a/p2p/net/mock/mock_notif_test.go +++ b/p2p/net/mock/mock_notif_test.go @@ -109,7 +109,7 @@ func TestNotifications(t *testing.T) { // there's one stream per conn that we need to drain.... // unsure where these are coming from - for i, _ := range nets { + for i := range nets { n := notifiees[i] testOCStream(n, nil) testOCStream(n, nil) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index fdd334d59..29b57816f 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -215,7 +215,7 @@ func TestProvides(t *testing.T) { } } - for k, _ := range testCaseValues { + for k := range testCaseValues { log.Debugf("announcing provider for %s", k) if err := dhts[3].Provide(ctx, k); err != nil { t.Fatal(err) @@ -226,7 +226,7 @@ func TestProvides(t *testing.T) { time.Sleep(time.Millisecond * 6) n := 0 - for k, _ := range testCaseValues { + for k := range testCaseValues { n = (n + 1) % 3 log.Debugf("getting providers for %s from %d", k, n) @@ -521,7 +521,7 @@ func TestProvidesMany(t *testing.T) { } } - for k, _ := range testCaseValues { + for k := range testCaseValues { // everyone should be able to find it... for _, dht := range dhts { log.Debugf("getting providers for %s at %s", k, dht.self) diff --git a/routing/dht/providers.go b/routing/dht/providers.go index c62aee97c..e803398be 100644 --- a/routing/dht/providers.go +++ b/routing/dht/providers.go @@ -77,7 +77,7 @@ func (pm *ProviderManager) run() { case lc := <-pm.getlocal: var keys []u.Key - for k, _ := range pm.local { + for k := range pm.local { keys = append(keys, k) } lc <- keys diff --git a/routing/keyspace/xor_test.go b/routing/keyspace/xor_test.go index f90e8a5f9..cac274278 100644 --- a/routing/keyspace/xor_test.go +++ b/routing/keyspace/xor_test.go @@ -10,9 +10,9 @@ import ( func TestPrefixLen(t *testing.T) { cases := [][]byte{ - []byte{0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00}, - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - []byte{0x00, 0x58, 0xFF, 0x80, 0x00, 0x00, 0xF0}, + {0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x58, 0xFF, 0x80, 0x00, 0x00, 0xF0}, } lens := []int{24, 56, 9} @@ -28,15 +28,15 @@ func TestPrefixLen(t *testing.T) { func TestXorKeySpace(t *testing.T) { ids := [][]byte{ - []byte{0xFF, 0xFF, 0xFF, 0xFF}, - []byte{0x00, 0x00, 0x00, 0x00}, - []byte{0xFF, 0xFF, 0xFF, 0xF0}, + {0xFF, 0xFF, 0xFF, 0xFF}, + {0x00, 0x00, 0x00, 0x00}, + {0xFF, 0xFF, 0xFF, 0xF0}, } ks := [][2]Key{ - [2]Key{XORKeySpace.Key(ids[0]), XORKeySpace.Key(ids[0])}, - [2]Key{XORKeySpace.Key(ids[1]), XORKeySpace.Key(ids[1])}, - [2]Key{XORKeySpace.Key(ids[2]), XORKeySpace.Key(ids[2])}, + {XORKeySpace.Key(ids[0]), XORKeySpace.Key(ids[0])}, + {XORKeySpace.Key(ids[1]), XORKeySpace.Key(ids[1])}, + {XORKeySpace.Key(ids[2]), XORKeySpace.Key(ids[2])}, } for i, set := range ks { @@ -75,12 +75,12 @@ func TestXorKeySpace(t *testing.T) { func TestDistancesAndCenterSorting(t *testing.T) { adjs := [][]byte{ - []byte{173, 149, 19, 27, 192, 183, 153, 192, 177, 175, 71, 127, 177, 79, 207, 38, 166, 169, 247, 96, 121, 228, 139, 240, 144, 172, 183, 232, 54, 123, 253, 14}, - []byte{223, 63, 97, 152, 4, 169, 47, 219, 64, 87, 25, 45, 196, 61, 215, 72, 234, 119, 138, 220, 82, 188, 73, 140, 232, 5, 36, 192, 20, 184, 17, 25}, - []byte{73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, - []byte{73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, - []byte{73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 126}, - []byte{73, 0, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, + {173, 149, 19, 27, 192, 183, 153, 192, 177, 175, 71, 127, 177, 79, 207, 38, 166, 169, 247, 96, 121, 228, 139, 240, 144, 172, 183, 232, 54, 123, 253, 14}, + {223, 63, 97, 152, 4, 169, 47, 219, 64, 87, 25, 45, 196, 61, 215, 72, 234, 119, 138, 220, 82, 188, 73, 140, 232, 5, 36, 192, 20, 184, 17, 25}, + {73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, + {73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, + {73, 176, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 126}, + {73, 0, 221, 176, 149, 143, 22, 42, 129, 124, 213, 114, 232, 95, 189, 154, 18, 3, 122, 132, 32, 199, 53, 185, 58, 157, 117, 78, 52, 146, 157, 127}, } keys := make([]Key, len(adjs)) diff --git a/routing/supernode/client.go b/routing/supernode/client.go index 15c3a4086..14f6a4db5 100644 --- a/routing/supernode/client.go +++ b/routing/supernode/client.go @@ -86,7 +86,7 @@ func (c *Client) Provide(ctx context.Context, k u.Key) error { msg := pb.NewMessage(pb.Message_ADD_PROVIDER, string(k), 0) // FIXME how is connectedness defined for the local node pri := []pb.PeerRoutingInfo{ - pb.PeerRoutingInfo{ + { PeerInfo: peer.PeerInfo{ ID: c.local, Addrs: c.peerhost.Addrs(), diff --git a/routing/supernode/server.go b/routing/supernode/server.go index 46205d0e4..95d6a0def 100644 --- a/routing/supernode/server.go +++ b/routing/supernode/server.go @@ -73,7 +73,7 @@ func (s *Server) handleMessage( case dhtpb.Message_FIND_NODE: p := s.peerstore.PeerInfo(peer.ID(req.GetKey())) pri := []dhtpb.PeerRoutingInfo{ - dhtpb.PeerRoutingInfo{ + { PeerInfo: p, // Connectedness: TODO }, diff --git a/test/Makefile b/test/Makefile index 17c22300a..a6d99dab9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -43,16 +43,16 @@ bin/iptb: $(call find_go_files, $(IPTB_SRC)) IPFS-BUILD-OPTIONS test: test_expensive -test_expensive: +test_expensive: verify_gofmt cd sharness && make TEST_EXPENSIVE=1 cd 3nodetest && make cd dependencies && make -test_cheap: +test_cheap: verify_gofmt cd sharness && make cd 3nodetest && make -test_race: +test_race: verify_gofmt cd sharness && make GOFLAGS=-race TEST_EXPENSIVE=1 cd 3nodetest && make GOFLAGS=-race cd dependencies && make GOFLAGS=-race @@ -60,4 +60,7 @@ test_race: IPFS-BUILD-OPTIONS: FORCE @bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***' +verify_gofmt: + bin/verify-go-fmt.sh + .PHONY: all clean FORCE diff --git a/test/bin/verify-go-fmt.sh b/test/bin/verify-go-fmt.sh new file mode 100755 index 000000000..227d2d82e --- /dev/null +++ b/test/bin/verify-go-fmt.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +#TODO add go lint and go vet + +verify_gofmt() { + GOFMT="gofmt -s" + cd "$(git rev-parse --show-toplevel)" + bad_files=$($GOFMT -l . | grep -v Godeps) + cd - + if [[ -n $bad_files ]]; then + echo "You have to run '$GOFMT' on these files:" + echo "$bad_files" + false + else + true + fi +} + +verify_gofmt diff --git a/thirdparty/pq/container_test.go b/thirdparty/pq/container_test.go index d96c677cb..1c333f8b4 100644 --- a/thirdparty/pq/container_test.go +++ b/thirdparty/pq/container_test.go @@ -41,11 +41,11 @@ func TestQueuesReturnTypeIsSameAsParameterToPush(t *testing.T) { func TestCorrectnessOfPop(t *testing.T) { q := New(PriorityComparator) tasks := []TestElem{ - TestElem{Key: "a", Priority: 9}, - TestElem{Key: "b", Priority: 4}, - TestElem{Key: "c", Priority: 3}, - TestElem{Key: "d", Priority: 0}, - TestElem{Key: "e", Priority: 6}, + {Key: "a", Priority: 9}, + {Key: "b", Priority: 4}, + {Key: "c", Priority: 3}, + {Key: "d", Priority: 0}, + {Key: "e", Priority: 6}, } for _, e := range tasks { q.Push(&e) diff --git a/tour/all.go b/tour/all.go index 1930acb7a..2dd1bb50b 100644 --- a/tour/all.go +++ b/tour/all.go @@ -43,85 +43,85 @@ var ( // Topics contains a mapping of Tour Topic ID to Topic var allTopics = []Topic{ - Topic{ID: Introduction(0), Content: IntroHelloMars}, - Topic{ID: Introduction(1), Content: IntroTour}, - Topic{ID: Introduction(2), Content: IntroAboutIpfs}, + {ID: Introduction(0), Content: IntroHelloMars}, + {ID: Introduction(1), Content: IntroTour}, + {ID: Introduction(2), Content: IntroAboutIpfs}, - Topic{ID: FileBasics(1), Content: FileBasicsFilesystem}, - Topic{ID: FileBasics(2), Content: FileBasicsGetting}, - Topic{ID: FileBasics(3), Content: FileBasicsAdding}, - Topic{ID: FileBasics(4), Content: FileBasicsDirectories}, - Topic{ID: FileBasics(5), Content: FileBasicsDistributed}, - Topic{ID: FileBasics(6), Content: FileBasicsMounting}, + {ID: FileBasics(1), Content: FileBasicsFilesystem}, + {ID: FileBasics(2), Content: FileBasicsGetting}, + {ID: FileBasics(3), Content: FileBasicsAdding}, + {ID: FileBasics(4), Content: FileBasicsDirectories}, + {ID: FileBasics(5), Content: FileBasicsDistributed}, + {ID: FileBasics(6), Content: FileBasicsMounting}, - Topic{NodeBasics(0), NodeBasicsInit}, - Topic{NodeBasics(1), NodeBasicsHelp}, - Topic{NodeBasics(2), NodeBasicsUpdate}, - Topic{NodeBasics(3), NodeBasicsConfig}, + {NodeBasics(0), NodeBasicsInit}, + {NodeBasics(1), NodeBasicsHelp}, + {NodeBasics(2), NodeBasicsUpdate}, + {NodeBasics(3), NodeBasicsConfig}, - Topic{MerkleDag(0), MerkleDagIntro}, - Topic{MerkleDag(1), MerkleDagContentAddressing}, - Topic{MerkleDag(2), MerkleDagContentAddressingLinks}, - Topic{MerkleDag(3), MerkleDagRedux}, - Topic{MerkleDag(4), MerkleDagIpfsObjects}, - Topic{MerkleDag(5), MerkleDagIpfsPaths}, - Topic{MerkleDag(6), MerkleDagImmutability}, - Topic{MerkleDag(7), MerkleDagUseCaseUnixFS}, - Topic{MerkleDag(8), MerkleDagUseCaseGitObjects}, - Topic{MerkleDag(9), MerkleDagUseCaseOperationalTransforms}, + {MerkleDag(0), MerkleDagIntro}, + {MerkleDag(1), MerkleDagContentAddressing}, + {MerkleDag(2), MerkleDagContentAddressingLinks}, + {MerkleDag(3), MerkleDagRedux}, + {MerkleDag(4), MerkleDagIpfsObjects}, + {MerkleDag(5), MerkleDagIpfsPaths}, + {MerkleDag(6), MerkleDagImmutability}, + {MerkleDag(7), MerkleDagUseCaseUnixFS}, + {MerkleDag(8), MerkleDagUseCaseGitObjects}, + {MerkleDag(9), MerkleDagUseCaseOperationalTransforms}, - Topic{Network(0), Network_Intro}, - Topic{Network(1), Network_Ipfs_Peers}, - Topic{Network(2), Network_Daemon}, - Topic{Network(3), Network_Routing}, - Topic{Network(4), Network_Exchange}, - Topic{Network(5), Network_Intro}, + {Network(0), Network_Intro}, + {Network(1), Network_Ipfs_Peers}, + {Network(2), Network_Daemon}, + {Network(3), Network_Routing}, + {Network(4), Network_Exchange}, + {Network(5), Network_Intro}, // TODO daemon - {API, API Clients, Example} how old-school http + ftp // clients show it - Topic{Daemon(0), Daemon_Intro}, - Topic{Daemon(1), Daemon_Running_Commands}, - Topic{Daemon(2), Daemon_Web_UI}, + {Daemon(0), Daemon_Intro}, + {Daemon(1), Daemon_Running_Commands}, + {Daemon(2), Daemon_Web_UI}, - Topic{Routing(0), Routing_Intro}, - Topic{Routing(1), Rouing_Interface}, - Topic{Routing(2), Routing_Resolving}, - Topic{Routing(3), Routing_DHT}, - Topic{Routing(4), Routing_Other}, + {Routing(0), Routing_Intro}, + {Routing(1), Rouing_Interface}, + {Routing(2), Routing_Resolving}, + {Routing(3), Routing_DHT}, + {Routing(4), Routing_Other}, // TODO Exchange_Providing // TODO Exchange_Providers - Topic{Exchange(0), Exchange_Intro}, - Topic{Exchange(1), Exchange_Getting_Blocks}, - Topic{Exchange(2), Exchange_Strategies}, - Topic{Exchange(3), Exchange_Bitswap}, + {Exchange(0), Exchange_Intro}, + {Exchange(1), Exchange_Getting_Blocks}, + {Exchange(2), Exchange_Strategies}, + {Exchange(3), Exchange_Bitswap}, - Topic{Ipns(0), Ipns_Name_System}, - Topic{Ipns(1), Ipns_Mutability}, - Topic{Ipns(2), Ipns_PKI_Review}, - Topic{Ipns(3), Ipns_Publishing}, - Topic{Ipns(4), Ipns_Resolving}, - Topic{Ipns(5), Ipns_Consistency}, - Topic{Ipns(6), Ipns_Records_Etc}, + {Ipns(0), Ipns_Name_System}, + {Ipns(1), Ipns_Mutability}, + {Ipns(2), Ipns_PKI_Review}, + {Ipns(3), Ipns_Publishing}, + {Ipns(4), Ipns_Resolving}, + {Ipns(5), Ipns_Consistency}, + {Ipns(6), Ipns_Records_Etc}, - Topic{Mounting(0), Mounting_General}, - Topic{Mounting(1), Mounting_Ipfs}, - Topic{Mounting(2), Mounting_Ipns}, + {Mounting(0), Mounting_General}, + {Mounting(1), Mounting_Ipfs}, + {Mounting(2), Mounting_Ipns}, - Topic{Plumbing(0), Plumbing_Intro}, - Topic{Plumbing(1), Plumbing_Ipfs_Block}, - Topic{Plumbing(2), Plumbing_Ipfs_Object}, - Topic{Plumbing(3), Plumbing_Ipfs_Refs}, - Topic{Plumbing(4), Plumbing_Ipfs_Ping}, - Topic{Plumbing(5), Plumbing_Ipfs_Id}, + {Plumbing(0), Plumbing_Intro}, + {Plumbing(1), Plumbing_Ipfs_Block}, + {Plumbing(2), Plumbing_Ipfs_Object}, + {Plumbing(3), Plumbing_Ipfs_Refs}, + {Plumbing(4), Plumbing_Ipfs_Ping}, + {Plumbing(5), Plumbing_Ipfs_Id}, - Topic{Formats(0), Formats_MerkleDag}, - Topic{Formats(1), Formats_Multihash}, - Topic{Formats(2), Formats_Multiaddr}, - Topic{Formats(3), Formats_Multicodec}, - Topic{Formats(4), Formats_Multicodec}, - Topic{Formats(5), Formats_Multikey}, - Topic{Formats(6), Formats_Protocol_Specific}, + {Formats(0), Formats_MerkleDag}, + {Formats(1), Formats_Multihash}, + {Formats(2), Formats_Multiaddr}, + {Formats(3), Formats_Multicodec}, + {Formats(4), Formats_Multicodec}, + {Formats(5), Formats_Multikey}, + {Formats(6), Formats_Protocol_Specific}, } // Introduction diff --git a/unixfs/mod/dagmodifier.go b/unixfs/mod/dagmodifier.go index 6cca0c007..e0e09f711 100644 --- a/unixfs/mod/dagmodifier.go +++ b/unixfs/mod/dagmodifier.go @@ -95,7 +95,7 @@ func (dm *DagModifier) WriteAt(b []byte, offset int64) (int, error) { type zeroReader struct{} func (zr zeroReader) Read(b []byte) (int, error) { - for i, _ := range b { + for i := range b { b[i] = 0 } return len(b), nil diff --git a/util/key_set.go b/util/key_set.go index 28d87eee5..0cf6dbda9 100644 --- a/util/key_set.go +++ b/util/key_set.go @@ -39,7 +39,7 @@ func (wl *ks) Keys() []Key { wl.lock.RLock() defer wl.lock.RUnlock() keys := make([]Key, 0) - for k, _ := range wl.data { + for k := range wl.data { keys = append(keys, k) } return keys diff --git a/util/log.go b/util/log.go index 805b716ad..541991755 100644 --- a/util/log.go +++ b/util/log.go @@ -72,7 +72,7 @@ func SetDebugLogging() { // SetAllLoggers changes the logging.Level of all loggers to lvl func SetAllLoggers(lvl logging.Level) { logging.SetLevel(lvl, "") - for n, _ := range loggers { + for n := range loggers { logging.SetLevel(lvl, n) } } diff --git a/util/util_test.go b/util/util_test.go index 458637f66..dc73f1a03 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -29,20 +29,20 @@ func TestKey(t *testing.T) { func TestXOR(t *testing.T) { cases := [][3][]byte{ - [3][]byte{ - []byte{0xFF, 0xFF, 0xFF}, - []byte{0xFF, 0xFF, 0xFF}, - []byte{0x00, 0x00, 0x00}, + { + {0xFF, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xFF}, + {0x00, 0x00, 0x00}, }, - [3][]byte{ - []byte{0x00, 0xFF, 0x00}, - []byte{0xFF, 0xFF, 0xFF}, - []byte{0xFF, 0x00, 0xFF}, + { + {0x00, 0xFF, 0x00}, + {0xFF, 0xFF, 0xFF}, + {0xFF, 0x00, 0xFF}, }, - [3][]byte{ - []byte{0x55, 0x55, 0x55}, - []byte{0x55, 0xFF, 0xAA}, - []byte{0x00, 0xAA, 0xFF}, + { + {0x55, 0x55, 0x55}, + {0x55, 0xFF, 0xAA}, + {0x00, 0xAA, 0xFF}, }, }