New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zgo.at/follow

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zgo.at/follow

  • v0.0.0-20240522232612-673fb184d32f
  • Go
  • Socket score

Version published
Created
Source

Go library to follow a file for changes; e.g. "tail -F".

There's a little example application in tail/main.go:

func main() {
	if len(os.Args) <= 1 {
		fmt.Println("need at least one filename")
		os.Exit(1)
	}

	f := follow.New()

	// Maximum time to retry opening the file after it goes away; -1 to keep
	// trying forever.
	f.Retry = -1

	// Install signal handler; any signal sent to this will reopen the file; you
	// can send something manually with:
	//    f.Reopen <- os.Interrupt
	signal.Notify(f.Reopen, syscall.SIGHUP)

	// Keep reading data in the background, sending it to the f.Data channel.
	go func() { log.Fatal(f.Start(context.Background(), os.Args[1])) }()

	for {
		data := <-f.Data
		if data.Err != nil {
			if data.Err == io.EOF {
				break
			}
			log.Fatal(data.Err)
		}
		fmt.Println("X", data)
	}
}

FAQs

Package last updated on 22 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc