ufs

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 18 Imported by: 0

README

go-ufs

Documentation

Index

Constants

View Source
const (
	HTTP  = services.HTTP + "://"
	HTTPS = services.HTTPS + "://"
	FTP   = services.FTP + "://"
	FTPS  = services.FTPS + "://"
	SFTP  = services.SFTP + "://"
	S3    = services.S3 + "://"
	FILE  = "file://"
)

Variables

View Source
var AppFs = afero.NewOsFs()

Functions

func CopyFile

func CopyFile(fs afero.Fs, path string, newPath string) (int64, error)

func CopyFileP added in v1.1.0

func CopyFileP(fs afero.Fs, path string, newPath string) int64

func CreateLockFile added in v1.0.2

func CreateLockFile(fs afero.Fs, filename string) (afero.File, error)

CreateLockFile tries to create a file with given name and acquire an exclusive lock on it. If the file already exists AND is still locked, it will fail.

func DefaultEtcHosts

func DefaultEtcHosts() (string, error)

func DefaultEtcHostsP added in v1.1.0

func DefaultEtcHostsP() string

func DirExists

func DirExists(fs afero.Fs, path string) (bool, error)

DirExists ...

func DirExistsP added in v1.1.0

func DirExistsP(fs afero.Fs, path string) bool

func DownloadBytes

func DownloadBytes(logger comm.Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) (result []byte, err error)

func DownloadBytesP added in v1.1.0

func DownloadBytesP(logger comm.Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) []byte

func DownloadText

func DownloadText(logger comm.Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) (string, error)

func DownloadTextP added in v1.1.0

func DownloadTextP(logger comm.Logger, fallbackDir string, fs afero.Fs, url string, credentials Credentials, timeout time.Duration) string

func EnsureDirExists

func EnsureDirExists(fs afero.Fs, path string) error

func EnsureDirExistsP added in v1.1.0

func EnsureDirExistsP(fs afero.Fs, path string)

func EnsureFileExists

func EnsureFileExists(fs afero.Fs, path string) error

func EnsureFileExistsP added in v1.1.0

func EnsureFileExistsP(fs afero.Fs, path string)

func ExpandHomePath

func ExpandHomePath(path string) (string, error)

ExpandHomePath ...

func ExpandHomePathP added in v1.1.0

func ExpandHomePathP(path string) string

func ExtractTitle

func ExtractTitle(filePath string) string

func FallbackFilePath added in v1.2.1

func FallbackFilePath(fallbackDir string, url string) string

func FileExists

func FileExists(fs afero.Fs, path string) (bool, error)

FileExists ...

func FileExistsP added in v1.1.0

func FileExistsP(fs afero.Fs, path string) bool

func FromYaml added in v1.2.3

func FromYaml(yamlText string, envsubt bool, result any) (err error)

func FromYamlFile

func FromYamlFile(fs afero.Fs, path string, envsubt bool, result any) error

func FromYamlFileP added in v1.1.0

func FromYamlFileP(fs afero.Fs, path string, envsubt bool, result any)

func FromYamlP added in v1.2.3

func FromYamlP(yamlText string, envsubt bool, result any)

func GetLockFilePid added in v1.0.2

func GetLockFilePid(fs afero.Fs, filename string) (pid int, err error)

If filename is a lock file, returns the PID of the process locking it

func HasFallbackFile added in v1.2.1

func HasFallbackFile(fallbackDir string, fs afero.Fs, url string) (bool, error)

func IsFileProtocol

func IsFileProtocol(url string) bool

func IsRemote

func IsRemote(url string) bool

func ListSuffixed

func ListSuffixed(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) (map[string]string, error)

func ListSuffixedP added in v1.1.0

func ListSuffixedP(fs afero.Fs, targetDir string, suffix string, skipEmptyFile bool) map[string]string

func MapFromYaml added in v1.2.3

func MapFromYaml(yamlText string, envsubt bool) (map[string]any, error)

func MapFromYamlFile

func MapFromYamlFile(fs afero.Fs, path string, envsubt bool) (map[string]any, error)

func MapFromYamlFileP added in v1.1.0

func MapFromYamlFileP(fs afero.Fs, path string, envsubt bool) map[string]any

func MapFromYamlP added in v1.2.3

func MapFromYamlP(yamlText string, envsubt bool) map[string]any

func Mkdir

func Mkdir(fs afero.Fs, path string) error

Mkdir ...

func MkdirP added in v1.1.0

func MkdirP(fs afero.Fs, path string)

func ReadBytes

func ReadBytes(fs afero.Fs, path string) ([]byte, error)

ReadBytes ...

func ReadBytesP added in v1.1.0

func ReadBytesP(fs afero.Fs, path string) []byte

func ReadFallbackFile added in v1.2.1

func ReadFallbackFile(fallbackDir string, fs afero.Fs, url string) (string, []byte, error)

func ReadLines

func ReadLines(fs afero.Fs, path string) ([]string, error)

func ReadLinesP added in v1.1.0

func ReadLinesP(fs afero.Fs, path string) []string

func ReadText

func ReadText(fs afero.Fs, path string) (string, error)

func ReadTextP added in v1.1.0

func ReadTextP(fs afero.Fs, path string) string

func RemoveDir

func RemoveDir(fs afero.Fs, path string) error

RemoveDir ...

func RemoveDirP added in v1.1.0

func RemoveDirP(fs afero.Fs, path string)

func RemoveFile

func RemoveFile(fs afero.Fs, path string) error

RemoveFile ...

func RemoveFileP added in v1.1.0

func RemoveFileP(fs afero.Fs, path string)

func Rename

func Rename(fs afero.Fs, path string, newPath string) error

func RenameP added in v1.1.0

func RenameP(fs afero.Fs, path string, newPath string)

func ShortDescription

func ShortDescription(url string) string

func Stat

func Stat(fs afero.Fs, path string, ensureExists bool) (os.FileInfo, error)

Stat ...

func StatP added in v1.1.0

func StatP(fs afero.Fs, path string, ensureExists bool) os.FileInfo

func TempFile

func TempFile(fs afero.Fs, pattern string) (string, error)

func TempFileP added in v1.1.0

func TempFileP(fs afero.Fs, pattern string) string

func TempTextFile

func TempTextFile(fs afero.Fs, pattern string, content string) (string, error)

func TempTextFileP added in v1.1.0

func TempTextFileP(fs afero.Fs, pattern string, content string) string

func UserHomeDir

func UserHomeDir() (string, error)

func UserHomeDirP added in v1.1.0

func UserHomeDirP() string

func WorkDir

func WorkDir(url string, defaultDir string) string

func Write

func Write(fs afero.Fs, path string, content []byte) error

Write ...

func WriteFallbackFile added in v1.2.1

func WriteFallbackFile(fallbackDir string, fs afero.Fs, url string, bytes []byte) (string, error)

func WriteIfNotFound

func WriteIfNotFound(fs afero.Fs, path string, content []byte) (bool, error)

WriteIfNotFound ...

func WriteIfNotFoundP added in v1.1.0

func WriteIfNotFoundP(fs afero.Fs, path string, content []byte) bool

func WriteLines

func WriteLines(fs afero.Fs, path string, lines ...string) error

func WriteLinesP added in v1.1.0

func WriteLinesP(fs afero.Fs, path string, lines ...string)

WriteLines ...

func WriteP added in v1.1.0

func WriteP(fs afero.Fs, path string, content []byte)

func WriteText

func WriteText(fs afero.Fs, path string, content string) error

WriteText ...

func WriteTextIfNotFound

func WriteTextIfNotFound(fs afero.Fs, path string, content string) (bool, error)

func WriteTextIfNotFoundP added in v1.1.0

func WriteTextIfNotFoundP(fs afero.Fs, path string, content string) bool

WriteTextIfNotFound ...

func WriteTextP added in v1.1.0

func WriteTextP(fs afero.Fs, path string, content string)

Types

type AferoBlob

type AferoBlob = *AferoBlobT

func NewAferoBlob

func NewAferoBlob(afs afero.Fs, path string) AferoBlob

func (AferoBlob) Close

func (me AferoBlob) Close() error

func (AferoBlob) Fs

func (me AferoBlob) Fs() afero.Fs

func (AferoBlob) Path

func (me AferoBlob) Path() string

func (AferoBlob) Read

func (me AferoBlob) Read(p []byte) (n int, err error)

type AferoBlobT

type AferoBlobT struct {
	// contains filtered or unexported fields
}

type AferoFile

type AferoFile = *AferoFileT

func NewAferoFile

func NewAferoFile(afs afero.Fs, apath string, credentials Credentials, timeout time.Duration) (AferoFile, error)

func NewAferoFileP added in v1.1.0

func NewAferoFileP(afs afero.Fs, apath string, credentials Credentials, timeout time.Duration) AferoFile

func (AferoFile) Credentials

func (me AferoFile) Credentials() Credentials

func (AferoFile) Dir

func (me AferoFile) Dir() string

filepath

func (AferoFile) Download

func (me AferoFile) Download() (Content, error)

func (AferoFile) DownloadP added in v1.1.0

func (me AferoFile) DownloadP() Content

func (AferoFile) Fs

func (me AferoFile) Fs() afero.Fs

func (AferoFile) Name

func (me AferoFile) Name() string

func (AferoFile) Protocol

func (me AferoFile) Protocol() string

remote protocol. May be used to explicitly tell what protocol to use (i.e. "http", "ftp", "etc").

func (AferoFile) Timeout

func (me AferoFile) Timeout() time.Duration

func (AferoFile) URL

func (me AferoFile) URL() *url.URL

func (AferoFile) Url

func (me AferoFile) Url() string

remote file/dir url

type AferoFileT

type AferoFileT struct {
	// contains filtered or unexported fields
}

type Content

type Content = *ContentT

type ContentT

type ContentT = models.RemoteFileContent

type Credentials

type Credentials = *CredentialsT

type CredentialsT

type CredentialsT = models.Credentials

type File

type File interface {
	Name() string
	Dir() string
	Url() string
	Protocol() string
	URL() *url.URL
	Credentials() Credentials
	Timeout() time.Duration
	DownloadP() Content
	Download() (Content, error)
}

func NewFile

func NewFile(afs afero.Fs, url string, credentials Credentials, timeout time.Duration) (File, error)

func NewFileP added in v1.1.0

func NewFileP(afs afero.Fs, url string, credentials Credentials, timeout time.Duration) File

type RemoteFile

type RemoteFile = *RemoteFileT

func NewRemoteFile

func NewRemoteFile(url string, credentials Credentials, timeout time.Duration) (RemoteFile, error)

func NewRemoteFileP added in v1.1.0

func NewRemoteFileP(url string, credentials Credentials, timeout time.Duration) RemoteFile

func (RemoteFile) Credentials

func (me RemoteFile) Credentials() Credentials

func (RemoteFile) Dir

func (me RemoteFile) Dir() string

filepath

func (RemoteFile) Download

func (me RemoteFile) Download() (Content, error)

func (RemoteFile) DownloadP added in v1.1.0

func (me RemoteFile) DownloadP() Content

func (RemoteFile) Name

func (me RemoteFile) Name() string

func (RemoteFile) Protocol

func (me RemoteFile) Protocol() string

remote protocol. May be used to explicitly tell what protocol to use (i.e. "http", "ftp", "etc").

func (RemoteFile) Timeout

func (me RemoteFile) Timeout() time.Duration

func (RemoteFile) URL

func (me RemoteFile) URL() *url.URL

func (RemoteFile) Url

func (me RemoteFile) Url() string

remote file/dir url

type RemoteFileT

type RemoteFileT struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
patch
go-universal-network-adapter
Package contains realization of class for file download via HTTP protocol
Package contains realization of class for file download via HTTP protocol

Jump to

Keyboard shortcuts

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