mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-14 12:48:44 +00:00
*.go: go-staticcheck linting
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
4760b77e54
commit
3bc8e48538
6 changed files with 6 additions and 42 deletions
|
@ -174,9 +174,7 @@ func keyValDifference(this, that []KeyVal) []KeyVal {
|
|||
}
|
||||
func keyValCopy(set []KeyVal) []KeyVal {
|
||||
ret := make([]KeyVal, len(set))
|
||||
for i := range set {
|
||||
ret[i] = set[i]
|
||||
}
|
||||
copy(ret, set)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package mtree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -42,7 +41,7 @@ func TestXattr(t *testing.T) {
|
|||
}
|
||||
|
||||
if err := xattr.Set(dir, "user.test", []byte("directory")); err != nil {
|
||||
t.Skip(fmt.Sprintf("skipping: %q does not support xattrs", dir))
|
||||
t.Skipf("skipping: %q does not support xattrs", dir)
|
||||
}
|
||||
if err := xattr.Set(filepath.Join(dir, "file"), "user.test", []byte("regular file")); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
26
tar.go
26
tar.go
|
@ -373,7 +373,6 @@ func flatten(root *Entry, creator *dhCreator, keywords []Keyword) {
|
|||
}
|
||||
creator.DH.Entries = append(creator.DH.Entries, dotEntry)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// resolveHardlinks goes through an Entry tree, and finds the Entry's associated
|
||||
|
@ -409,31 +408,6 @@ func resolveHardlinks(root *Entry, hardlinks map[string][]string, countlinks boo
|
|||
}
|
||||
}
|
||||
|
||||
// filter takes in a pointer to an Entry, and returns a slice of Entry's that
|
||||
// satisfy the predicate p
|
||||
func filter(root *Entry, p func(*Entry) bool) []Entry {
|
||||
if root != nil {
|
||||
var validEntrys []Entry
|
||||
if len(root.Children) > 0 || root.Prev != nil {
|
||||
for _, c := range root.Children {
|
||||
// filter the sub-directory
|
||||
if c.Prev != nil {
|
||||
validEntrys = append(validEntrys, filter(c, p)...)
|
||||
}
|
||||
if p(c) {
|
||||
if c.Prev == nil {
|
||||
validEntrys = append([]Entry{*c}, validEntrys...)
|
||||
} else {
|
||||
validEntrys = append(validEntrys, *c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return validEntrys
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ts *tarStream) setErr(err error) {
|
||||
ts.err = err
|
||||
}
|
||||
|
|
|
@ -336,12 +336,6 @@ type fakeFile struct {
|
|||
Xattrs map[string]string
|
||||
}
|
||||
|
||||
// minimal tar archive that mimics what is in ./testdata/test.tar
|
||||
var minimalFiles = []fakeFile{
|
||||
{"x/", "", 0755, '5', 0, 0, nil},
|
||||
{"x/files", "howdy\n", 0644, '0', 0, 0, nil},
|
||||
}
|
||||
|
||||
func makeTarStream(ff []fakeFile) ([]byte, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package mtree
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -32,7 +31,7 @@ func TestXattrUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
if err := xattr.Set(dir, "user.test", []byte("directory")); err != nil {
|
||||
t.Skip(fmt.Sprintf("skipping: %q does not support xattrs", dir))
|
||||
t.Skipf("skipping: %q does not support xattrs", dir)
|
||||
}
|
||||
if err := xattr.Set(tmpfn, "user.test", []byte("regular file")); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
6
walk.go
6
walk.go
|
@ -103,7 +103,7 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
}
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
return fmt.Errorf("unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
|
@ -138,7 +138,7 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
}
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
return fmt.Errorf("unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
|
@ -198,7 +198,7 @@ func Walk(root string, excludes []ExcludeFunc, keywords []Keyword, fsEval FsEval
|
|||
}
|
||||
keyFunc, ok := KeywordFuncs[keyword.Prefix()]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
return fmt.Errorf("unknown keyword %q for file %q", keyword.Prefix(), path)
|
||||
}
|
||||
kvs, err := creator.fs.KeywordFunc(keyFunc)(path, info, r)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue