iox

package
v0.0.0-...-38cdf9c Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKey    = errors.New("failed generate key")
	ErrCipher = errors.New("failed to create cipher")
	ErrFile   = errors.New("failed read/write file")
	ErrInput  = errors.New("invalid input")
)
View Source
var (
	ErrTooManyIndexedFiles   = errors.New("io.indexedFile.exceededLimit")
	ErrUnknownConflictPolicy = errors.New("io.fileCreate.unknownConflictPolicy")
)

Functions

func AskDangerous

func AskDangerous(question string, def bool) bool

func AskPassword

func AskPassword(name string) string

AskPassword - asks password, prints the given name before asking

func CreateFile

func CreateFile(
	path string, conflictPolicy FileConflictPolicy) (*os.File, error)

func DecryptBase64Str

func DecryptBase64Str(in, password string) (string, error)

func DecryptFromFile

func DecryptFromFile(path, password string, writer io.Writer) error

func EncryptToBase64Str

func EncryptToBase64Str(in, password string) (string, error)

func EncryptToFile

func EncryptToFile(reader io.Reader, path, password string) error

func ExistsAsDir

func ExistsAsDir(path string) (yes bool)

ExistsAsDir - checks if a directory exists at given path. If a error occurs while stating whatever exists at given location, false is returned

func ExistsAsFile

func ExistsAsFile(path string) (yes bool)

ExistsAsFile - checks if a regular file exists at given path. If a error occurs while stating whatever exists at given location, false is returned

func FormattedJSON

func FormattedJSON(o interface{}) (string, error)

FormattedJSON - converts given data to JSON and returns as pretty printed

func Glob

func Glob(path string, filter func(string) bool) ([]string, error)

func LoadJson

func LoadJson(reader io.Reader, out interface{}) error

func LoadJsonFile

func LoadJsonFile(path string, out interface{}) error

func MustGetUserHome

func MustGetUserHome() string

func PrintJSON

func PrintJSON(o interface{})

PrintJSON - dumps JSON representation of given data to stdout

func SplitPath

func SplitPath(path string) (dirPath, fileBaseName, ext string)

func Walk

func Walk(path *WalkOptions) error

func WriteJSON

func WriteJSON(writer io.Writer, o interface{}) error

WriteJSON - writes JSON representation of given data to given writer

func WriteJSONFile

func WriteJSONFile(
	path string, conflictPolicy FileConflictPolicy, data interface{}) error

Types

type FileConflictPolicy

type FileConflictPolicy int
const (
	Append FileConflictPolicy = iota
	Overwrite
	RenameOriginalWithIndex
	RenameOriginalWithTimestamp
	NameNewWithIndex
	NameNewWithTimestamp
)

type FileCrytor

type FileCrytor interface {
	Encrypt(in []byte) ([]byte, error)
	Decrypt(in []byte) ([]byte, error)
	IsEncrypted(in []byte) bool
}

func NewCryptor

func NewCryptor(password string) FileCrytor

type UserInputReader

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

func NewUserInputReader

func NewUserInputReader(input io.Reader, output io.Writer) *UserInputReader

func StdUserInputReader

func StdUserInputReader() *UserInputReader

func (*UserInputReader) BoolOr

func (uir *UserInputReader) BoolOr(question string, def bool) bool

func (*UserInputReader) Float

func (uir *UserInputReader) Float(name string) float64

func (*UserInputReader) FloatOr

func (uir *UserInputReader) FloatOr(name string, def float64) float64

func (*UserInputReader) Int

func (uir *UserInputReader) Int(name string) int

func (*UserInputReader) IntOr

func (uir *UserInputReader) IntOr(name string, def int) int

func (*UserInputReader) Secret

func (uir *UserInputReader) Secret(msg string) string

Secret - asks password from user, does not echo charectors

func (*UserInputReader) Select

func (uir *UserInputReader) Select(
	name string, options []string, def string) string

func (*UserInputReader) String

func (uir *UserInputReader) String(name string) string

func (*UserInputReader) StringOr

func (uir *UserInputReader) StringOr(name string, def string) string

type WalkOptions

type WalkOptions struct {
}

Jump to

Keyboard shortcuts

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