Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

go fmt

Chris Lu446e476a11cb
diff --git a/weed/command/filer_sync.go b/weed/command/filer_sync.go
index a1d0bd2acb..cafd51a16a 100644
--- a/weed/command/filer_sync.go
+++ b/weed/command/filer_sync.go
@@ -36,7 +36,7 @@ type SyncOptions struct {
}
var (
- syncOptions SyncOptions
+ syncOptions SyncOptions
syncCpuProfile *string
syncMemProfile *string
)
diff --git a/weed/filer/meta_aggregator.go b/weed/filer/meta_aggregator.go
index c1e73aaf98..e95b457a43 100644
--- a/weed/filer/meta_aggregator.go
+++ b/weed/filer/meta_aggregator.go
@@ -87,7 +87,7 @@ func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self string, peer string
if err := ma.updateOffset(f, peer, peerSignature, event.TsNs); err == nil {
if event.TsNs < time.Now().Add(-2*time.Minute).UnixNano() {
glog.V(0).Infof("sync with %s progressed to: %v %0.2f/sec", peer, time.Unix(0, event.TsNs), float64(counter)/60.0)
- } else if !synced{
+ } else if !synced {
synced = true
glog.V(0).Infof("synced with %s", peer)
}
@@ -162,13 +162,13 @@ func (ma *MetaAggregator) readFilerStoreSignature(peer string) (sig int32, err e
return
}
-const(
+const (
MetaOffsetPrefix = "Meta"
)
func (ma *MetaAggregator) readOffset(f *Filer, peer string, peerSignature int32) (lastTsNs int64, err error) {
- key := []byte(MetaOffsetPrefix+"xxxx")
+ key := []byte(MetaOffsetPrefix + "xxxx")
util.Uint32toBytes(key[len(MetaOffsetPrefix):], uint32(peerSignature))
value, err := f.Store.KvGet(context.Background(), key)
@@ -191,7 +191,7 @@ func (ma *MetaAggregator) readOffset(f *Filer, peer string, peerSignature int32)
func (ma *MetaAggregator) updateOffset(f *Filer, peer string, peerSignature int32, lastTsNs int64) (err error) {
- key := []byte(MetaOffsetPrefix+"xxxx")
+ key := []byte(MetaOffsetPrefix + "xxxx")
util.Uint32toBytes(key[len(MetaOffsetPrefix):], uint32(peerSignature))
value := make([]byte, 8)
diff --git a/weed/replication/replicator.go b/weed/replication/replicator.go
index e0535175e4..c4228434f5 100644
--- a/weed/replication/replicator.go
+++ b/weed/replication/replicator.go
@@ -84,4 +84,3 @@ func ReadFilerSignature(grpcDialOption grpc.DialOption, filer string) (filerSign
}
return filerSignature, nil
}
-
diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go
index c92d61e355..6248214318 100644
--- a/weed/shell/command_volume_balance.go
+++ b/weed/shell/command_volume_balance.go
@@ -174,7 +174,7 @@ func (n *Node) localVolumeRatio() float64 {
}
func (n *Node) localVolumeNextRatio() float64 {
- return divide(len(n.selectedVolumes) + 1, int(n.info.MaxVolumeCount))
+ return divide(len(n.selectedVolumes)+1, int(n.info.MaxVolumeCount))
}
func (n *Node) selectVolumes(fn func(v *master_pb.VolumeInformationMessage) bool) {
diff --git a/weed/shell/command_volume_balance_test.go b/weed/shell/command_volume_balance_test.go
index 4f46648c00..9e154dc00e 100644
--- a/weed/shell/command_volume_balance_test.go
+++ b/weed/shell/command_volume_balance_test.go
@@ -20,7 +20,6 @@ func TestIsGoodMove(t *testing.T) {
var tests = []testMoveCase{
-
{
name: "test 100 move to spread into proper data centers",
replication: "100",
@@ -132,7 +131,6 @@ func TestIsGoodMove(t *testing.T) {
targetLocation: location{"dc1", "r2", &master_pb.DataNodeInfo{Id: "dn3"}},
expected: true,
},
-
}
for _, tt := range tests {
diff --git a/weed/storage/needle_map_memory.go b/weed/storage/needle_map_memory.go
index 3fa85deda9..23ee561d07 100644
--- a/weed/storage/needle_map_memory.go
+++ b/weed/storage/needle_map_memory.go
@@ -65,7 +65,7 @@ func (nm *NeedleMap) Get(key NeedleId) (existingValue *needle_map.NeedleValue, o
}
func (nm *NeedleMap) Delete(key NeedleId) error {
existingValue, ok := nm.m.Get(NeedleId(key))
- if !ok || existingValue.Size.IsDeleted(){
+ if !ok || existingValue.Size.IsDeleted() {
return nil
}
deletedBytes := nm.m.Delete(NeedleId(key))
diff --git a/weed/storage/needle_map_metric_test.go b/weed/storage/needle_map_metric_test.go
index 0c792869f7..a460b34084 100644
--- a/weed/storage/needle_map_metric_test.go
+++ b/weed/storage/needle_map_metric_test.go
@@ -17,7 +17,7 @@ func TestFastLoadingNeedleMapMetrics(t *testing.T) {
for i := 0; i < 10000; i++ {
nm.Put(Uint64ToNeedleId(uint64(i+1)), Uint32ToOffset(uint32(0)), Size(1))
if rand.Float32() < 0.2 {
- nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i))+1)))
+ nm.Delete(Uint64ToNeedleId(uint64(rand.Int63n(int64(i)) + 1)))
}
}
diff --git a/weed/util/compression.go b/weed/util/compression.go
index 736f76a5e0..cf3ac7c578 100644
--- a/weed/util/compression.go
+++ b/weed/util/compression.go
@@ -12,11 +12,11 @@ import (
"github.com/klauspost/compress/zstd"
)
-var(
+var (
UnsupportedCompression = fmt.Errorf("unsupported compression")
)
-func MaybeGzipData(input []byte) ([]byte) {
+func MaybeGzipData(input []byte) []byte {
if IsGzippedContent(input) {
return input
}
@@ -24,13 +24,13 @@ func MaybeGzipData(input []byte) ([]byte) {
if err != nil {
return input
}
- if len(gzipped) * 10 > len(input) * 9 {
+ if len(gzipped)*10 > len(input)*9 {
return input
}
return gzipped
}
-func MaybeDecompressData(input []byte) ([]byte) {
+func MaybeDecompressData(input []byte) []byte {
uncompressed, err := DecompressData(input)
if err != nil {
if err != UnsupportedCompression {