# stail **Repository Path**: licoy/stail ## Basic Information - **Project Name**: stail - **Description**: 通过系统级的命令(如`tail -f`)来实时监控文件变动 | Use system level commands (such as `tail - f`) to monitor file changes in real time - **Primary Language**: Go - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2021-12-03 - **Last Updated**: 2025-01-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [中文](./README.md) | English ## :rocket: Introduction

Stail

real-time monitoring of file changes through system-level commands (such as `tail -f`)

## :wrench: Install ``` go get github.com/Licoy/stail ``` ## :hammer: Use ```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("get content: %s", content)) }) if err != nil { fmt.Println(err) return } time.AfterFunc(time.Second*10, func() { si.Close() // close the acquisition channel after 10 s } si.Watch() } ``` equivalent to ```bash tail -{tailLine}f {filepath} ``` ## :bulb: Parameter - `filepath` file path that needs to be monitored - `tailLine` view only the specified line at the end - `call` the content callback func, the content type is string ## :memo: License [MIT](./LICENSE)