io

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package io some io operation functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst string, opts ...CopyOption) error

Copy support copy file to file or dir to dir

func GetIOStreams

func GetIOStreams(ctx context.Context) (ioStreams *clioptions.IOStreams)

GetIOStreams returns IOStreams stored in the context if any if not found will return nil *IOStreams

func IsDir

func IsDir(dir string) bool

IsDir check if the given path is a dir

func IsExist

func IsExist(path string) bool

IsExist check if the given path is existed

func IsFile

func IsFile(file string) bool

IsFile check if the given path is a file

func MustGetIOStreams

func MustGetIOStreams(ctx context.Context) (ioStreams *clioptions.IOStreams)

MustGetIOStreams gets the IOStream from context or initiates a default using os.Stdin, os.Stout, os.Sterr

func WithIOStreams

func WithIOStreams(ctx context.Context, ioStreams *clioptions.IOStreams) context.Context

WithIOStreams adds IOStreams into the context

func WriteFile

func WriteFile(dstFile string, content []byte, perm os.FileMode) error

WriteFile write the content to the desired file

Types

type Config

type Config struct {
	FileFilter []func(srcFile, dstFile string) bool
}

Config configuration for copy operation

type CopyOption

type CopyOption func(config *Config)

CopyOption function for setting CopyConfig

func FileFilterOption

func FileFilterOption(f func(srcFile, dstFile string) bool) CopyOption

FileFilterOption construct file filter `CopyOption`

Jump to

Keyboard shortcuts

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