Documentation
¶
Index ¶
- type Api
- type AssetDirFunc
- type AssetFunc
- type AssetInfoFunc
- type Dir
- func (d *Dir) Close() error
- func (d *Dir) Name() string
- func (d *Dir) Read([]byte) (int, error)
- func (d *Dir) ReadAt([]byte, int64) (int, error)
- func (d *Dir) Readdir(n int) (out []os.FileInfo, err error)
- func (d *Dir) Readdirnames(int) ([]string, error)
- func (d *Dir) Seek(int64, int) (int64, error)
- func (d *Dir) Stat() (os.FileInfo, error)
- func (d *Dir) Sync() error
- func (d *Dir) Truncate(int64) error
- func (d *Dir) Write([]byte) (int, error)
- func (d *Dir) WriteAt([]byte, int64) (int, error)
- func (d *Dir) WriteString(string) (int, error)
- type File
- func (f *File) Close() error
- func (f *File) Name() string
- func (f *File) Readdir(int) ([]os.FileInfo, error)
- func (f *File) Readdirnames(int) ([]string, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(int64) error
- func (f *File) Write([]byte) (int, error)
- func (f *File) WriteAt([]byte, int64) (int, error)
- func (f *File) WriteString(string) (int, error)
- type Fs
- func (fs *Fs) Asset(name string) ([]byte, error)
- func (fs *Fs) AssetDir(name string) ([]string, error)
- func (fs *Fs) AssetInfo(name string) (os.FileInfo, error)
- func (fs *Fs) Chmod(string, os.FileMode) error
- func (fs *Fs) Chtimes(string, time.Time, time.Time) error
- func (fs *Fs) Create(string) (afero.File, error)
- func (fs *Fs) Mkdir(string, os.FileMode) error
- func (fs *Fs) MkdirAll(string, os.FileMode) error
- func (fs *Fs) Name() string
- func (fs *Fs) Open(name string) (afero.File, error)
- func (fs *Fs) OpenFile(name string, flag int, mode os.FileMode) (afero.File, error)
- func (fs *Fs) Remove(string) error
- func (fs *Fs) RemoveAll(string) error
- func (fs *Fs) Rename(string, string) error
- func (fs *Fs) Stat(name string) (os.FileInfo, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetDirFunc ¶
type Fs ¶
type Fs struct {
AssetFunc
AssetDirFunc
AssetInfoFunc
}
Example ¶
package main
import (
"fmt"
"io/ioutil"
"log"
bindatafs "github.com/jncornett/afero-bindatafs"
"github.com/spf13/afero"
)
var (
Asset bindatafs.AssetFunc
AssetDir bindatafs.AssetDirFunc
AssetInfo bindatafs.AssetInfoFunc
)
func main() {
var fs afero.Fs = &bindatafs.Fs{
AssetFunc: Asset,
AssetInfoFunc: AssetInfo,
AssetDirFunc: AssetDir,
}
f, err := fs.Open("data/a.txt")
if err != nil {
log.Fatal(err)
}
defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}
fmt.Println("contents of file:", string(b))
}
Output:
Click to show internal directories.
Click to hide internal directories.