Documentation ¶
Index ¶
- func Create(name string) (*os.File, error)
- func MarshalJSONFile(v interface{}, filename string, perm os.FileMode) (err error)
- func Open(name string) (*os.File, error)
- func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func ReadFile(name string) ([]byte, error)
- func ReplaceFile(name string, perm os.FileMode, fn func(w io.Writer) error) error
- func UniqueDir(parent, name string) (dir string, err error)
- func UnmarshalJSONFile(filename string, v interface{}) error
- type Replacer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSONFile ¶
MarshalJSONFile writes the JSON encoding of v to a file named by filename. The file is created atomically. If the file does not exist, Marshal creates it with permissions perm.
func ReplaceFile ¶
func UniqueDir ¶
UniqueDir creates a unique dir given the desired name and parent directory. For instance if the desired path is /usr/mydir but such a path already exists, the dir /usr/mydir_01 is returned (and so on). Path extensions are respected and the unique number is appended before any extensions (e.g. mydir.brim -> mydir_01.txt).
func UnmarshalJSONFile ¶
UnmarshalJSONFile parses JSON-encoded data from the file named by filename and stores the result in the value pointed to by v. Internally, Unmarshal uses json.Unmarshal.
Types ¶
type Replacer ¶
type Replacer struct {
// contains filtered or unexported fields
}
func NewFileReplacer ¶
NewFileReplacer returns a Replacer, an io.WriteCloser that can be used to atomically update the content of a file. Either Close or Abort must be called on the Replacer; Close will rename the temp file to the given filename, while Abort will leave the original file unmodified.