Package s3fs provides an implementation of wfs for S3.
package main
import (
"fmt"
"io/fs"
"log"
"github.com/jarxorg/s3fs"
)
func main() {
fsys := s3fs.New("<your-bucket>")
entries, err := fs.ReadDir(fsys, ".")
if err != nil {
log.Fatal(err)
}
for _, entry := range entries {
fmt.Println(entry.Name())
}
}
package main
import (
"io/fs"
"log"
"github.com/jarxorg/wfs"
"github.com/jarxorg/s3fs"
)
func main() {
fsys := s3fs.New("<your-bucket>")
_, err := wfs.WriteFile(fsys, "test.txt", []byte(`Hello`), fs.ModePerm)
if err != nil {
log.Fatal(err)
}
}
S3FS can pass TestFS in "testing/fstest".
import (
"testing/fstest"
"github.com/jarxorg/s3fs"
)
// ...
fsys := s3fs.New("<your-bucket>")
if err := fstest.TestFS(fsys, "<your-expected>"); err != nil {
t.Errorf("Error testing/fstest: %+v", err)
}
FSTEST_BUCKET="<your-bucket>" \
FSTEST_EXPECTED="<your-expected>" \
go test -tags integtest ./...