Skip to content

Latest commit

 

History

History
44 lines (41 loc) · 1.02 KB

README_EN.md

File metadata and controls

44 lines (41 loc) · 1.02 KB

中文 | English

🚀 Introduction

Stail

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

🔧 Install

go get github.com/Licoy/stail

🔨 Use

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

tail -{tailLine}f {filepath}

💡 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

📝 License

MIT