From a91d253f253ccc2ee30a4f748ef2657be08f1b07 Mon Sep 17 00:00:00 2001 From: matfax Date: Thu, 2 Aug 2018 14:51:29 +0200 Subject: [PATCH] Updated config and cleaned up code --- .gitignore | 1 + .idea/afero.iml | 8 ++++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 ++++ Gopkg.lock | 111 ++++++++++++++++++++++++++++++++++++++++++++ Gopkg.toml | 50 ++++++++++++++++++++ README.md | 48 ++++--------------- afero_test.go | 2 +- appveyor.yml | 15 ------ memmap.go | 7 +-- sftpfs/sftp.go | 2 +- zipfs/file.go | 10 ++-- zipfs/fs.go | 2 +- zipfs/zipfs_test.go | 2 +- 14 files changed, 206 insertions(+), 66 deletions(-) create mode 100644 .idea/afero.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml delete mode 100644 appveyor.yml diff --git a/.gitignore b/.gitignore index 546a551e..ca45fbc8 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ $RECYCLE.BIN/ *.dll *.so *.dylib +vendor/ # Test binary, build with `go test -c` *.test diff --git a/.idea/afero.iml b/.idea/afero.iml new file mode 100644 index 00000000..c956989b --- /dev/null +++ b/.idea/afero.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..28a804d8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..1e080f3a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 00000000..95844172 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,111 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "cloud.google.com/go" + packages = ["compute/metadata","iam","internal","internal/optional","internal/trace","internal/version","storage"] + revision = "aad3f485ee528456e0768f20397b4d9dd941e755" + version = "v0.25.0" + +[[projects]] + name = "github.com/golang/protobuf" + packages = ["proto","protoc-gen-go/descriptor","ptypes","ptypes/any","ptypes/duration","ptypes/timestamp"] + revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" + version = "v1.1.0" + +[[projects]] + name = "github.com/googleapis/gax-go" + packages = ["."] + revision = "317e0006254c44a0ac427cc52a0e083ff0b9622f" + version = "v2.0.0" + +[[projects]] + name = "github.com/kr/fs" + packages = ["."] + revision = "1455def202f6e05b95cc7bfc7e8ae67ae5141eba" + version = "v0.1.0" + +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + +[[projects]] + name = "github.com/pkg/sftp" + packages = ["."] + revision = "6b9fa10dea25176501bd80eb8a45a46d2afc97ad" + version = "v1.8.1" + +[[projects]] + branch = "master" + name = "github.com/zatte/afero" + packages = ["gcs"] + revision = "b737c2a2e12dbb3a10a75aec9ee0527b29c2a9fc" + +[[projects]] + name = "go.opencensus.io" + packages = [".","exporter/stackdriver/propagation","internal","internal/tagencoding","plugin/ochttp","plugin/ochttp/propagation/b3","stats","stats/internal","stats/view","tag","trace","trace/internal","trace/propagation"] + revision = "e262766cd0d230a1bb7c37281e345e465f19b41b" + version = "v0.14.0" + +[[projects]] + branch = "master" + name = "golang.org/x/crypto" + packages = ["curve25519","ed25519","ed25519/internal/edwards25519","internal/chacha20","internal/subtle","poly1305","ssh"] + revision = "c126467f60eb25f8f27e5a981f32a87e3965053f" + +[[projects]] + branch = "master" + name = "golang.org/x/net" + packages = ["context","context/ctxhttp","http/httpguts","http2","http2/hpack","idna","internal/timeseries","trace"] + revision = "f4c29de78a2a91c00474a2e689954305c350adf9" + +[[projects]] + branch = "master" + name = "golang.org/x/oauth2" + packages = [".","google","internal","jws","jwt"] + revision = "3d292e4d0cdc3a0113e6d207bb137145ef1de42f" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = ["unix"] + revision = "3dc4335d56c789b04b0ba99b7a37249d9b614314" + +[[projects]] + name = "golang.org/x/text" + packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"] + revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" + version = "v0.3.0" + +[[projects]] + branch = "master" + name = "google.golang.org/api" + packages = ["gensupport","googleapi","googleapi/internal/uritemplates","googleapi/transport","internal","iterator","option","storage/v1","transport/http"] + revision = "31ca0e01cd791f07750cb23fc99327721f753290" + +[[projects]] + name = "google.golang.org/appengine" + packages = [".","internal","internal/app_identity","internal/base","internal/datastore","internal/log","internal/modules","internal/remote_api","internal/urlfetch","urlfetch"] + revision = "b1f26356af11148e710935ed1ac8a7f5702c7612" + version = "v1.1.0" + +[[projects]] + branch = "master" + name = "google.golang.org/genproto" + packages = ["googleapis/api/annotations","googleapis/iam/v1","googleapis/rpc/code","googleapis/rpc/status"] + revision = "daca94659cb50e9f37c1b834680f2e46358f10b0" + +[[projects]] + name = "google.golang.org/grpc" + packages = [".","balancer","balancer/base","balancer/roundrobin","codes","connectivity","credentials","encoding","encoding/proto","grpclog","internal","internal/backoff","internal/channelz","internal/envconfig","internal/grpcrand","internal/transport","keepalive","metadata","naming","peer","resolver","resolver/dns","resolver/passthrough","stats","status","tap"] + revision = "32fb0ac620c32ba40a4626ddf94d90d12cce3455" + version = "v1.14.0" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "2e93c30b5d1b77f3bf86a57bb39e230baba1809289c76b58edf1f981aa30cbb2" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 00000000..cfdd60a0 --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,50 @@ + +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + + +[[constraint]] + name = "cloud.google.com/go" + version = "0.25.0" + +[[constraint]] + name = "github.com/pkg/sftp" + version = "1.8.1" + +[[constraint]] + name = "github.com/spf13/afero" + version = "1.1.1" + +[[constraint]] + branch = "master" + name = "github.com/zatte/afero" + +[[constraint]] + branch = "master" + name = "golang.org/x/net" + +[[constraint]] + name = "golang.org/x/text" + version = "0.3.0" + +[[constraint]] + branch = "master" + name = "google.golang.org/api" diff --git a/README.md b/README.md index 0c9b04b5..15202e42 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ A FileSystem Abstraction System for Go -[![Build Status](https://travis-ci.org/spf13/afero.svg)](https://travis-ci.org/spf13/afero) [![Build status](https://ci.appveyor.com/api/projects/status/github/spf13/afero?branch=master&svg=true)](https://ci.appveyor.com/project/spf13/afero) [![GoDoc](https://godoc.org/github.com/spf13/afero?status.svg)](https://godoc.org/github.com/spf13/afero) [![Join the chat at https://gitter.im/spf13/afero](https://badges.gitter.im/Dev%20Chat.svg)](https://gitter.im/spf13/afero?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://travis-ci.org/gofunky/afero.svg)](https://travis-ci.org/gofunky/afero) +[![Build status](https://ci.appveyor.com/api/projects/status/github/gofunky/afero?branch=master&svg=true)](https://ci.appveyor.com/project/gofunky/afero) [![GoDoc](https://godoc.org/github.com/gofunky/afero?status.svg)](https://godoc.org/github.com/gofunky/afero) +[![Go Report Card](https://goreportcard.com/badge/github.com/gofunky/afero)](https://goreportcard.com/report/github.com/gofunky/afero) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e64fc666a8bc43c2b5fd5f5fa771156a)](https://www.codacy.com/app/gofunky/afero?utm_source=github.com&utm_medium=referral&utm_content=gofunky/afero&utm_campaign=Badge_Grade) # Overview @@ -46,15 +49,15 @@ A few different ways you could use Afero: * Define different filesystems for different parts of your application. * Use Afero for mock filesystems while testing -## Step 1: Install Afero +## Step 1: Get Afero First use go get to install the latest version of the library. - $ go get github.com/spf13/afero + $ go get github.com/gofunky/afero Next include Afero in your application. ```go -import "github.com/spf13/afero" +import "github.com/gofunky/afero" ``` ## Step 2: Declare a backend @@ -151,7 +154,7 @@ Walk(root string, walkFn filepath.WalkFunc) error WriteFile(filename string, data []byte, perm os.FileMode) error WriteReader(path string, r io.Reader) (err error) ``` -For a complete list see [Afero's GoDoc](https://godoc.org/github.com/spf13/afero) +For a complete list see [Afero's GoDoc](https://godoc.org/github.com/gofunky/afero) They are available under two different approaches to use. You can either call them directly where the first parameter of each function will be the file @@ -404,39 +407,6 @@ object of a particular type". It's also nice that unlike some of my other libraries (hugo, cobra, viper) it Googles very well. -## Release Notes - -* **0.10.0** 2015.12.10 - * Full compatibility with Windows - * Introduction of afero utilities - * Test suite rewritten to work cross platform - * Normalize paths for MemMapFs - * Adding Sync to the file interface - * **Breaking Change** Walk and ReadDir have changed parameter order - * Moving types used by MemMapFs to a subpackage - * General bugfixes and improvements -* **0.9.0** 2015.11.05 - * New Walk function similar to filepath.Walk - * MemMapFs.OpenFile handles O_CREATE, O_APPEND, O_TRUNC - * MemMapFs.Remove now really deletes the file - * InMemoryFile.Readdir and Readdirnames work correctly - * InMemoryFile functions lock it for concurrent access - * Test suite improvements -* **0.8.0** 2014.10.28 - * First public version - * Interfaces feel ready for people to build using - * Interfaces satisfy all known uses - * MemMapFs passes the majority of the OS test suite - * OsFs passes the majority of the OS test suite - -## Contributing - -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request - ## Contributors Names in no particular order: @@ -449,4 +419,4 @@ Names in no particular order: ## License Afero is released under the Apache 2.0 license. See -[LICENSE.txt](https://github.com/spf13/afero/blob/master/LICENSE.txt) +[LICENSE.txt](https://github.com/gofunky/afero/blob/master/LICENSE.txt) diff --git a/afero_test.go b/afero_test.go index e2c13624..787d8c4a 100644 --- a/afero_test.go +++ b/afero_test.go @@ -570,7 +570,7 @@ func TestReaddir(t *testing.T) { } } -// https://github.com/spf13/afero/issues/169 +// https://github.com/gofunky/afero/issues/169 func TestReaddirRegularFile(t *testing.T) { defer removeAllTestFiles(t) for _, fs := range Fss { diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a633ad50..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '{build}' -clone_folder: C:\gopath\src\github.com\spf13\afero -environment: - GOPATH: C:\gopath -build_script: -- cmd: >- - go version - - go env - - go get -v github.com/spf13/afero/... - - go build github.com/spf13/afero -test_script: -- cmd: go test -race -v github.com/spf13/afero/... diff --git a/memmap.go b/memmap.go index 8d163dfb..ba85b355 100644 --- a/memmap.go +++ b/memmap.go @@ -22,7 +22,8 @@ import ( "sync" "time" - "github.com/spf13/afero/mem" + "github.com/gofunky/afero/mem" + "io" ) type MemMapFs struct { @@ -228,7 +229,7 @@ func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, erro file = mem.NewReadOnlyFileHandle(file.(*mem.File).Data()) } if flag&os.O_APPEND > 0 { - _, err = file.Seek(0, os.SEEK_END) + _, err = file.Seek(0, io.SeekEnd) if err != nil { file.Close() return nil, err @@ -274,7 +275,7 @@ func (m *MemMapFs) RemoveAll(path string) error { m.mu.RLock() defer m.mu.RUnlock() - for p, _ := range m.getData() { + for p := range m.getData() { if strings.HasPrefix(p, path) { m.mu.RUnlock() m.mu.Lock() diff --git a/sftpfs/sftp.go b/sftpfs/sftp.go index e41df68c..1f31363b 100644 --- a/sftpfs/sftp.go +++ b/sftpfs/sftp.go @@ -17,8 +17,8 @@ import ( "os" "time" + "github.com/gofunky/afero" "github.com/pkg/sftp" - "github.com/spf13/afero" ) // Fs is a afero.Fs implementation that uses functions provided by the sftp package. diff --git a/zipfs/file.go b/zipfs/file.go index 2841227f..a966e7c9 100644 --- a/zipfs/file.go +++ b/zipfs/file.go @@ -7,7 +7,7 @@ import ( "path/filepath" "syscall" - "github.com/spf13/afero" + "github.com/gofunky/afero" ) type File struct { @@ -84,10 +84,10 @@ func (f *File) Seek(offset int64, whence int) (int64, error) { return 0, afero.ErrFileClosed } switch whence { - case os.SEEK_SET: - case os.SEEK_CUR: + case io.SeekStart: + case io.SeekCurrent: offset += f.offset - case os.SEEK_END: + case io.SeekEnd: offset += int64(f.zipfile.UncompressedSize64) default: return 0, syscall.EINVAL @@ -139,7 +139,7 @@ func (f *File) Readdirnames(count int) (names []string, err error) { if err != nil { return nil, err } - for filename, _ := range zipfiles { + for filename := range zipfiles { names = append(names, filename) if count >= 0 && len(names) >= count { break diff --git a/zipfs/fs.go b/zipfs/fs.go index 72887f9c..4f4f8b82 100644 --- a/zipfs/fs.go +++ b/zipfs/fs.go @@ -7,7 +7,7 @@ import ( "syscall" "time" - "github.com/spf13/afero" + "github.com/gofunky/afero" ) type Fs struct { diff --git a/zipfs/zipfs_test.go b/zipfs/zipfs_test.go index 02ac6b63..c22d2508 100644 --- a/zipfs/zipfs_test.go +++ b/zipfs/zipfs_test.go @@ -1,7 +1,7 @@ package zipfs import ( - "github.com/spf13/afero" + "github.com/gofunky/afero" "archive/zip" "path/filepath"