Categorygithub.com/koscom-cloud/pathio
modulepackage
3.7.1+incompatible
Repository: https://github.com/koscom-cloud/pathio.git
Documentation: pkg.go.dev

# README

pathio

GoDoc

-- import "gopkg.in/Clever/pathio.v3"

Package pathio is a package that allows writing to and reading from different types of paths transparently. It supports two types of paths:

1. Local file paths
2. S3 File Paths (s3://bucket/key)

Note that using s3 paths requires setting two environment variables

1. AWS_SECRET_ACCESS_KEY
2. AWS_ACCESS_KEY_ID

Usage

Pathio has a very easy to use interface, with 5 main functions:

import "gopkg.in/Clever/pathio.v3"
var err error

ListFiles

// func ListFiles(path string) ([]string, error)
files, err = pathio.ListFiles("s3://bucket/my/key") // s3
files, err = pathio.ListFiles("/home/me")           // local

Write / WriteReader

// func Write(path string, input []byte) error
toWrite := []byte("hello world\n")
err = pathio.Write("s3://bucket/my/key", toWrite)   // s3
err = pathio.Write("/home/me/hello_world", toWrite) // local

// func WriteReader(path string, input io.ReadSeeker) error
toWriteReader, err := os.Open("test.txt") // this implements Read and Seek
err = pathio.WriteReader("s3://bucket/my/key", toWriteReader)   // s3
err = pathio.WriteReader("/home/me/hello_world", toWriteReader) // local

Read

// func Reader(path string) (rc io.ReadCloser, err error)
reader, err = pathio.Reader("s3://bucket/key/to/read") // s3
reader, err = pathio.Reader("/home/me/file/to/read")   // local

Delete

// func Delete(path string) error
err = pathio.Delete("s3://bucket/key/to/read") // s3
err = pathio.Delete("/home/me/file/to/read")   // local

# Packages

No description provided by the author

# Functions

Delete calls DefaultClient's Delete method.
Exists calls DefaultClient's Exists method.
ListFiles calls DefaultClient's ListFiles method.
NewClient creates a new client that utilizes the provided AWS config.
NewMockPathio creates a new mock instance.
NewMocks3Handler creates a new mock instance.
Reader calls DefaultClient's Reader method.
Write calls DefaultClient's Write method.
WriteReader calls DefaultClient's WriteReader method.

# Variables

DefaultClient is the default pathio client called by the Reader, Writer, and WriteReader methods.

# Structs

Client is the pathio client used to access the local file system and S3.
MockPathio is a mock of Pathio interface.
MockPathioMockRecorder is the mock recorder for MockPathio.
Mocks3Handler is a mock of s3Handler interface.
Mocks3HandlerMockRecorder is the mock recorder for Mocks3Handler.

# Interfaces

Pathio is a defined interface for accessing both S3 and local files.