Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 09b4f7f

Browse files
committed
Apply gofmt to all *.go files
1 parent fcca188 commit 09b4f7f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

command/write_command.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package command
22

33
import (
4-
"github.com/goraft/raftd/db"
54
"github.com/goraft/raft"
5+
"github.com/goraft/raftd/db"
66
)
77

88
// This command writes a value to a key.
@@ -13,10 +13,10 @@ type WriteCommand struct {
1313

1414
// Creates a new write command.
1515
func NewWriteCommand(key string, value string) *WriteCommand {
16-
return &WriteCommand{
17-
Key: key,
18-
Value: value,
19-
}
16+
return &WriteCommand{
17+
Key: key,
18+
Value: value,
19+
}
2020
}
2121

2222
// The name of the command in the log.

db/db.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
package db
22

33
import (
4-
"sync"
4+
"sync"
55
)
66

77
// The key-value database.
88
type DB struct {
9-
data map[string]string
10-
mutex sync.RWMutex
9+
data map[string]string
10+
mutex sync.RWMutex
1111
}
1212

1313
// Creates a new database.
1414
func New() *DB {
15-
return &DB{
16-
data: make(map[string]string),
17-
}
15+
return &DB{
16+
data: make(map[string]string),
17+
}
1818
}
1919

2020
// Retrieves the value for a given key.
2121
func (db *DB) Get(key string) string {
22-
db.mutex.RLock()
23-
defer db.mutex.RUnlock()
24-
return db.data[key]
22+
db.mutex.RLock()
23+
defer db.mutex.RUnlock()
24+
return db.data[key]
2525
}
2626

2727
// Sets the value for a given key.
2828
func (db *DB) Put(key string, value string) {
29-
db.mutex.Lock()
30-
defer db.mutex.Unlock()
31-
db.data[key] = value
29+
db.mutex.Lock()
30+
defer db.mutex.Unlock()
31+
db.data[key] = value
3232
}

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package main
22

33
import (
44
"flag"
5+
"github.com/goraft/raft"
56
"github.com/goraft/raftd/command"
67
"github.com/goraft/raftd/server"
7-
"github.com/goraft/raft"
88
"log"
99
"math/rand"
1010
"os"
@@ -41,7 +41,7 @@ func main() {
4141
log.Print("Raft debugging enabled.")
4242
}
4343

44-
rand.Seed(time.Now().UnixNano())
44+
rand.Seed(time.Now().UnixNano())
4545

4646
// Setup commands.
4747
raft.RegisterCommand(&command.WriteCommand{})

server/server.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"github.com/goraft/raft"
78
"github.com/goraft/raftd/command"
89
"github.com/goraft/raftd/db"
9-
"github.com/goraft/raft"
1010
"github.com/gorilla/mux"
1111
"io/ioutil"
1212
"log"
@@ -36,7 +36,7 @@ func New(path string, host string, port int) *Server {
3636
host: host,
3737
port: port,
3838
path: path,
39-
db: db.New(),
39+
db: db.New(),
4040
router: mux.NewRouter(),
4141
}
4242

@@ -84,7 +84,7 @@ func (s *Server) ListenAndServe(leader string) error {
8484
log.Fatal(err)
8585
}
8686

87-
// Initialize the server by joining itself.
87+
// Initialize the server by joining itself.
8888
} else if s.raftServer.IsLogEmpty() {
8989
log.Println("Initializing new cluster")
9090

0 commit comments

Comments
 (0)