ufs

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 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

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

func CreateLockFile

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

func DefaultEtcHostsP() string

func DirExists

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

DirExists ...

func DirExistsP

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

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

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

func EnsureDirExistsP(fs afero.Fs, path string)

func EnsureFileExists

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

func EnsureFileExistsP

func EnsureFileExistsP(fs afero.Fs, path string)

func ExpandHomePath

func ExpandHomePath(path string) (string, error)

ExpandHomePath ...

func ExpandHomePathP

func ExpandHomePathP(path string) string

func ExtractTitle

func ExtractTitle(filePath string) string

func FallbackFilePath

func FallbackFilePath(fallbackDir string, url string) string

func FileExists

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

FileExists ...

func FileExistsP

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

func FromYaml

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

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

func FromYamlP

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

func GetLockFilePid

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

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

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

func MapFromYaml

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

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

func MapFromYamlP

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

func Mkdir

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

Mkdir ...

func MkdirP

func MkdirP(fs afero.Fs, path string)

func ReadBytes

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

ReadBytes ...

func ReadBytesP

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

func ReadFallbackFile

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

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

func ReadText

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

func ReadTextP

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

func RemoveDir

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

RemoveDir ...

func RemoveDirP

func RemoveDirP(fs afero.Fs, path string)

func RemoveFile

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

RemoveFile ...

func RemoveFileP

func RemoveFileP(fs afero.Fs, path string)

func Rename

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

func RenameP

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

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

func TempFile

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

func TempFileP

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

func TempTextFile

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

func TempTextFileP

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

func UserHomeDir

func UserHomeDir() (string, error)

func UserHomeDirP

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

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

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

func WriteLines

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

func WriteLinesP

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

WriteLines ...

func WriteP

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

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

WriteTextIfNotFound ...

func WriteTextP

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

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

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

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

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

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