Documentation
¶
Overview ¶
Package xfercommon holds helpers for a file transfer that do not know which protocol is moving the bytes. FTP uses them. A later protocol can use the same ones.
Index ¶
- Constants
- func CheckPath(path string) error
- func CheckText(field, v string) error
- func FillReader(mode string, n int64) (io.Reader, error)
- func HexDigest(sum []byte) string
- func NewHash() hash.Hash
- func ParseSize(s string) (int64, error)
- func ReplaceID(s, id string) string
- func ValidSHA256(s string) bool
- type CountingReader
- type CountingWriter
Constants ¶
View Source
const ( // MaxSize is the most a generated payload may be: 4 GiB. MaxSize = 4 << 30 // MaxPath is the most bytes a remote path may be. MaxPath = 4096 // MaxBody is the most a caller-supplied body may be. MaxBody = 64 << 20 )
Variables ¶
This section is empty.
Functions ¶
func CheckText ¶
CheckText refuses a CR, LF or NUL in v. The error names the field and does not include the value.
func FillReader ¶
FillReader returns a reader of exactly n bytes. mode is random, zero or text. The same mode and n always produce the same bytes. The reader never holds those bytes all at once.
func ParseSize ¶
ParseSize reads a size such as 1024, 10KiB, 10MiB or 1GiB. The unit is 1024-based. A bare number is a count of bytes.
func ValidSHA256 ¶
ValidSHA256 reports whether s is 64 hex characters.
Types ¶
type CountingReader ¶
CountingReader counts the bytes read from r.
Click to show internal directories.
Click to hide internal directories.