Installation

Install the Go module and import the provider package for the storage backend you use.

Install the module

Run go get from your application module:

go get github.com/cersho/gofiles-sdk

The module requires Go 1.26 or newer.

Choose a provider

Provider packages are part of the same module. Import only the adapter you need:

import (
	files "github.com/cersho/gofiles-sdk"
	"github.com/cersho/gofiles-sdk/providers/s3"
)

The AWS SDK dependency is already declared in go.mod for S3-backed adapters.

Verify the install

Create a small program with the memory adapter:

package main

import (
	"context"
	"fmt"

	files "github.com/cersho/gofiles-sdk"
	"github.com/cersho/gofiles-sdk/providers/memory"
)

func main() {
	ctx := context.Background()
	client := files.MustNew(files.Options{
		Adapter: memory.New(memory.Options{}),
	})

	result, err := client.Upload(ctx, "checks/install.txt", files.StringBody("ok"), files.UploadOptions{})
	if err != nil {
		panic(err)
	}

	fmt.Println(result.Key)
	// Output: checks/install.txt
}

Run it:

go run .

Provider setup

Use the provider pages for adapter-specific options and environment variables:

On this page