diff --git a/weed/command/export.go b/weed/command/export.go index b78b3f601..529ee47e3 100644 --- a/weed/command/export.go +++ b/weed/command/export.go @@ -125,7 +125,7 @@ func runExport(cmd *Command, args []string) bool { t := time.Now() tarHeader = tar.Header{Mode: 0644, ModTime: t, Uid: os.Getuid(), Gid: os.Getgid(), - Typeflag: tar.TypeReg, + Typeflag: tar.TypeReg, AccessTime: t, ChangeTime: t} } diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go index 9937bc9d6..218abf645 100644 --- a/weed/command/filer_copy.go +++ b/weed/command/filer_copy.go @@ -8,16 +8,16 @@ import ( "path/filepath" "strings" + "context" "github.com/chrislusf/seaweedfs/weed/operation" + "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/security" - "path" + "github.com/chrislusf/seaweedfs/weed/util" + "io" "net/http" - "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" + "path" "strconv" - "io" "time" - "context" - "github.com/chrislusf/seaweedfs/weed/util" ) var ( @@ -77,7 +77,7 @@ func runCopy(cmd *Command, args []string) bool { return false } filerDestination := args[len(args)-1] - fileOrDirs := args[0: len(args)-1] + fileOrDirs := args[0 : len(args)-1] filerUrl, err := url.Parse(filerDestination) if err != nil { diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index fda15090f..242ed4dc8 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -11,8 +11,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/filesys" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/util" - "strings" "strconv" + "strings" ) func runMount(cmd *Command, args []string) bool { diff --git a/weed/command/s3.go b/weed/command/s3.go index 03fa80ed8..1966cb954 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -4,11 +4,11 @@ import ( "net/http" "time" + "fmt" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/s3api" "github.com/chrislusf/seaweedfs/weed/util" "github.com/gorilla/mux" - "fmt" - "github.com/chrislusf/seaweedfs/weed/s3api" ) var ( diff --git a/weed/filer2/abstract_sql/abstract_sql_store.go b/weed/filer2/abstract_sql/abstract_sql_store.go index d6bb717ca..5f2990475 100644 --- a/weed/filer2/abstract_sql/abstract_sql_store.go +++ b/weed/filer2/abstract_sql/abstract_sql_store.go @@ -77,7 +77,7 @@ func (store *AbstractSqlStore) FindEntry(fullpath filer2.FullPath) (*filer2.Entr return entry, nil } -func (store *AbstractSqlStore) DeleteEntry(fullpath filer2.FullPath) (error) { +func (store *AbstractSqlStore) DeleteEntry(fullpath filer2.FullPath) error { dir, name := fullpath.DirAndName() diff --git a/weed/filer2/filer_master.go b/weed/filer2/filer_master.go index 51b12c237..63c3ef452 100644 --- a/weed/filer2/filer_master.go +++ b/weed/filer2/filer_master.go @@ -1,12 +1,12 @@ package filer2 import ( - "fmt" "context" + "fmt" "time" - "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/util" ) diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index b8183037b..744eeac2b 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -9,9 +9,9 @@ import ( "bazil.org/fuse" "bazil.org/fuse/fs" + "github.com/chrislusf/seaweedfs/weed/filer2" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" - "github.com/chrislusf/seaweedfs/weed/filer2" ) type Dir struct { diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index a89c51b31..7ba515202 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -1,9 +1,9 @@ package filesys import ( - "context" "bazil.org/fuse" "bazil.org/fuse/fs" + "context" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "path/filepath" diff --git a/weed/filesys/dirty_page.go b/weed/filesys/dirty_page.go index 6a7b557c2..a9307f246 100644 --- a/weed/filesys/dirty_page.go +++ b/weed/filesys/dirty_page.go @@ -1,14 +1,14 @@ package filesys import ( - "fmt" "bytes" - "time" "context" + "fmt" + "time" - "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" - "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/operation" + "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" ) type ContinuousDirtyPages struct { diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 03eed0a6f..0c13db984 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -9,9 +9,9 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" + "net/http" "strings" "sync" - "net/http" ) type FileHandle struct { diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 2f885d0af..6a89c654e 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -1,15 +1,15 @@ package filesys import ( + "bazil.org/fuse" "bazil.org/fuse/fs" "fmt" - "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" - "github.com/karlseguin/ccache" - "sync" - "bazil.org/fuse" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" + "github.com/karlseguin/ccache" "strings" + "sync" ) type WFS struct { @@ -30,7 +30,7 @@ type WFS struct { func NewSeaweedFileSystem(filerGrpcAddress string, filerMountRootPath string, collection string, replication string, ttlSec int32, chunkSizeLimitMB int, dataCenter string) *WFS { if filerMountRootPath != "/" && strings.HasSuffix(filerMountRootPath, "/") { - filerMountRootPath = filerMountRootPath[0:len(filerMountRootPath)-1] + filerMountRootPath = filerMountRootPath[0 : len(filerMountRootPath)-1] } return &WFS{ filerGrpcAddress: filerGrpcAddress, diff --git a/weed/operation/sync_volume.go b/weed/operation/sync_volume.go index 5be312450..d4434b318 100644 --- a/weed/operation/sync_volume.go +++ b/weed/operation/sync_volume.go @@ -6,8 +6,8 @@ import ( "net/url" "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/chrislusf/seaweedfs/weed/util" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/util" ) type SyncVolumeResponse struct { @@ -44,8 +44,8 @@ func GetVolumeIdxEntries(server string, vid string, eachEntryFn func(key NeedleI line := make([]byte, NeedleEntrySize) err := util.GetBufferStream("http://"+server+"/admin/sync/index", values, line, func(bytes []byte) { key := BytesToNeedleId(line[:NeedleIdSize]) - offset := BytesToOffset(line[NeedleIdSize:NeedleIdSize+OffsetSize]) - size := util.BytesToUint32(line[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize]) + offset := BytesToOffset(line[NeedleIdSize : NeedleIdSize+OffsetSize]) + size := util.BytesToUint32(line[NeedleIdSize+OffsetSize : NeedleIdSize+OffsetSize+SizeSize]) eachEntryFn(key, offset, size) }) if err != nil { diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index a2af1f70c..af05d0a93 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -1,14 +1,14 @@ package s3api import ( - "net/http" - "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" - "github.com/chrislusf/seaweedfs/weed/glog" - "time" "context" "fmt" + "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/gorilla/mux" + "net/http" "os" + "time" ) var ( diff --git a/weed/s3api/s3api_errors.go b/weed/s3api/s3api_errors.go index 10b48c2c8..771b1dd82 100644 --- a/weed/s3api/s3api_errors.go +++ b/weed/s3api/s3api_errors.go @@ -26,7 +26,7 @@ type ErrorCode int // Error codes, see full list at http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html const ( - ErrNone ErrorCode = iota + ErrNone ErrorCode = iota ErrMethodNotAllowed ErrBucketNotEmpty ErrBucketAlreadyExists diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go index 13dfc8d15..8c3d4a5b1 100644 --- a/weed/s3api/s3api_handlers.go +++ b/weed/s3api/s3api_handlers.go @@ -1,17 +1,17 @@ package s3api import ( - "net/http" - "net/url" - "fmt" - "time" - "github.com/gorilla/mux" + "bytes" "context" + "encoding/base64" + "encoding/xml" + "fmt" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" - "bytes" - "encoding/xml" - "encoding/base64" + "github.com/gorilla/mux" + "net/http" + "net/url" + "time" ) type mimeType string diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 079509792..132b0e753 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -1,12 +1,12 @@ package s3api import ( - "net/http" - "github.com/chrislusf/seaweedfs/weed/glog" + "encoding/json" "fmt" + "github.com/chrislusf/seaweedfs/weed/glog" "github.com/gorilla/mux" "io/ioutil" - "encoding/json" + "net/http" ) var ( diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index d8e6de1f7..078dcaa75 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -37,7 +37,7 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { apiRouter := router.PathPrefix("/").Subrouter() var routers []*mux.Router if s3a.option.DomainName != "" { - routers = append(routers, apiRouter.Host("{bucket:.+}." + s3a.option.DomainName).Subrouter()) + routers = append(routers, apiRouter.Host("{bucket:.+}."+s3a.option.DomainName).Subrouter()) } routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter()) diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go index feedb905d..830d8ebe1 100644 --- a/weed/server/filer_grpc_server.go +++ b/weed/server/filer_grpc_server.go @@ -11,8 +11,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" - "strconv" "github.com/chrislusf/seaweedfs/weed/util" + "strconv" ) func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) { diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index 601790f8a..61ca972cc 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -1,7 +1,6 @@ package weed_server import ( - "net/http" "github.com/chrislusf/seaweedfs/weed/filer2" _ "github.com/chrislusf/seaweedfs/weed/filer2/cassandra" _ "github.com/chrislusf/seaweedfs/weed/filer2/leveldb" @@ -9,8 +8,9 @@ import ( _ "github.com/chrislusf/seaweedfs/weed/filer2/mysql" _ "github.com/chrislusf/seaweedfs/weed/filer2/postgres" _ "github.com/chrislusf/seaweedfs/weed/filer2/redis" - "github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/security" + "net/http" ) type FilerOption struct { diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go index dbd91c5e0..77374147a 100644 --- a/weed/server/filer_server_handlers_read.go +++ b/weed/server/filer_server_handlers_read.go @@ -10,10 +10,10 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/util" - "strconv" - "mime/multipart" "mime" + "mime/multipart" "path" + "strconv" ) func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, isGetMethod bool) { diff --git a/weed/server/raft_server_handlers.go b/weed/server/raft_server_handlers.go index c91ab0407..627fe354e 100644 --- a/weed/server/raft_server_handlers.go +++ b/weed/server/raft_server_handlers.go @@ -1,8 +1,8 @@ package weed_server import ( - "net/http" "github.com/chrislusf/seaweedfs/weed/operation" + "net/http" ) func (s *RaftServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) { diff --git a/weed/server/volume_grpc_client.go b/weed/server/volume_grpc_client.go index b3c755239..de6fa23c7 100644 --- a/weed/server/volume_grpc_client.go +++ b/weed/server/volume_grpc_client.go @@ -7,8 +7,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/security" - "golang.org/x/net/context" "github.com/chrislusf/seaweedfs/weed/util" + "golang.org/x/net/context" ) func (vs *VolumeServer) GetMaster() string { diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go index 9294f9bf6..037fca2c2 100644 --- a/weed/server/volume_server.go +++ b/weed/server/volume_server.go @@ -1,10 +1,10 @@ package weed_server import ( - "net/http" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/storage" + "net/http" ) type VolumeServer struct { diff --git a/weed/server/volume_server_handlers_sync.go b/weed/server/volume_server_handlers_sync.go index 38adfe870..c6e32bb9b 100644 --- a/weed/server/volume_server_handlers_sync.go +++ b/weed/server/volume_server_handlers_sync.go @@ -6,8 +6,8 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage" - "github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/util" ) func (vs *VolumeServer) getVolumeSyncStatusHandler(w http.ResponseWriter, r *http.Request) { diff --git a/weed/storage/needle/btree_map.go b/weed/storage/needle/btree_map.go index a7c9982ac..d688b802e 100644 --- a/weed/storage/needle/btree_map.go +++ b/weed/storage/needle/btree_map.go @@ -1,8 +1,8 @@ package needle import ( - "github.com/google/btree" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/google/btree" ) //This map assumes mostly inserting increasing keys diff --git a/weed/storage/needle/compact_map.go b/weed/storage/needle/compact_map.go index 7b653d838..9852dca74 100644 --- a/weed/storage/needle/compact_map.go +++ b/weed/storage/needle/compact_map.go @@ -1,8 +1,8 @@ package needle import ( - "sync" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "sync" ) type CompactSection struct { diff --git a/weed/storage/needle/compact_map_perf_test.go b/weed/storage/needle/compact_map_perf_test.go index 7908e8d1d..a66836ac8 100644 --- a/weed/storage/needle/compact_map_perf_test.go +++ b/weed/storage/needle/compact_map_perf_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/chrislusf/seaweedfs/weed/util" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/chrislusf/seaweedfs/weed/util" ) func TestMemoryUsage(t *testing.T) { @@ -30,9 +30,9 @@ func loadNewNeedleMap(file *os.File) { } for count > 0 && e == nil { for i := 0; i < count; i += 16 { - key := BytesToNeedleId(bytes[i:i+NeedleIdSize]) - offset := BytesToOffset(bytes[i+NeedleIdSize:i+NeedleIdSize+OffsetSize]) - size := util.BytesToUint32(bytes[i+NeedleIdSize+OffsetSize:i+NeedleIdSize+OffsetSize+SizeSize]) + key := BytesToNeedleId(bytes[i : i+NeedleIdSize]) + offset := BytesToOffset(bytes[i+NeedleIdSize : i+NeedleIdSize+OffsetSize]) + size := util.BytesToUint32(bytes[i+NeedleIdSize+OffsetSize : i+NeedleIdSize+OffsetSize+SizeSize]) if offset > 0 { m.Set(NeedleId(key), offset, size) diff --git a/weed/storage/needle/compact_map_test.go b/weed/storage/needle/compact_map_test.go index 11d98eab3..b4cbb446a 100644 --- a/weed/storage/needle/compact_map_test.go +++ b/weed/storage/needle/compact_map_test.go @@ -1,8 +1,8 @@ package needle import ( - "testing" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "testing" ) func TestIssue52(t *testing.T) { diff --git a/weed/storage/needle/needle_value.go b/weed/storage/needle/needle_value.go index 8fd7b1b1c..b15d25245 100644 --- a/weed/storage/needle/needle_value.go +++ b/weed/storage/needle/needle_value.go @@ -1,8 +1,8 @@ package needle import ( - "github.com/google/btree" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/google/btree" ) const ( diff --git a/weed/storage/needle_map.go b/weed/storage/needle_map.go index ce2079e89..6d815679b 100644 --- a/weed/storage/needle_map.go +++ b/weed/storage/needle_map.go @@ -57,8 +57,8 @@ func (nm *baseNeedleMapper) IndexFileName() string { func IdxFileEntry(bytes []byte) (key NeedleId, offset Offset, size uint32) { key = BytesToNeedleId(bytes[:NeedleIdSize]) - offset = BytesToOffset(bytes[NeedleIdSize:NeedleIdSize+OffsetSize]) - size = util.BytesToUint32(bytes[NeedleIdSize+OffsetSize:NeedleIdSize+OffsetSize+SizeSize]) + offset = BytesToOffset(bytes[NeedleIdSize : NeedleIdSize+OffsetSize]) + size = util.BytesToUint32(bytes[NeedleIdSize+OffsetSize : NeedleIdSize+OffsetSize+SizeSize]) return } func (nm *baseNeedleMapper) appendToIndexFile(key NeedleId, offset Offset, size uint32) error { diff --git a/weed/storage/needle_map_boltdb.go b/weed/storage/needle_map_boltdb.go index d5062a1b7..fd335fd00 100644 --- a/weed/storage/needle_map_boltdb.go +++ b/weed/storage/needle_map_boltdb.go @@ -6,11 +6,11 @@ import ( "github.com/boltdb/bolt" + "errors" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/storage/needle" . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/util" - "errors" ) type BoltDbNeedleMap struct { @@ -101,7 +101,7 @@ func (m *BoltDbNeedleMap) Get(key NeedleId) (element *needle.NeedleValue, ok boo } offset = BytesToOffset(data[0:OffsetSize]) - size = util.BytesToUint32(data[OffsetSize:OffsetSize+SizeSize]) + size = util.BytesToUint32(data[OffsetSize : OffsetSize+SizeSize]) return nil }) diff --git a/weed/storage/needle_map_leveldb.go b/weed/storage/needle_map_leveldb.go index 1af88e545..1580bb005 100644 --- a/weed/storage/needle_map_leveldb.go +++ b/weed/storage/needle_map_leveldb.go @@ -81,7 +81,7 @@ func (m *LevelDbNeedleMap) Get(key NeedleId) (element *needle.NeedleValue, ok bo return nil, false } offset := BytesToOffset(data[0:OffsetSize]) - size := util.BytesToUint32(data[OffsetSize:OffsetSize+SizeSize]) + size := util.BytesToUint32(data[OffsetSize : OffsetSize+SizeSize]) return &needle.NeedleValue{Key: NeedleId(key), Offset: offset, Size: size}, true } diff --git a/weed/storage/needle_map_memory.go b/weed/storage/needle_map_memory.go index 690ddd737..fa5576c2b 100644 --- a/weed/storage/needle_map_memory.go +++ b/weed/storage/needle_map_memory.go @@ -88,7 +88,7 @@ func WalkIndexFile(r *os.File, fn func(key NeedleId, offset Offset, size uint32) for count > 0 && e == nil || e == io.EOF { for i = 0; i+NeedleEntrySize <= count; i += NeedleEntrySize { - key, offset, size = IdxFileEntry(bytes[i: i+NeedleEntrySize]) + key, offset, size = IdxFileEntry(bytes[i : i+NeedleEntrySize]) if e = fn(key, offset, size); e != nil { return e } diff --git a/weed/storage/needle_map_metric.go b/weed/storage/needle_map_metric.go index 793a9ea10..3bcb140f1 100644 --- a/weed/storage/needle_map_metric.go +++ b/weed/storage/needle_map_metric.go @@ -2,10 +2,10 @@ package storage import ( "fmt" - "os" - "github.com/willf/bloom" "github.com/chrislusf/seaweedfs/weed/glog" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "github.com/willf/bloom" + "os" ) type mapMetric struct { diff --git a/weed/storage/needle_map_metric_test.go b/weed/storage/needle_map_metric_test.go index 400e655a7..539f83a87 100644 --- a/weed/storage/needle_map_metric_test.go +++ b/weed/storage/needle_map_metric_test.go @@ -1,11 +1,11 @@ package storage import ( - "testing" - "io/ioutil" - "math/rand" "github.com/chrislusf/seaweedfs/weed/glog" . "github.com/chrislusf/seaweedfs/weed/storage/types" + "io/ioutil" + "math/rand" + "testing" ) func TestFastLoadingNeedleMapMetrics(t *testing.T) { diff --git a/weed/storage/needle_parse_multipart.go b/weed/storage/needle_parse_multipart.go index 112ec32d4..af12b994d 100644 --- a/weed/storage/needle_parse_multipart.go +++ b/weed/storage/needle_parse_multipart.go @@ -1,12 +1,12 @@ package storage import ( - "mime" - "github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/glog" + "github.com/chrislusf/seaweedfs/weed/operation" + "io/ioutil" + "mime" "net/http" "path" - "io/ioutil" "strings" ) diff --git a/weed/storage/needle_read_write.go b/weed/storage/needle_read_write.go index a62539afc..bfd325475 100644 --- a/weed/storage/needle_read_write.go +++ b/weed/storage/needle_read_write.go @@ -6,8 +6,8 @@ import ( "io" "os" - . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/glog" + . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/util" ) @@ -59,7 +59,7 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, actualSize i actualSize = NeedleEntrySize + int64(n.Size) padding := NeedlePaddingSize - ((NeedleEntrySize + n.Size + NeedleChecksumSize) % NeedlePaddingSize) util.Uint32toBytes(header[0:NeedleChecksumSize], n.Checksum.Value()) - _, err = w.Write(header[0: NeedleChecksumSize+padding]) + _, err = w.Write(header[0 : NeedleChecksumSize+padding]) return case Version2: header := make([]byte, NeedleEntrySize) @@ -123,7 +123,7 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, actualSize i } if n.HasLastModifiedDate() { util.Uint64toBytes(header[0:8], n.LastModified) - if _, err = w.Write(header[8-LastModifiedBytesLength: 8]); err != nil { + if _, err = w.Write(header[8-LastModifiedBytesLength : 8]); err != nil { return } } @@ -145,7 +145,7 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, actualSize i } padding := NeedlePaddingSize - ((NeedleEntrySize + n.Size + NeedleChecksumSize) % NeedlePaddingSize) util.Uint32toBytes(header[0:NeedleChecksumSize], n.Checksum.Value()) - _, err = w.Write(header[0: NeedleChecksumSize+padding]) + _, err = w.Write(header[0 : NeedleChecksumSize+padding]) return n.DataSize, getActualSize(n.Size), err } @@ -169,14 +169,14 @@ func (n *Needle) ReadData(r *os.File, offset int64, size uint32, version Version } switch version { case Version1: - n.Data = bytes[NeedleEntrySize: NeedleEntrySize+size] + n.Data = bytes[NeedleEntrySize : NeedleEntrySize+size] case Version2: - n.readNeedleDataVersion2(bytes[NeedleEntrySize: NeedleEntrySize+int(n.Size)]) + n.readNeedleDataVersion2(bytes[NeedleEntrySize : NeedleEntrySize+int(n.Size)]) } if size == 0 { return nil } - checksum := util.BytesToUint32(bytes[NeedleEntrySize+size: NeedleEntrySize+size+NeedleChecksumSize]) + checksum := util.BytesToUint32(bytes[NeedleEntrySize+size : NeedleEntrySize+size+NeedleChecksumSize]) newChecksum := NewCRC(n.Data) if checksum != newChecksum.Value() { return errors.New("CRC error! Data On Disk Corrupted") @@ -187,21 +187,21 @@ func (n *Needle) ReadData(r *os.File, offset int64, size uint32, version Version func (n *Needle) ParseNeedleHeader(bytes []byte) { n.Cookie = BytesToCookie(bytes[0:CookieSize]) - n.Id = BytesToNeedleId(bytes[CookieSize:CookieSize+NeedleIdSize]) - n.Size = util.BytesToUint32(bytes[CookieSize+NeedleIdSize:NeedleEntrySize]) + n.Id = BytesToNeedleId(bytes[CookieSize : CookieSize+NeedleIdSize]) + n.Size = util.BytesToUint32(bytes[CookieSize+NeedleIdSize : NeedleEntrySize]) } func (n *Needle) readNeedleDataVersion2(bytes []byte) { index, lenBytes := 0, len(bytes) if index < lenBytes { - n.DataSize = util.BytesToUint32(bytes[index: index+4]) + n.DataSize = util.BytesToUint32(bytes[index : index+4]) index = index + 4 if int(n.DataSize)+index > lenBytes { // this if clause is due to bug #87 and #93, fixed in v0.69 // remove this clause later return } - n.Data = bytes[index: index+int(n.DataSize)] + n.Data = bytes[index : index+int(n.DataSize)] index = index + int(n.DataSize) n.Flags = bytes[index] index = index + 1 @@ -209,25 +209,25 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) { if index < lenBytes && n.HasName() { n.NameSize = uint8(bytes[index]) index = index + 1 - n.Name = bytes[index: index+int(n.NameSize)] + n.Name = bytes[index : index+int(n.NameSize)] index = index + int(n.NameSize) } if index < lenBytes && n.HasMime() { n.MimeSize = uint8(bytes[index]) index = index + 1 - n.Mime = bytes[index: index+int(n.MimeSize)] + n.Mime = bytes[index : index+int(n.MimeSize)] index = index + int(n.MimeSize) } if index < lenBytes && n.HasLastModifiedDate() { - n.LastModified = util.BytesToUint64(bytes[index: index+LastModifiedBytesLength]) + n.LastModified = util.BytesToUint64(bytes[index : index+LastModifiedBytesLength]) index = index + LastModifiedBytesLength } if index < lenBytes && n.HasTtl() { - n.Ttl = LoadTTLFromBytes(bytes[index: index+TtlBytesLength]) + n.Ttl = LoadTTLFromBytes(bytes[index : index+TtlBytesLength]) index = index + TtlBytesLength } if index < lenBytes && n.HasPairs() { - n.PairsSize = util.BytesToUint16(bytes[index: index+2]) + n.PairsSize = util.BytesToUint16(bytes[index : index+2]) index += 2 end := index + int(n.PairsSize) n.Pairs = bytes[index:end] diff --git a/weed/storage/needle_test.go b/weed/storage/needle_test.go index 4dce3f123..65036409c 100644 --- a/weed/storage/needle_test.go +++ b/weed/storage/needle_test.go @@ -1,8 +1,8 @@ package storage import ( - "testing" "github.com/chrislusf/seaweedfs/weed/storage/types" + "testing" ) func TestParseKeyHash(t *testing.T) { diff --git a/weed/storage/store.go b/weed/storage/store.go index ef055ee59..ac125ef4b 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -5,9 +5,9 @@ import ( "strconv" "strings" - . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" + . "github.com/chrislusf/seaweedfs/weed/storage/types" ) const ( diff --git a/weed/storage/types/needle_id_type.go b/weed/storage/types/needle_id_type.go index d9e7074b3..cb19a6f45 100644 --- a/weed/storage/types/needle_id_type.go +++ b/weed/storage/types/needle_id_type.go @@ -1,9 +1,9 @@ package types import ( + "fmt" "github.com/chrislusf/seaweedfs/weed/util" "strconv" - "fmt" ) type NeedleId uint64 @@ -21,11 +21,11 @@ func NeedleIdToUint64(needleId NeedleId) uint64 { return uint64(needleId) } -func Uint64ToNeedleId(needleId uint64) (NeedleId) { +func Uint64ToNeedleId(needleId uint64) NeedleId { return NeedleId(needleId) } -func BytesToNeedleId(bytes []byte) (NeedleId) { +func BytesToNeedleId(bytes []byte) NeedleId { return NeedleId(util.BytesToUint64(bytes)) } diff --git a/weed/storage/types/needle_types.go b/weed/storage/types/needle_types.go index 09ff727e6..8a2054fc5 100644 --- a/weed/storage/types/needle_types.go +++ b/weed/storage/types/needle_types.go @@ -1,10 +1,10 @@ package types import ( - "math" + "fmt" "github.com/chrislusf/seaweedfs/weed/util" + "math" "strconv" - "fmt" ) type Offset uint32 @@ -23,11 +23,11 @@ const ( func CookieToBytes(bytes []byte, cookie Cookie) { util.Uint32toBytes(bytes, uint32(cookie)) } -func Uint32ToCookie(cookie uint32) (Cookie) { +func Uint32ToCookie(cookie uint32) Cookie { return Cookie(cookie) } -func BytesToCookie(bytes []byte) (Cookie) { +func BytesToCookie(bytes []byte) Cookie { return Cookie(util.BytesToUint32(bytes[0:4])) } @@ -43,10 +43,10 @@ func OffsetToBytes(bytes []byte, offset Offset) { util.Uint32toBytes(bytes, uint32(offset)) } -func Uint32ToOffset(offset uint32) (Offset) { +func Uint32ToOffset(offset uint32) Offset { return Offset(offset) } -func BytesToOffset(bytes []byte) (Offset) { +func BytesToOffset(bytes []byte) Offset { return Offset(util.BytesToUint32(bytes[0:4])) } diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go index 34b4cfe0d..58ecc73cb 100644 --- a/weed/storage/volume_vacuum.go +++ b/weed/storage/volume_vacuum.go @@ -5,8 +5,8 @@ import ( "os" "time" - . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/glog" + . "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/util" ) diff --git a/weed/storage/volume_vacuum_test.go b/weed/storage/volume_vacuum_test.go index 896540621..464d52618 100644 --- a/weed/storage/volume_vacuum_test.go +++ b/weed/storage/volume_vacuum_test.go @@ -1,11 +1,11 @@ package storage import ( + "github.com/chrislusf/seaweedfs/weed/storage/types" "io/ioutil" "math/rand" "os" "testing" - "github.com/chrislusf/seaweedfs/weed/storage/types" ) /*