diff --git a/weed/command/backup.go b/weed/command/backup.go index b9973c6a9..207df770b 100644 --- a/weed/command/backup.go +++ b/weed/command/backup.go @@ -72,7 +72,7 @@ func runBackup(cmd *Command, args []string) bool { vid := needle.VolumeId(*s.volumeId) // find volume location, replication, ttl info - lookup, err := operation.Lookup(func()string{return *s.master}, vid.String()) + lookup, err := operation.Lookup(func() string { return *s.master }, vid.String()) if err != nil { fmt.Printf("Error looking up volume %d: %v\n", vid, err) return true diff --git a/weed/command/download.go b/weed/command/download.go index 5da1f57d9..7bbff9448 100644 --- a/weed/command/download.go +++ b/weed/command/download.go @@ -44,7 +44,7 @@ var cmdDownload = &Command{ func runDownload(cmd *Command, args []string) bool { for _, fid := range args { - if e := downloadToFile(func()string{return *d.server}, fid, util.ResolvePath(*d.dir)); e != nil { + if e := downloadToFile(func() string { return *d.server }, fid, util.ResolvePath(*d.dir)); e != nil { fmt.Println("Download Error: ", fid, e) } } diff --git a/weed/command/upload.go b/weed/command/upload.go index effcf8836..149d71241 100644 --- a/weed/command/upload.go +++ b/weed/command/upload.go @@ -96,7 +96,7 @@ func runUpload(cmd *Command, args []string) bool { if e != nil { return e } - results, e := operation.SubmitFiles(func()string {return *upload.master}, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl) + results, e := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl) bytes, _ := json.Marshal(results) fmt.Println(string(bytes)) if e != nil { @@ -113,7 +113,7 @@ func runUpload(cmd *Command, args []string) bool { if e != nil { fmt.Println(e.Error()) } - results, _ := operation.SubmitFiles(func()string {return *upload.master}, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl) + results, _ := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl) bytes, _ := json.Marshal(results) fmt.Println(string(bytes)) } diff --git a/weed/filer/mysql/mysql_store.go b/weed/filer/mysql/mysql_store.go index 022a8d72d..501ab1d39 100644 --- a/weed/filer/mysql/mysql_store.go +++ b/weed/filer/mysql/mysql_store.go @@ -47,7 +47,7 @@ func (store *MysqlStore) initialize(user, password, hostname string, port int, d store.SupportBucketTable = false store.SqlGenerator = &SqlGenMysql{ CreateTableSqlTemplate: "", - DropTableSqlTemplate: "drop table `%s`", + DropTableSqlTemplate: "drop table `%s`", } sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, user, password, hostname, port, database) diff --git a/weed/filer/postgres/postgres_sql_gen.go b/weed/filer/postgres/postgres_sql_gen.go index 480f433ef..e13070c3d 100644 --- a/weed/filer/postgres/postgres_sql_gen.go +++ b/weed/filer/postgres/postgres_sql_gen.go @@ -1,10 +1,10 @@ package postgres import ( - `fmt` + "fmt" - `github.com/chrislusf/seaweedfs/weed/filer/abstract_sql` - _ `github.com/lib/pq` + "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql" + _ "github.com/lib/pq" ) type SqlGenPostgres struct { diff --git a/weed/filer/postgres2/postgres2_store.go b/weed/filer/postgres2/postgres2_store.go index 4b5fbc8cf..92893bf7a 100644 --- a/weed/filer/postgres2/postgres2_store.go +++ b/weed/filer/postgres2/postgres2_store.go @@ -50,7 +50,7 @@ func (store *PostgresStore2) initialize(createTable, user, password, hostname st store.SupportBucketTable = true store.SqlGenerator = &postgres.SqlGenPostgres{ CreateTableSqlTemplate: createTable, - DropTableSqlTemplate: `drop table "%s"`, + DropTableSqlTemplate: `drop table "%s"`, } sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, hostname, port, sslmode) diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index b24514cda..0d5cfd29c 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -100,7 +100,7 @@ func retriedUploadData(uploadUrl string, filename string, cipher bool, data []by } else { glog.Warningf("uploading to %s: %v", uploadUrl, err) } - time.Sleep(time.Millisecond * time.Duration(237 * (i+1))) + time.Sleep(time.Millisecond * time.Duration(237*(i+1))) } return } diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.go index 4a77d24b5..f24d4e924 100644 --- a/weed/server/master_server_handlers_admin.go +++ b/weed/server/master_server_handlers_admin.go @@ -125,13 +125,13 @@ func (ms *MasterServer) selfUrl(r *http.Request) string { } func (ms *MasterServer) submitFromMasterServerHandler(w http.ResponseWriter, r *http.Request) { if ms.Topo.IsLeader() { - submitForClientHandler(w, r, func()string{return ms.selfUrl(r)}, ms.grpcDialOption) + submitForClientHandler(w, r, func() string { return ms.selfUrl(r) }, ms.grpcDialOption) } else { masterUrl, err := ms.Topo.Leader() if err != nil { writeJsonError(w, r, http.StatusInternalServerError, err) } else { - submitForClientHandler(w, r, func()string{return masterUrl}, ms.grpcDialOption) + submitForClientHandler(w, r, func() string { return masterUrl }, ms.grpcDialOption) } } } diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 323667d2e..f8875169f 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -219,14 +219,14 @@ func (vs *VolumeServer) doHeartbeat(masterNode, masterGrpcAddress string, grpcDi case <-vs.stopChan: var volumeMessages []*master_pb.VolumeInformationMessage emptyBeat := &master_pb.Heartbeat{ - Ip: vs.store.Ip, - Port: uint32(vs.store.Port), - PublicUrl: vs.store.PublicUrl, - MaxFileKey: uint64(0), - DataCenter: vs.store.GetDataCenter(), - Rack: vs.store.GetRack(), - Volumes: volumeMessages, - HasNoVolumes: len(volumeMessages) == 0, + Ip: vs.store.Ip, + Port: uint32(vs.store.Port), + PublicUrl: vs.store.PublicUrl, + MaxFileKey: uint64(0), + DataCenter: vs.store.GetDataCenter(), + Rack: vs.store.GetRack(), + Volumes: volumeMessages, + HasNoVolumes: len(volumeMessages) == 0, } glog.V(1).Infof("volume server %s:%d stops and deletes all volumes", vs.store.Ip, vs.store.Port) if err = stream.Send(emptyBeat); err != nil { diff --git a/weed/shell/command_ec_test.go b/weed/shell/command_ec_test.go index 14235d565..a1226adbb 100644 --- a/weed/shell/command_ec_test.go +++ b/weed/shell/command_ec_test.go @@ -126,7 +126,7 @@ func TestCommandEcBalanceVolumeEvenButRackUneven(t *testing.T) { func newEcNode(dc string, rack string, dataNodeId string, freeEcSlot int) *EcNode { return &EcNode{ info: &master_pb.DataNodeInfo{ - Id: dataNodeId, + Id: dataNodeId, DiskInfos: make(map[string]*master_pb.DiskInfo), }, dc: dc, diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go index 677f38856..f9dcf3b5f 100644 --- a/weed/shell/command_volume_fsck.go +++ b/weed/shell/command_volume_fsck.go @@ -285,7 +285,7 @@ func (c *commandVolumeFsck) collectVolumeIds(verbose bool, writer io.Writer) (vo } eachDataNode(resp.TopologyInfo, func(dc string, rack RackId, t *master_pb.DataNodeInfo) { - for _, diskInfo := range t.DiskInfos{ + for _, diskInfo := range t.DiskInfos { for _, vi := range diskInfo.VolumeInfos { volumeIdToServer[vi.Id] = VInfo{ server: t.Id, diff --git a/weed/storage/store.go b/weed/storage/store.go index 92f1db2bc..47829666a 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -285,15 +285,15 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat { } return &master_pb.Heartbeat{ - Ip: s.Ip, - Port: uint32(s.Port), - PublicUrl: s.PublicUrl, - MaxVolumeCounts: maxVolumeCounts, - MaxFileKey: NeedleIdToUint64(maxFileKey), - DataCenter: s.dataCenter, - Rack: s.rack, - Volumes: volumeMessages, - HasNoVolumes: len(volumeMessages) == 0, + Ip: s.Ip, + Port: uint32(s.Port), + PublicUrl: s.PublicUrl, + MaxVolumeCounts: maxVolumeCounts, + MaxFileKey: NeedleIdToUint64(maxFileKey), + DataCenter: s.dataCenter, + Rack: s.rack, + Volumes: volumeMessages, + HasNoVolumes: len(volumeMessages) == 0, } } diff --git a/weed/storage/types/volume_disk_type.go b/weed/storage/types/volume_disk_type.go index 0e199a626..25056ee10 100644 --- a/weed/storage/types/volume_disk_type.go +++ b/weed/storage/types/volume_disk_type.go @@ -25,7 +25,7 @@ func ToDiskType(vt string) (diskType DiskType) { return } -func (diskType DiskType) String() string{ +func (diskType DiskType) String() string { if diskType == "" { return "" } diff --git a/weed/topology/disk.go b/weed/topology/disk.go index c159c4cca..37d5e1272 100644 --- a/weed/topology/disk.go +++ b/weed/topology/disk.go @@ -48,11 +48,11 @@ func (d *DiskUsages) negative() *DiskUsages { t := newDiskUsages() for diskType, b := range d.usages { a := t.getOrCreateDisk(diskType) - a.volumeCount = - b.volumeCount - a.remoteVolumeCount = - b.remoteVolumeCount - a.activeVolumeCount = - b.activeVolumeCount - a.ecShardCount = - b.ecShardCount - a.maxVolumeCount = - b.maxVolumeCount + a.volumeCount = -b.volumeCount + a.remoteVolumeCount = -b.remoteVolumeCount + a.activeVolumeCount = -b.activeVolumeCount + a.ecShardCount = -b.ecShardCount + a.maxVolumeCount = -b.maxVolumeCount } return t @@ -68,7 +68,7 @@ func (d *DiskUsages) ToMap() interface{} { return ret } -func (d *DiskUsages) ToDiskInfo() (map[string]*master_pb.DiskInfo) { +func (d *DiskUsages) ToDiskInfo() map[string]*master_pb.DiskInfo { ret := make(map[string]*master_pb.DiskInfo) for diskType, diskUsageCounts := range d.usages { m := &master_pb.DiskInfo{ diff --git a/weed/topology/node.go b/weed/topology/node.go index f9ac890ef..95d63972e 100644 --- a/weed/topology/node.go +++ b/weed/topology/node.go @@ -39,7 +39,7 @@ type NodeImpl struct { diskUsages *DiskUsages id NodeId parent Node - sync.RWMutex // lock children + sync.RWMutex // lock children children map[NodeId]Node maxVolumeId needle.VolumeId