Documentation ¶
Index ¶
- func DeserializeFromJSONFile(path string, objPtr interface{}) error
- func IsExist(err error) bool
- func IsNotExist(err error) bool
- func Lstat(name string) (os.FileInfo, error)
- func Mkdir(path string, perm os.FileMode) error
- func MkdirAll(path string, perm os.FileMode) error
- func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func ReadAll(r io.Reader) ([]byte, error)
- func ReadDir(dirname string) ([]os.FileInfo, error)
- func ReadFile(filename string) ([]byte, error)
- func Remove(name string) error
- func RemoveAll(name string) error
- func Rename(oldpath, newpath string) error
- func SerializeToJSONFile(obj interface{}, path string) error
- func Stat(name string) (os.FileInfo, error)
- func TempDir(dir, prefix string) (name string, err error)
- func WriteFile(filename string, data []byte, perm os.FileMode) error
- func WriteSerializedFile(filename string, data []byte, perm os.FileMode) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeFromJSONFile ¶
DeserializeFromJSONFile deserializes the given JSON file into the object pointed to by objPtr. It may return an error for which ioutil.IsNotExist() returns true.
func IsExist ¶
IsExist wraps os.IsExist to work around https://github.com/golang/go/issues/17164 .
func IsNotExist ¶
IsNotExist is like os.IsNotExist, but handles wrapped errors, too.
func SerializeToJSONFile ¶
SerializeToJSONFile serializes the given object as JSON and writes it to the given file, making its parent directory first if necessary.
func WriteSerializedFile ¶
WriteSerializedFile writes (or overwrites) `data` into `filename`. If `filename` doesn't exist, it's created with `perm` permissions. If `filename` does exist, the data is first overwritten to the file, and then the file is truncated to the length of the data. If the data represents a serialized data structure where the length is explicitly stated in, or implicitly calculated from, the data itself on a read, then this is approximately an atomic write (without the performance overhead of writing to a temp file and renaming it). NOTE: it's technically possible a partial OS write could lead to a corrupted file, though in practice this seems much more rare than ioutil.WriteFile() leaving behind an empty file.
Types ¶
This section is empty.