Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/licoy/stail
:rocket: 通过系统级的命令(如`tail -f`)来循环显示文件尾部数据 | Use system-level commands (such as `tail -f`) to display tail data in a loop
https://github.com/licoy/stail
fsnotify monitor powershell tail
Last synced: 19 days ago
JSON representation
:rocket: 通过系统级的命令(如`tail -f`)来循环显示文件尾部数据 | Use system-level commands (such as `tail -f`) to display tail data in a loop
- Host: GitHub
- URL: https://github.com/licoy/stail
- Owner: Licoy
- License: mit
- Created: 2021-12-02T04:41:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-03T05:23:32.000Z (almost 3 years ago)
- Last Synced: 2024-10-09T06:31:11.859Z (29 days ago)
- Topics: fsnotify, monitor, powershell, tail
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 16
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
中文 | [English](./README_EN.md)
## :rocket: 介绍
Stail
通过系统级的命令( 如 `tail -f` )来实时监控文件变动
## :wrench: 安装
```
go get github.com/Licoy/stail
```
## :hammer: 使用
```golang
func useSTail(filepath string, tailLine int) {
st, err := stail.New(stail.Options{})
if err != nil {
fmt.Println(err)
return
}
si, err := st.Tail(filepath, tailLine, func(content string) {
fmt.Print(fmt.Sprintf("获取到内容: %s", content))
})
if err != nil {
fmt.Println(err)
return
}
time.AfterFunc(time.Second*10, func() {
err = si.Close() // 10s之后关闭获取通道
}
si.Watch()
}
```
相当于
```bash
tail -{tailLine}f {filepath}
```
## :bulb: 参数
- `filepath` 需要监听的文件路径
- `tailLine` 只查看末尾的指定行
- `call` 内容回调func,内容类型为string## :memo: 协议
[MIT](./LICENSE)