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.

1. v0.54 2. go vet found many printing format errors

Chris Lu3b5035c46862
diff --git a/go/storage/cdb_map.go b/go/storage/cdb_map.go
index 14437c45bf..d09a87e2a0 100644
--- a/go/storage/cdb_map.go
+++ b/go/storage/cdb_map.go
@@ -142,7 +142,7 @@ func (m cdbMap) Visit(visit func(NeedleValue) error) (err error) {
func ConvertIndexToCdb(cdbName string, index *os.File) error {
idx, err := LoadNeedleMap(index)
if err != nil {
- return fmt.Errorf("error loading needle map %s: %s", index, err)
+ return fmt.Errorf("error loading needle map %s: %s", index.Name(), err)
}
defer idx.Close()
return DumpNeedleMapToCdb(cdbName, idx)
@@ -185,12 +185,12 @@ func DumpNeedleMapToCdb(cdbName string, nm *NeedleMap) error {
})
if err != nil {
closer()
- return fmt.Errorf("error walking index %s: %s", nm, err)
+ return fmt.Errorf("error walking index %v: %s", nm, err)
}
// store fileBytes
data, e := json.Marshal(nm.mapMetric)
if e != nil {
- return fmt.Errorf("error marshaling metric %s: %s", nm.mapMetric, e)
+ return fmt.Errorf("error marshaling metric %v: %s", nm.mapMetric, e)
}
if err = adder(cdb.Element{Key: []byte{'M'}, Data: data}); err != nil {
return err
diff --git a/go/storage/cdb_map_test.go b/go/storage/cdb_map_test.go
index 6fe2a12f00..f6a7d42ad1 100644
--- a/go/storage/cdb_map_test.go
+++ b/go/storage/cdb_map_test.go
@@ -84,7 +84,7 @@ func BenchmarkCdbMap9List(t *testing.B) {
t.Logf("opening %s", indexFile)
idx, err := LoadNeedleMap(indexFile)
if err != nil {
- t.Fatalf("cannot load %s: %s", indexFile, err)
+ t.Fatalf("cannot load %s: %s", indexFile.Name(), err)
}
defer idx.Close()
b := getMemStats()
@@ -113,7 +113,7 @@ func BenchmarkCdbMap9List(t *testing.B) {
glog.V(0).Infof("%d. %s", i, nv)
}
if nv2, ok := m.Get(uint64(nv.Key)); !ok || nv2 == nil {
- t.Errorf("%s in index, not in cdb", nv.Key)
+ t.Errorf("%d in index, not in cdb", nv.Key)
} else if nv2.Key != nv.Key {
t.Errorf("requested key %d from cdb, got %d", nv.Key, nv2.Key)
} else if nv2.Offset != nv.Offset {
@@ -137,7 +137,7 @@ func BenchmarkCdbMap9List(t *testing.B) {
return nil
}
if nv2, ok := m.Get(uint64(nv.Key)); !ok || nv2 == nil {
- t.Errorf("%s in cdb, not in index", nv.Key)
+ t.Errorf("%d in cdb, not in index", nv.Key)
} else if nv2.Key != nv.Key {
t.Errorf("requested key %d from index, got %d", nv.Key, nv2.Key)
} else if nv2.Offset != nv.Offset {
diff --git a/go/storage/needle_map.go b/go/storage/needle_map.go
index 9c77fcf731..33d3d17471 100644
--- a/go/storage/needle_map.go
+++ b/go/storage/needle_map.go
@@ -145,7 +145,7 @@ func (nm *NeedleMap) Delete(key uint64) error {
if e := nm.indexFile.Truncate(offset); e != nil {
plus = "\ncouldn't truncate index file: " + e.Error()
}
- return fmt.Errorf("error writing to indexfile %s: %s%s", nm.indexFile, err, plus)
+ return fmt.Errorf("error writing to indexfile %s: %s%s", nm.indexFile.Name(), err, plus)
}
nm.DeletionCounter++
return nil
diff --git a/go/storage/store.go b/go/storage/store.go
index a4263dcac5..8c6663a08a 100644
--- a/go/storage/store.go
+++ b/go/storage/store.go
@@ -150,7 +150,7 @@ func (s *Store) findFreeLocation() (ret *DiskLocation) {
}
func (s *Store) addVolume(vid VolumeId, collection string, replicaPlacement *ReplicaPlacement) error {
if s.findVolume(vid) != nil {
- return fmt.Errorf("Volume Id %s already exists!", vid)
+ return fmt.Errorf("Volume Id %d already exists!", vid)
}
if location := s.findFreeLocation(); location != nil {
glog.V(0).Infoln("In dir", location.Directory, "adds volume =", vid, ", collection =", collection, ", replicaPlacement =", replicaPlacement)
@@ -177,7 +177,7 @@ func (s *Store) CheckCompactVolume(volumeIdString string, garbageThresholdString
glog.V(3).Infoln(vid, "garbage level is", v.garbageLevel())
return nil, garbageThreshold < v.garbageLevel()
}
- return fmt.Errorf("volume id %s is not found during check compact!", vid), false
+ return fmt.Errorf("volume id %d is not found during check compact!", vid), false
}
func (s *Store) CompactVolume(volumeIdString string) error {
vid, err := NewVolumeId(volumeIdString)
@@ -187,7 +187,7 @@ func (s *Store) CompactVolume(volumeIdString string) error {
if v := s.findVolume(vid); v != nil {
return v.Compact()
}
- return fmt.Errorf("volume id %s is not found during compact!", vid)
+ return fmt.Errorf("volume id %d is not found during compact!", vid)
}
func (s *Store) CommitCompactVolume(volumeIdString string) error {
vid, err := NewVolumeId(volumeIdString)
@@ -197,7 +197,7 @@ func (s *Store) CommitCompactVolume(volumeIdString string) error {
if v := s.findVolume(vid); v != nil {
return v.commitCompact()
}
- return fmt.Errorf("volume id %s is not found during commit compact!", vid)
+ return fmt.Errorf("volume id %d is not found during commit compact!", vid)
}
func (s *Store) FreezeVolume(volumeIdString string) error {
vid, err := NewVolumeId(volumeIdString)
@@ -210,7 +210,7 @@ func (s *Store) FreezeVolume(volumeIdString string) error {
}
return v.freeze()
}
- return fmt.Errorf("volume id %s is not found during freeze!", vid)
+ return fmt.Errorf("volume id %d is not found during freeze!", vid)
}
func (l *DiskLocation) loadExistingVolumes() {
if dirs, err := ioutil.ReadDir(l.Directory); err == nil {
@@ -328,7 +328,7 @@ func (s *Store) Close() {
func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) {
if v := s.findVolume(i); v != nil {
if v.readOnly {
- err = fmt.Errorf("Volume %s is read only!", i)
+ err = fmt.Errorf("Volume %d is read only!", i)
return
} else {
if MaxPossibleVolumeSize >= v.ContentSize()+uint64(size) {
@@ -346,7 +346,7 @@ func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) {
return
}
glog.V(0).Infoln("volume", i, "not found!")
- err = fmt.Errorf("Volume %s not found!", i)
+ err = fmt.Errorf("Volume %d not found!", i)
return
}
func (s *Store) Delete(i VolumeId, n *Needle) (uint32, error) {
diff --git a/go/storage/volume.go b/go/storage/volume.go
index f0006f5cc1..9ec112c570 100644
--- a/go/storage/volume.go
+++ b/go/storage/volume.go
@@ -195,7 +195,7 @@ func (v *Volume) isFileUnchanged(n *Needle) bool {
func (v *Volume) Destroy() (err error) {
if v.readOnly {
- err = fmt.Errorf("%s is read-only", v.dataFile)
+ err = fmt.Errorf("%s is read-only", v.dataFile.Name())
return
}
v.Close()
@@ -210,7 +210,7 @@ func (v *Volume) Destroy() (err error) {
func (v *Volume) write(n *Needle) (size uint32, err error) {
glog.V(4).Infof("writing needle %s", NewFileIdFromNeedle(v.Id, n).String())
if v.readOnly {
- err = fmt.Errorf("%s is read-only", v.dataFile)
+ err = fmt.Errorf("%s is read-only", v.dataFile.Name())
return
}
v.accessLock.Lock()
@@ -236,7 +236,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
if size, err = n.Append(v.dataFile, v.Version()); err != nil {
if e := v.dataFile.Truncate(offset); e != nil {
- err = fmt.Errorf("%s\ncannot truncate %s: %s", err, v.dataFile, e.Error())
+ err = fmt.Errorf("%s\ncannot truncate %s: %s", err, v.dataFile.Name(), e.Error())
}
return
}
@@ -252,7 +252,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
func (v *Volume) delete(n *Needle) (uint32, error) {
glog.V(4).Infof("delete needle %s", NewFileIdFromNeedle(v.Id, n).String())
if v.readOnly {
- return 0, fmt.Errorf("%s is read-only", v.dataFile)
+ return 0, fmt.Errorf("%s is read-only", v.dataFile.Name())
}
v.accessLock.Lock()
defer v.accessLock.Unlock()
diff --git a/go/topology/volume_layout.go b/go/topology/volume_layout.go
index bd95cc796c..538acb54cb 100644
--- a/go/topology/volume_layout.go
+++ b/go/topology/volume_layout.go
@@ -107,7 +107,6 @@ func (vl *VolumeLayout) PickForWrite(count int, option *VolumeGrowOption) (*stor
}
return &vid, count, locationList, nil
}
- return nil, 0, nil, errors.New("Strangely This Should Never Have Happened!")
}
func (vl *VolumeLayout) GetActiveVolumeCount(option *VolumeGrowOption) int {
diff --git a/go/util/constants.go b/go/util/constants.go
index a666ff5d5a..ab57af0c9b 100644
--- a/go/util/constants.go
+++ b/go/util/constants.go
@@ -3,5 +3,5 @@ package util
import ()
const (
- VERSION = "0.54 beta"
+ VERSION = "0.54"
)
diff --git a/go/weed/export.go b/go/weed/export.go
index ef14e19c0e..dae6053c74 100644
--- a/go/weed/export.go
+++ b/go/weed/export.go
@@ -94,7 +94,7 @@ func runExport(cmd *Command, args []string) bool {
nm, err := storage.LoadNeedleMap(indexFile)
if err != nil {
- glog.Fatalf("cannot load needle map from %s: %s", indexFile, err)
+ glog.Fatalf("cannot load needle map from %s: %s", indexFile.Name(), err)
}
var version storage.Version
diff --git a/go/weed/server.go b/go/weed/server.go
index 61e42fb360..dde896c096 100644
--- a/go/weed/server.go
+++ b/go/weed/server.go
@@ -86,7 +86,7 @@ func runServer(cmd *Command, args []string) bool {
if max, e := strconv.Atoi(maxString); e == nil {
maxCounts = append(maxCounts, max)
} else {
- glog.Fatalf("The max specified in -max not a valid number %s", max)
+ glog.Fatalf("The max specified in -max not a valid number %s", maxString)
}
}
if len(folders) != len(maxCounts) {
diff --git a/go/weed/shell.go b/go/weed/shell.go
index 885a0fa71b..6a33312843 100644
--- a/go/weed/shell.go
+++ b/go/weed/shell.go
@@ -57,5 +57,4 @@ func runShell(command *Command, args []string) bool {
cmd = readLine()
execCmd(cmd)
}
- return true
}
diff --git a/go/weed/volume.go b/go/weed/volume.go
index 3c6cf05a5c..a43a396b29 100644
--- a/go/weed/volume.go
+++ b/go/weed/volume.go
@@ -53,7 +53,7 @@ func runVolume(cmd *Command, args []string) bool {
if max, e := strconv.Atoi(maxString); e == nil {
maxCounts = append(maxCounts, max)
} else {
- glog.Fatalf("The max specified in -max not a valid number %s", max)
+ glog.Fatalf("The max specified in -max not a valid number %s", maxString)
}
}
if len(folders) != len(maxCounts) {