Add Go Mod

This commit is contained in:
Quentin 2021-04-26 17:21:03 +02:00
parent a25e9930f5
commit 651dc950dd
Signed by: quentin
GPG key ID: A98E9B769E4FF428
6 changed files with 80 additions and 26 deletions

View file

@ -4,7 +4,6 @@ import(
"log"
"os"
"io"
"path/filepath"
)
func cmdHead(config *configCollect) {
@ -30,13 +29,6 @@ func cmdHead(config *configCollect) {
}
type LsWalker struct { }
func (lw* LsWalker) onDir(dn *DirNode) {
log.Println(dn.String())
}
func (lw* LsWalker) onFile(fn *FileNode) {
log.Println(fn.String())
}
func cmdLs(config *configCollect) {
en := NewEntryNode(config)
en.Walk(new(LsWalker))
@ -62,24 +54,6 @@ func cmdCpFile(config *configCollect) {
}
}
type CopyWalker struct { }
func (cw* CopyWalker) onDir(dn *DirNode) {
err := os.MkdirAll(filepath.Join(dn.Config.Dest, dn.AbsolutePath), os.ModePerm)
if err != nil { log.Fatal(err) }
log.Println(dn.String())
}
func (cw* CopyWalker) onFile(fn *FileNode) {
fn.Parse()
file, err := os.Create(filepath.Join(fn.Config.Dest, fn.AbsolutePath))
if err != nil { log.Fatal(err) }
defer file.Close()
written, err := io.Copy(file, fn)
if err != nil { log.Fatal(err) }
if uint64(written) != fn.Elem.FileSize {
log.Fatal(written, "bytes written,", fn.Elem.FileSize, "bytes expected")
}
log.Println(fn.String())
}
func cmdCpDir(config *configCollect) {
en := NewEntryNode(config)
en.Walk(new(CopyWalker))

27
copy_walker.go Normal file
View file

@ -0,0 +1,27 @@
package main
import (
"log"
"os"
"path/filepath"
"io"
)
type CopyWalker struct { }
func (cw* CopyWalker) onDir(dn *DirNode) {
err := os.MkdirAll(filepath.Join(dn.Config.Dest, dn.AbsolutePath), os.ModePerm)
if err != nil { log.Fatal(err) }
log.Println(dn.String())
}
func (cw* CopyWalker) onFile(fn *FileNode) {
fn.Parse()
file, err := os.Create(filepath.Join(fn.Config.Dest, fn.AbsolutePath))
if err != nil { log.Fatal(err) }
defer file.Close()
written, err := io.Copy(file, fn)
if err != nil { log.Fatal(err) }
if uint64(written) != fn.Elem.FileSize {
log.Fatal(written, "bytes written,", fn.Elem.FileSize, "bytes expected")
}
log.Println(fn.String())
}

8
go.mod Normal file
View file

@ -0,0 +1,8 @@
module git.deuxfleurs.fr/quentin/seafile_recovery
go 1.15
require (
github.com/aws/aws-sdk-go v1.38.25
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
)

23
go.sum Normal file
View file

@ -0,0 +1,23 @@
github.com/aws/aws-sdk-go v1.38.25 h1:aNjeh7+MON05cZPtZ6do+KxVT67jPOSQXANA46gOQao=
github.com/aws/aws-sdk-go v1.38.25/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

11
ls_walker.go Normal file
View file

@ -0,0 +1,11 @@
package main
import ("log")
type LsWalker struct { }
func (lw* LsWalker) onDir(dn *DirNode) {
log.Println(dn.String())
}
func (lw* LsWalker) onFile(fn *FileNode) {
log.Println(fn.String())
}

11
s3_walker.go Normal file
View file

@ -0,0 +1,11 @@
package main
import (
"github.com/aws/aws-sdk-go/service/s3"
)
type S3Walker struct { }
func (sw* S3Walker) onDir(dn *DirNode) {
}
func (sw* S3Walker) onFile(fn *FileNode) {
}