title: Interrupt current tail and start new one
body: <p>So I am creating some log analyzer in golang and what I need is real-time tail -f of newly created files.</p>
  
  <p>I am using tail package together with fsnotify package but I'm not very familiar with channels and routines in go so I need some assistance.</p>
  
  <p>Currently program looks like this:</p>
  
  <pre><code>package main
  
  import(
      "fmt"
      "github.com/hpcloud/tail"
      "strings"
      "log"
      "net/smtp"
      "time"
      "github.com/fsnotify/fsnotify"
  )
  
  //this function needs to monitor for new files in directory
  func newFileCheck() (newFilename chan string, err error) {
      watcher, err := fsnotify.NewWatcher()
      if err != nil {
          return
      }
  
      err = watcher.Add("myDir")
      if err != nil {
          return
      }
  
      newFilename = make(chan string)
  
      // Process events
      go func() {
          for {
              select {
              case ev := &lt;-watcher.Events:
                  log.Println("event:", ev)
                  newFilename &lt;- ev.Name // Relative path to the file
                  //t.Stop() //if I pass reference to t THIS IS NOT HAPPENING ?
              case err := &lt;-watcher.Errors:
                  log.Println("error:", err)
              }
          }
      }()
  
      return
  }
  
  func main() {
      newFileName = "mylog_0000.log.txt"
  
      fmt.Println("Processing log: ",newFileName)
  
      newFilenameChan, err := newFileCheck()
      if err != nil {
          fmt.Println("ERR: ",err)
      }
  
      t := tailLog(newFileName)
  
      go func() {
          for {
              select {
                  case name := &lt;-newFilenameChan:
                      fmt.Println("New file created: ",name) //this will be printed only once and then on new events nothing is printed ?
  
                  //NONE of the lines abowe doesn't work
                  t.Stop()
                  t.Dead()
                  t.Done()
  
                  t = tailLog(name)
              }
          }
      }()
  }
  
  func tailLog(fileName string) *tail.Tail{
      var count = 0
      // close the old one and read new file
      t, err := tail.TailFile("/mydir/"+fileName, tail.Config{Follow: true, ReOpen: true})
  
      for line := range t.Lines {
          //fmt.Println("Line is:", line.Text)
  
          //check do we have what we need
          if strings.Contains(strings.ToLower(line.Text), "mfc"){
  
              count++
              //do other stuff
          }
      }
  
      fmt.Println(err)
  
      return t
  }
  </code></pre>
  
  <p>So I can't figure out why newFileCheck functions prints event only for the fist time, and also I'm not able to figure out how to cancel active tail when new event happens, and then start tail again after that event ?</p>