README

fileutils

GO utility functions for file system access

Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsolutePath

func AbsolutePath(path string) string

    AbsolutePath normalizes the given path and makes it absolute.

    func DirGlob

    func DirGlob(pattern string) []string

      DirGlob resolves the given pattern into matching directories. Errors are ignored.

      func Exists

      func Exists(path string) bool

        Exists returns true if the given path exists.

        func FileGlob

        func FileGlob(pattern string) []string

          FileGlob resolves the given pattern into matching regular files. Errors are ignored.

          func FilterByPattern

          func FilterByPattern(paths []string, caseInsensitive bool, patterns ...interface{}) (result []string)

            FilterByPattern takes a list of paths and a list of patterns and returns all paths matching this pattern. Only the last path component (base path) is used when checking a pattern. Patterns can be strings containing wildcards or regular expressions.

            func Glob

            func Glob(pattern string) []string

              Glob resolves the given pattern into matching directory entries. Errors are ignored.

              func HasWildcard

              func HasWildcard(path string) bool

                HasWildcard returns true if the given path contains a wildcard.

                func IsDir

                func IsDir(path string) bool

                  IsDir returns true if the given path exists and points to a directory.

                  func IsFile

                  func IsFile(path string) bool

                    IsFile returns true if the given path exists and points to a regular file.

                    func Join

                    func Join(sep string, elem ...string) (path string)

                    func NormalizePath

                    func NormalizePath(path string) string

                      NormalizePath normalizes the given path by changing the path separator to the OS specific separator.

                      func ReadFile

                      func ReadFile(file string) (string, error)

                        ReadFile returns the contents of the given file as a string, or an error if the file could not be read.

                        func ReadLines

                        func ReadLines(file string) ([]string, error)

                          ReadLines returns the contents of the given file, split into individual lines, or an error if the file could not be read.

                          func Sort

                          func Sort(list []string, ignoreCase bool) []string

                            Sort sorts the given list numerically/logically, optionally ignoring case. All numbers in the name are considered, so a1b2 < a2b2 < a10b2 < a10b10.

                            func SplitLines

                            func SplitLines(text string) []string

                              SplitLines splits the given text into individual lines, removing CR first and then splitting on LN indicating End-Of-Line.

                              Types

                              type PathInfo

                              type PathInfo struct {
                              	Path  string
                              	IsDir bool
                              }

                                PathInfo contains info about a file or directory

                                func ResolvePath

                                func ResolvePath(path string) []PathInfo

                                  ResolvePath checks whether the given path exists or uses Glob if it doesn't and returns a logically sorted slice of ResolvedPath structures describing the matching entries.