fs

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MPL-2.0 Imports: 13 Imported by: 21

Documentation

Overview

Package fs provides filesystem-related utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseName

func BaseName(path string) string

BaseName returns the file name without the directory or extension.

func Copy added in v1.1.0

func Copy(src, dst string) error

Copy src to dst. src may be a directory, file, or symlink.

func FileExists

func FileExists(path string) bool

FileExists returns true if the path points to a regular file.

func IsDir

func IsDir(path string) bool

IsDir returns true if the specified path exists and is a directory.

func LoadJSON

func LoadJSON(path string, data interface{}) error

LoadJSON data from the specified path.

func LoadYAML

func LoadYAML(path string, data interface{}) error

LoadYAML data from the specified path.

func MoveFile

func MoveFile(src, dst string) (err error)

MoveFile moves a file in the file system or across volumes, using rename if possible, but falling back to copying the file if not. This will error if either src or dst are not regular files.

func SanitizeName

func SanitizeName(name string) string

SanitizeName sanitizes a file name by replacing invalid characters.

func SaveJSON

func SaveJSON(path string, data interface{}, format bool) error

SaveJSON data to the specified path.

func SaveYAML

func SaveYAML(path string, data interface{}) error

SaveYAML data to the specified path.

func Split

func Split(path string) []string

Split a path into its component parts. In the case of a full path, the first element will be filepath.Separator, possibly prefixed by a volume name. In the case of a relative path, the first element will be ".".

func TrimExtension

func TrimExtension(path string) string

TrimExtension trims any extension from the path.

func UnsanitizeName

func UnsanitizeName(name string) string

UnsanitizeName reverses the effects of a call to SanitizeName.

func Walk

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk performs the same function as filepath.Walk() does, but works on http.FileSystem objects.

Types

This section is empty.

Directories

Path Synopsis
Package embedded provides an implementation of an embedded filesystem.
Package embedded provides an implementation of an embedded filesystem.
htmltmpl
Package htmltmpl provides convenience utilities for using html templates in an embedded filesystem.
Package htmltmpl provides convenience utilities for using html templates in an embedded filesystem.
texttmpl
Package texttmpl provides convenience utilities for using text templates in an embedded filesystem.
Package texttmpl provides convenience utilities for using text templates in an embedded filesystem.
Package paths provides platform-specific standard paths.
Package paths provides platform-specific standard paths.
Package safe provides safe, atomic saving of files.
Package safe provides safe, atomic saving of files.
Package zip provides simple zip extraction.
Package zip provides simple zip extraction.

Jump to

Keyboard shortcuts

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