Documentation
¶
Index ¶
- Variables
- func CopyBuffer(ctx context.Context, dst io.Writer, src io.Reader, buf []byte) (written int64, err error)
- func CopyDir(ctx context.Context, source string, dest string) (err error)
- func CopyFile(ctx context.Context, src, dst string) error
- func DESDecryptor(ctx context.Context, key, iv []byte, cipherReader io.Reader, size int64) (io.Reader, error)
- func DecryptAES(data []byte, password string) ([]byte, error)
- func DecryptAESFile(src, dst string, password string) error
- func EncryptAES(data []byte, password string) ([]byte, error)
- func EncryptAESFile(src, dst string, password string) error
- func LimitReadAll(ctx context.Context, r io.Reader, p []byte) (int, error)
- func LimitWriteAll(ctx context.Context, w io.Writer, p []byte) (int, error)
- func Targz(ctx context.Context, src, dst string) error
- type LimitReader
- type LimitWriter
- type ProgressWriter
Constants ¶
This section is empty.
Variables ¶
var DefaultDESDecryptorBufSize = 32 * 1024
Functions ¶
func CopyBuffer ¶
func CopyBuffer(ctx context.Context, dst io.Writer, src io.Reader, buf []byte) (written int64, err error)
copyBuffer is the cancelable implementation of Copy and CopyBuffer. if buf is nil, one is allocated.
func DESDecryptor ¶
func DecryptAESFile ¶
func EncryptAESFile ¶
Types ¶
type LimitReader ¶ added in v0.5.0
type LimitReader interface {
io.ReadCloser
Consumed() int
Remaining() int
}
LimitReader reads at most max bytes and then FAILS, rather than reporting a clean EOF. That distinction matters for untrusted input: a silently truncated body reaches the consumer looking like a complete one. Use it to bound anything whose decoded size isn't known from the wire size — an inflating stream being the usual case.
func NewLimitReader ¶ added in v0.5.0
func NewLimitReader(r io.Reader, max int) LimitReader
NewLimitReader bounds r to max bytes. Reading exactly max succeeds and ends in io.EOF; the first byte beyond max returns an error. The error is deliberately uncategorized — how an over-long stream maps to a status is the caller's decision, not this package's.
It returns a ReadCloser so the result can stand in directly for something like http.Request.Body. Close closes r when r is itself a Closer, and is a no-op otherwise.
type LimitWriter ¶ added in v0.3.13
func NewLimitWriter ¶ added in v0.3.13
func NewLimitWriter(w io.Writer, max int) LimitWriter