Documentation ¶
Index ¶
- Constants
- func ANSIColor(node *Node, s string) string
- func CTimeSort(nf1, nf2 *Node) bool
- func DirRecursiveSize(node *Node) (size int64, err error)
- func DirSort(nf1, nf2 *Node, nxt SortFunc) bool
- func FormatSize(opts *Options, size int64) string
- func ModSort(nf1, nf2 *Node) bool
- func NameSort(f1, f2 *Node) bool
- func NaturalLess(str1, str2 string) bool
- func NodeSize(node *Node) int64
- func SizeSort(f1, f2 *Node) bool
- func VerSort(f1, f2 *Node) bool
- type ByFunc
- type Fs
- type Node
- type Nodes
- type Options
- type SortFunc
Constants ¶
const ( Reset int = 0 // Not used, remove. Bold int = 1 Black int = iota + 28 Red Green Yellow Blue Magenta Cyan White )
const ( KB = 1 * 1000 MB = KB * 1000 GB = MB * 1000 TB = GB * 1000 PB = TB * 1000 EB = PB * 1000 )
KB = 1000 bytes
const ( KiB int64 = 1 << (10 * iota) MiB GiB TiB PiB EiB )
Do it using KiB format, so KB = 1024 ...
const Escape = "\x1b"
Variables ¶
This section is empty.
Functions ¶
func DirRecursiveSize ¶ added in v1.0.3
DirRecursiveSize returns the size of the directory, as the total of all child nodes.
func FormatSize ¶ added in v1.0.3
FormatSize as a string
func NaturalLess ¶
NaturalLess compares two strings using natural ordering. This means that e.g. "abc2" < "abc12".
Non-digit sequences and numbers are compared separately. The former are compared bytewise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so e.g. "2" < "02")
Limitation: only ASCII digits (0-9) are considered. Code taken from: https://github.com/fvbommel/util/blob/master/sortorder/natsort.go
Types ¶
type Fs ¶
To use this package programmatically, you must implement this interface. For example: PTAL on 'cmd/tree/tree.go'
type Node ¶
Node represent some node in the tree contains FileInfo, and its childs
type Options ¶
type Options struct { Fs Fs OutFile io.Writer // List All bool DirsOnly bool FullPath bool IgnoreCase bool FollowLink bool DeepLevel int Pattern string IPattern string // File ByteSize bool UnitSize bool FileMode bool ShowUid bool ShowGid bool LastMod bool Quotes bool Inodes bool Device bool // Sort NoSort bool VerSort bool ModSort bool DirSort bool NameSort bool SizeSort bool CTimeSort bool ReverSort bool // Graphics NoIndent bool Colorize bool JoinSingle bool // contains filtered or unexported fields }
Options store the configuration for specific tree. Note, that 'Fs', and 'OutFile' are required (OutFile can be os.Stdout).