diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index db1edf6..1bc42c6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,22 +1,25 @@ name: Build and Test on: [push, pull_request] +permissions: + contents: read + jobs: build: name: Go CI runs-on: ubuntu-latest strategy: matrix: - go: [1.16, 1.17] + go: ['1.19', '1.20'] steps: - name: Set up Go - uses: actions/setup-go@331ce1d993939866bb63c32c6cbbfd48fa76fc57 #v2 + uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 #v4.0.1 with: go-version: ${{ matrix.go }} - name: Check out source - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f #v2.3.4 + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2 - name: Install Linters - run: "curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0" + run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2" - name: Build run: go build ./... - name: Lint - run: golangci-lint run --disable-all --deadline=10m --enable=gofmt --enable=revive --enable=govet --enable=gosimple --enable=ineffassign + run: golangci-lint run diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e5a16d1 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,28 @@ +run: + deadline: 10m + build-tags: + +linters: + disable-all: true + enable: + - asciicheck + - bidichk + - bodyclose + - durationcheck + - errchkjson + - exportloopref + - gofmt + - goimports + - gosimple + - govet + - grouper + - ineffassign + - misspell + - nosprintfhostport + - reassign + - rowserrcheck + - tparallel + - typecheck + - unconvert + - unused + - vetshadow diff --git a/appdata.go b/appdata.go index 0c029f6..17f6f8e 100644 --- a/appdata.go +++ b/appdata.go @@ -96,11 +96,12 @@ func appDataDir(goos, appName string, roaming bool) string { // (%LOCALAPPDATA%) that is used by default. // // Example results: -// dir := AppDataDir("myapp", false) -// POSIX (Linux/BSD): ~/.myapp -// Mac OS: $HOME/Library/Application Support/Myapp -// Windows: %LOCALAPPDATA%\Myapp -// Plan 9: $home/myapp +// +// dir := AppDataDir("myapp", false) +// POSIX (Linux/BSD): ~/.myapp +// Mac OS: $HOME/Library/Application Support/Myapp +// Windows: %LOCALAPPDATA%\Myapp +// Plan 9: $home/myapp func AppDataDir(appName string, roaming bool) string { return appDataDir(runtime.GOOS, appName, roaming) } diff --git a/go.mod b/go.mod index 7578e2d..4cfcaeb 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module multus -go 1.17 +go 1.19 require ( github.com/jrick/ss v0.9.1 - github.com/smtc/rsync v0.0.0-20151014010438-0a038bb0deb8 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 + github.com/smtc/rsync v0.0.0-00010101000000-000000000000 + golang.org/x/sync v0.3.0 + golang.org/x/term v0.9.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -15,8 +15,8 @@ require ( github.com/dchest/blake2b v1.0.0 // indirect github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100 // indirect github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967 // indirect - golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect - golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/sys v0.9.0 // indirect ) replace github.com/smtc/rsync => github.com/dajohi/rsync v0.0.0-20220210212722-7c40f7496082 diff --git a/go.sum b/go.sum index 987185b..8879f3f 100644 --- a/go.sum +++ b/go.sum @@ -10,22 +10,14 @@ github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100 h1:i0RlfVCicU2hdE7lSl github.com/smtc/rollsum v0.0.0-20150721100732-39e98d252100/go.mod h1:6sQHUq9MNR2x9+cpk8+oegntSXGnXHopnOv92j2tikk= github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967 h1:W1sTuG/sEqqum0BZ6bI1V++UqMJ+dxoeX7Biz7EarmE= github.com/smtc/seekbuffer v0.0.0-20151009054628-711359748967/go.mod h1:yaoAwyoO9sNREC+8EVI+DgdGfUpMTVR9XzqxS7yGRF4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI= -golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/multus-agent/appdata.go b/multus-agent/appdata.go index 0c029f6..17f6f8e 100644 --- a/multus-agent/appdata.go +++ b/multus-agent/appdata.go @@ -96,11 +96,12 @@ func appDataDir(goos, appName string, roaming bool) string { // (%LOCALAPPDATA%) that is used by default. // // Example results: -// dir := AppDataDir("myapp", false) -// POSIX (Linux/BSD): ~/.myapp -// Mac OS: $HOME/Library/Application Support/Myapp -// Windows: %LOCALAPPDATA%\Myapp -// Plan 9: $home/myapp +// +// dir := AppDataDir("myapp", false) +// POSIX (Linux/BSD): ~/.myapp +// Mac OS: $HOME/Library/Application Support/Myapp +// Windows: %LOCALAPPDATA%\Myapp +// Plan 9: $home/myapp func AppDataDir(appName string, roaming bool) string { return appDataDir(runtime.GOOS, appName, roaming) } diff --git a/multus-agent/cleanup.go b/multus-agent/cleanup.go index 862c026..43d7177 100644 --- a/multus-agent/cleanup.go +++ b/multus-agent/cleanup.go @@ -6,18 +6,12 @@ import ( "log" "os" "path/filepath" - "regexp" "sort" "strconv" "strings" "time" ) -var ( - fileRexp = regexp.MustCompile(`\.gz\.enc$`) - hashRexp = regexp.MustCompile(`[[:xdigit:]]{64}`) -) - type File struct { Path string Timestamp time.Time @@ -43,23 +37,23 @@ func genTimestamp(name string) (time.Time, error) { return time.Time{}, fmt.Errorf("invalid filename") } - year, err := strconv.ParseInt(string(name[0:4]), 10, 64) + year, err := strconv.ParseInt(name[0:4], 10, 64) if err != nil { return time.Time{}, err } - month, err := strconv.ParseInt(string(name[4:6]), 10, 64) + month, err := strconv.ParseInt(name[4:6], 10, 64) if err != nil { return time.Time{}, err } - day, err := strconv.ParseInt(string(name[6:8]), 10, 64) + day, err := strconv.ParseInt(name[6:8], 10, 64) if err != nil { return time.Time{}, err } - hour, err := strconv.ParseInt(string(name[8:10]), 10, 64) + hour, err := strconv.ParseInt(name[8:10], 10, 64) if err != nil { return time.Time{}, err } - min, err := strconv.ParseInt(string(name[10:12]), 10, 64) + min, err := strconv.ParseInt(name[10:12], 10, 64) if err != nil { return time.Time{}, err } diff --git a/types.go b/types.go index 1b3d525..a9fe89d 100644 --- a/types.go +++ b/types.go @@ -370,7 +370,7 @@ func NewMetadata(filepath string) (*Metadata, error) { Mode: uint32(stat.Mode()), UID: statT.Uid, GID: statT.Gid, - RDev: uint64(statT.Rdev), + RDev: statT.Rdev, } MD := Metadata{ Attribs: fileAttributes, diff --git a/util.go b/util.go index 0de32b9..8fbaaae 100644 --- a/util.go +++ b/util.go @@ -32,6 +32,7 @@ func isSymlink(filemode os.FileMode) bool { return filemode&os.ModeSymlink == os.ModeSymlink } +/* func major(rdev uint64) uint64 { return (rdev >> 8) & 0xff } @@ -39,6 +40,7 @@ func major(rdev uint64) uint64 { func minor(rdev uint64) uint64 { return (rdev & 0xff) | ((rdev & 0xffff0000) >> 8) } +*/ func signatureFromReader(dstBuf *bytes.Buffer, fd io.ReadSeeker, len int64) error { // Save the current offset