Giter Site home page Giter Site logo

licoy / stail Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 3.0 8 KB

:rocket: 通过系统级的命令(如`tail -f`)来循环显示文件尾部数据 | Use system-level commands (such as `tail -f`) to display tail data in a loop

License: MIT License

Batchfile 2.09% Go 97.91%
tail powershell monitor fsnotify

stail's Introduction

中文 | English

🚀 介绍

Stail

通过系统级的命令( 如 `tail -f` )来实时监控文件变动

🔧 安装

go get github.com/Licoy/stail

🔨 使用

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()
}

相当于

tail -{tailLine}f {filepath}

💡 参数

  • filepath 需要监听的文件路径
  • tailLine 只查看末尾的指定行
  • call 内容回调func,内容类型为string

📝 协议

MIT

stail's People

Contributors

licoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.