hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.7k stars 502 forks source link

cannot find module providing package gopkg.in/fsnotify.v1 #178

Open xianyanglin opened 3 years ago

xianyanglin commented 3 years ago

hi I can not run my program~ it show:

go: finding gopkg.in/fsnotify.v1 v1.4.9 go: finding gopkg.in/fsnotify.v1 v1.4.9 build git.code.oa.com/xinghai-go/webDemo: cannot load gopkg.in/fsnotify.v1: cannot find module providing package gopkg.in/fsnotify.v1

wuxler commented 3 years ago

hi I can not run my program~ it show:

go: finding gopkg.in/fsnotify.v1 v1.4.9 go: finding gopkg.in/fsnotify.v1 v1.4.9 build git.code.oa.com/xinghai-go/webDemo: cannot load gopkg.in/fsnotify.v1: cannot find module providing package gopkg.in/fsnotify.v1

It's because package gopkg.in/fsnotify has been renamed as github.com/fsnotify/fsnotify .

There's two ways i supply to fix this problem.

First, copy code of this repo to vendor sub-direcotory in your local project, and change gopkg.in/fsnotify to github.com/fsnotify/fsnotify in watch/inotify.go and watch/inotify_tracker.go

Second, if you use go mod , you can use it directly:

main.go


package main

import ( "fmt"

"github.com/hpcloud/tail"

)

func main() { t, err := tail.TailFile("/var/log/syslog", tail.Config{Follow: true}) if err != nil { panic(err) } for line := range t.Lines { fmt.Println(line.Text) } }