Skip to content
/ gcsfs Public

go io/fs implementation on GCS (Google Cloud Storage)

License

Notifications You must be signed in to change notification settings

jarxorg/gcsfs

Repository files navigation

github.com/jarxorg/gcsfs

PkgGoDev Report Card

Package gcsfs provides an implementation of wfs for GCS (Google Cloud Storage).

Examples

ReadDir

package main

import (
  "fmt"
  "io/fs"
  "log"

  "github.com/jarxorg/gcsfs"
)

func main() {
  fsys := gcsfs.New("<your-bucket>")
  entries, err := fs.ReadDir(fsys, ".")
  if err != nil {
    log.Fatal(err)
  }
  for _, entry := range entries {
    fmt.Println(entry.Name())
  }
}

WriteFile

package main

import (
  "io/fs"
  "log"

  "github.com/jarxorg/wfs"
  "github.com/jarxorg/gcsfs"
)

func main() {
  fsys := gcsfs.New("<your-bucket>")
  _, err := wfs.WriteFile(fsys, "test.txt", []byte(`Hello`), fs.ModePerm)
  if err != nil {
    log.Fatal(err)
  }
}

Tests

GCSFS can pass TestFS in "testing/fstest".

import (
  "testing/fstest"

  "github.com/jarxorg/gcsfs"
)

// ...

fsys := gcsfs.New("<your-bucket>")
if err := fstest.TestFS(fsys, "<your-expected>"); err != nil {
  t.Errorf("Error testing/fstest: %+v", err)
}

Integration tests

FSTEST_BUCKET="<your-bucket>" \
FSTEST_EXPECTED="<your-expected>" \
  go test -tags integtest ./...

About

go io/fs implementation on GCS (Google Cloud Storage)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages