Cloudwatcher Released

Fri, Mar 19, 2021 2-minute read

Sometimes, I happened to write an updater system for applications that needs to keep track of a given S3 bucket or shared FS to update files or start routines.

Since I didn’t find nothing ready on Go side, I had to implement a my own solution and that’s because I wrote Cloudwatcher.

This library allows to get a notification every time a change happens on a cloud filesystem (or even on local storage). Currently the supported services are:

  • Google Drive
  • Dropbox
  • Amazon S3
  • Git

As I said it is also possible to get events from the local FS using fsnotify library.

The usage is really simple: we need to create a new Cloudwatcher object specifying the directory we want to watch, the type of service we are going to use and the interval of time we want on the polling routine (how much often the check should be made on the FS).

After that we only need to specify the configuration parameters (credentials) and call the Start function.

Using the GetEvents and GetErrors functions, the Cloudwatcher instance returns 2 channels where we can receive the events on changes and errors.

package main

import (


func main() {
	s, err := cloudwatcher.New("local", "/home/user/tests", time.Second)
	if err != nil {
		fmt.Printf("ERROR: %s", err)

	config := map[string]string{
		"disable_fsnotify": "false",

	err = s.SetConfig(config)
	if err != nil {
		fmt.Printf("ERROR: %s", err)

	err = s.Start()
	defer s.Close()
	for {
		select {
		case v := <-s.GetEvents():
			fmt.Printf("EVENT: %s %s\n", v.Key, v.TypeString())

		case e := <-s.GetErrors():
			fmt.Printf("ERROR: %s\n", e)

The last supported service I added has been the Git service. This one can work in 2 ways:

  • monitoring a branch and raise an event on every file change: created, deleted, modified and tag changed (file mode modified)
  • monitoring a branch or the entire repository and raise an event on every new commit or new tag created.

In this way it is possible to keep track of a path in the repository for file changes or on the entire repository for new commits or tags.

You can find some examples in the example directory.

Finally I also integrated it in driplane so it is possible to create a folder feeder on a git repository and receive updates on changes :)