fly

package module
v0.0.0-...-461a674 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2017 License: MIT Imports: 1 Imported by: 0

README

Fly Build Status GoDoc Go Report Card

Work In Progress

Fly is inspired by Flysystem. Fly is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.

Installation

$ go get -u github.com/frozzare/go-fly

Adapters

  • AWS S3
  • Local

Example

package main

import (
    "fmt"
    "log"
    
    "github.com/frozzare/go-fly"
    "github.com/frozzare/go-fly/adapter/flylocal"
)

func main() {
	fs := fly.NewFly(flylocal.NewAdapter("/tmp/fly"))

	if err := fs.Write("test/file.txt", "Hello, world!"); err != nil {
		log.Fatal(err)
	}

	content, err := fs.Read("test/file.txt")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(content)
	// Hello, world!
}

License

MIT © Fredrik Forsmo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filesystem

type Filesystem struct {
	// contains filtered or unexported fields
}

Filesystem repretents a fly filesystem.

func NewFly

func NewFly(adapter adapter.Adapter) *Filesystem

NewFly creates a new filesystem struct.

func (*Filesystem) Copy

func (f *Filesystem) Copy(src string, dst string) error

Copy will copy a file from source path to destionation path.

func (*Filesystem) CreateDir

func (f *Filesystem) CreateDir(path string, args ...interface{}) error

CreateDir creates a new directory.

func (*Filesystem) Delete

func (f *Filesystem) Delete(path string) error

Delete will delete a file from source path.

func (*Filesystem) DeleteDir

func (f *Filesystem) DeleteDir(path string) error

DeleteDir will delete a directory.

func (*Filesystem) Has

func (f *Filesystem) Has(path string) (bool, error)

Has will check if a file exists.

func (*Filesystem) HasDir

func (f *Filesystem) HasDir(path string) (bool, error)

HasDir will check if a directory exists.

func (*Filesystem) MimeType

func (f *Filesystem) MimeType(path string) (string, error)

MimeType will return the file mime type.

func (*Filesystem) Read

func (f *Filesystem) Read(path string) (string, error)

Read will read file content.

func (*Filesystem) ReadAndDelete

func (f *Filesystem) ReadAndDelete(path string) (string, error)

ReadAndDelete will read file content and then delete the file.

func (*Filesystem) Rename

func (f *Filesystem) Rename(src string, dst string) error

Rename will rename a file.

func (*Filesystem) Write

func (f *Filesystem) Write(path, content string, args ...interface{}) error

Write will write content to a file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL