Documentation ¶
Overview ¶
Package ios 输入输出相关.
包括 ReadLine, ContainsReader, WalkDir.
Index ¶
- Constants
- Variables
- func NewWriter(file string) (io.WriteCloser, error)
- func Read[E any](source <-chan E) (E, error)
- func ReadLine(file string, call func(line string) error) error
- func ReadTimeout[E any](source <-chan E, timeout time.Duration) (E, error)
- func ReaderLine(reader io.Reader, call func(line string) error) error
- func Unit(size int64, prec int) string
- func WalkDir(root string, walkDirFunc fs.WalkDirFunc, level int) error
- func Write[E any](data E, target chan<- E) (err error)
- func WriteTimeout[E any](data E, target chan<- E, timeout time.Duration) (err error)
- type ContainsReader
Examples ¶
Constants ¶
View Source
const ( Kilo Meg Giga Tera Peta Exa )
Variables ¶
View Source
var ( ErrTimeout = errors.New("time out") ErrChanClose = errors.New("channel close") )
Functions ¶
func NewWriter ¶ added in v0.2.19
func NewWriter(file string) (io.WriteCloser, error)
NewWriter 新建Writer,file存在Seek末尾,不存在创建.
func Read ¶ added in v1.0.49
Read 读取管道.
Example ¶
package main import ( "fmt" "github.com/xuender/oils/ios" ) func main() { data := make(chan int, 1) data <- 1 fmt.Println(ios.Read(data)) close(data) fmt.Println(ios.Read(data)) }
Output: 1 <nil> 0 channel close
func ReadTimeout ¶ added in v1.0.49
Read 限制时间内读取管道.
func Unit ¶ added in v0.5.41
Example ¶
package main import ( "fmt" "github.com/xuender/oils/ios" ) func main() { fmt.Println(ios.Unit(1, 2)) fmt.Println(ios.Unit(100, 2)) fmt.Println(ios.Unit(1024, 2)) fmt.Println(ios.Unit(1700, 2)) fmt.Println(ios.Unit(3*ios.Meg, 2)) }
Output: 1B 100B 1KB 1.7KB 3MB
Types ¶
type ContainsReader ¶
type ContainsReader struct {
// contains filtered or unexported fields
}
func NewContainsReader ¶
func NewContainsReader(reader io.Reader, subslice []byte) *ContainsReader
func (*ContainsReader) Contains ¶
func (p *ContainsReader) Contains() bool
Click to show internal directories.
Click to hide internal directories.