mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
go vet
This commit is contained in:
parent
d4e5a22e53
commit
79d11ac951
|
@ -10,12 +10,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
Url string "url"
|
Url string `json:"url"`
|
||||||
PublicUrl string "publicUrl"
|
PublicUrl string `json:"publicUrl"`
|
||||||
}
|
}
|
||||||
type LookupResult struct {
|
type LookupResult struct {
|
||||||
Locations []Location "locations"
|
Locations []Location `json:"locations"`
|
||||||
Error string "error"
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Add a caching for vid here
|
//TODO: Add a caching for vid here
|
||||||
|
|
|
@ -4,8 +4,8 @@ import ()
|
||||||
|
|
||||||
type NeedleValue struct {
|
type NeedleValue struct {
|
||||||
Key Key
|
Key Key
|
||||||
Offset uint32 "Volume offset" //since aligned to 8 bytes, range is 4G*8=32G
|
Offset uint32 `comment:"Volume offset"` //since aligned to 8 bytes, range is 4G*8=32G
|
||||||
Size uint32 "Size of the data portion"
|
Size uint32 `comment:"Size of the data portion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -19,20 +19,20 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Needle struct {
|
type Needle struct {
|
||||||
Cookie uint32 "random number to mitigate brute force lookups"
|
Cookie uint32 `comment:"random number to mitigate brute force lookups"`
|
||||||
Id uint64 "needle id"
|
Id uint64 `comment:"needle id"`
|
||||||
Size uint32 "sum of DataSize,Data,NameSize,Name,MimeSize,Mime"
|
Size uint32 `comment:"sum of DataSize,Data,NameSize,Name,MimeSize,Mime"`
|
||||||
|
|
||||||
DataSize uint32 "Data size" //version2
|
DataSize uint32 `comment:"Data size"` //version2
|
||||||
Data []byte "The actual file data"
|
Data []byte `comment:"The actual file data"`
|
||||||
Flags byte "boolean flags" //version2
|
Flags byte `comment:"boolean flags"` //version2
|
||||||
NameSize uint8 //version2
|
NameSize uint8 //version2
|
||||||
Name []byte "maximum 256 characters" //version2
|
Name []byte `comment:"maximum 256 characters"` //version2
|
||||||
MimeSize uint8 //version2
|
MimeSize uint8 //version2
|
||||||
Mime []byte "maximum 256 characters" //version2
|
Mime []byte `comment:"maximum 256 characters"` //version2
|
||||||
|
|
||||||
Checksum CRC "CRC32 to check integrity"
|
Checksum CRC `comment:"CRC32 to check integrity"`
|
||||||
Padding []byte "Aligned to 8 bytes"
|
Padding []byte `comment:"Aligned to 8 bytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNeedle(r *http.Request) (n *Needle, fname string, e error) {
|
func NewNeedle(r *http.Request) (n *Needle, fname string, e error) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, err error) {
|
||||||
defer func(s io.Seeker, off int64) {
|
defer func(s io.Seeker, off int64) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, e = s.Seek(off, 0); e != nil {
|
if _, e = s.Seek(off, 0); e != nil {
|
||||||
fmt.Printf("Failed to seek back to %d with error: %s\n", w, off, e)
|
fmt.Printf("Failed to seek %s back to %d with error: %s\n", w, off, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(s, end)
|
}(s, end)
|
||||||
|
|
|
@ -18,22 +18,22 @@ func TestXYZ(t *testing.T) {
|
||||||
|
|
||||||
picked, ret := nl.RandomlyPickN(1)
|
picked, ret := nl.RandomlyPickN(1)
|
||||||
if !ret || len(picked) != 1 {
|
if !ret || len(picked) != 1 {
|
||||||
t.Errorf("need to randomly pick 1 node")
|
t.Error("need to randomly pick 1 node")
|
||||||
}
|
}
|
||||||
|
|
||||||
picked, ret = nl.RandomlyPickN(4)
|
picked, ret = nl.RandomlyPickN(4)
|
||||||
if !ret || len(picked) != 4 {
|
if !ret || len(picked) != 4 {
|
||||||
t.Errorf("need to randomly pick 4 nodes")
|
t.Error("need to randomly pick 4 nodes")
|
||||||
}
|
}
|
||||||
|
|
||||||
picked, ret = nl.RandomlyPickN(5)
|
picked, ret = nl.RandomlyPickN(5)
|
||||||
if !ret || len(picked) != 5 {
|
if !ret || len(picked) != 5 {
|
||||||
t.Errorf("need to randomly pick 5 nodes")
|
t.Error("need to randomly pick 5 nodes")
|
||||||
}
|
}
|
||||||
|
|
||||||
picked, ret = nl.RandomlyPickN(6)
|
picked, ret = nl.RandomlyPickN(6)
|
||||||
if ret || len(picked) != 0 {
|
if ret || len(picked) != 0 {
|
||||||
t.Errorf("can not randomly pick 6 nodes:", ret, picked)
|
t.Error("can not randomly pick 6 nodes:", ret, picked)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ func batchVacuumVolumeCompact(vl *VolumeLayout, vid storage.VolumeId, locationli
|
||||||
ch := make(chan bool, locationlist.Length())
|
ch := make(chan bool, locationlist.Length())
|
||||||
for index, dn := range locationlist.list {
|
for index, dn := range locationlist.list {
|
||||||
go func(index int, url string, vid storage.VolumeId) {
|
go func(index int, url string, vid storage.VolumeId) {
|
||||||
fmt.Println(index, "Start vacuuming", vid, "on", dn.Url())
|
fmt.Println(index, "Start vacuuming", vid, "on", url)
|
||||||
if e := vacuumVolume_Compact(url, vid); e != nil {
|
if e := vacuumVolume_Compact(url, vid); e != nil {
|
||||||
fmt.Println(index, "Error when vacuuming", vid, "on", url, e)
|
fmt.Println(index, "Error when vacuuming", vid, "on", url, e)
|
||||||
ch <- false
|
ch <- false
|
||||||
|
|
|
@ -32,11 +32,11 @@ var cmdUpload = &Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssignResult struct {
|
type AssignResult struct {
|
||||||
Fid string "fid"
|
Fid string `json:"fid"`
|
||||||
Url string "url"
|
Url string `json:"url"`
|
||||||
PublicUrl string "publicUrl"
|
PublicUrl string `json:"publicUrl"`
|
||||||
Count int
|
Count int
|
||||||
Error string "error"
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func assign(count int) (*AssignResult, error) {
|
func assign(count int) (*AssignResult, error) {
|
||||||
|
@ -74,9 +74,9 @@ func upload(filename string, server string, fid string) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubmitResult struct {
|
type SubmitResult struct {
|
||||||
Fid string "fid"
|
Fid string `json:"fid"`
|
||||||
Size int "size"
|
Size int `json:"size"`
|
||||||
Error string "error"
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func submit(files []string) []SubmitResult {
|
func submit(files []string) []SubmitResult {
|
||||||
|
|
|
@ -242,7 +242,7 @@ func DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
n.Size = 0
|
n.Size = 0
|
||||||
ret, err := store.Delete(volumeId, n)
|
ret, err := store.Delete(volumeId, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("delete error: %s\n", err)
|
log.Println("delete error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue