store

package
v0.0.0-...-692212b Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(filename string) (*os.File, error)

Append open file in append mode, create is not exist

func Create

func Create(filename string) (*os.File, error)

Create creates the named file with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.

func DataPath

func DataPath(sub string) string

func LoadState

func LoadState(dir, name string, v interface{}) (err error)

LoadState load v from {store}/dir/name.json, use json.Unmarshal

func MkdirAll

func MkdirAll(dir string) error

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error.

func Open

func Open(filename string) (file *os.File, err error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func ReadDir

func ReadDir(dir string) ([]os.FileInfo, error)

ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.

func ReadFile

func ReadFile(filename string) (b []byte, err error)

ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.

func Remove

func Remove(name string) error

Remove removes the named file or directory. If there is an error, it will be of type *PathError.

func ResPath

func ResPath(sub string) string

func SaveState

func SaveState(dir, name string, v interface{}) (err error)

SaveState save v to {store}/dir/name.json, use json.MarshalIndent.

func Stat

func Stat(name string) (info os.FileInfo, err error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError.

func Truncate

func Truncate(name string, size int64) error

Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target. If there is an error, it will be of type *PathError.

func WriteFile

func WriteFile(filename string, data []byte) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm; otherwise WriteFile truncates it before writing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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