Search code examples
gogo-modules

Error when running go build . with log repo


I have a Go program with gomod and when I run go build . I got the following error:

go: github.com/sirupsen/[email protected] used for two different module paths (github.com/Sirupsen/logrus and github.com/sirupsen/logrus)

my go mod looks like

require (

github.com/Sirupsen/logrus v1.4.2 // indirect
github.com/sirupsen/logrus v1.4.2

…

) 

and I’ve added the following which doesnt help , any idea ?

replace (
   github.com/Sirupsen/logrus v1.4.2 => github.com/sirupsen/logrus v1.4.2
)

in my project code I use the import path with the lower case only github.com/sirupsen/logrus


Solution

  • Try to remove the //indirect line, then run

    go mod tidy # prune any extraneous requirements + other stuff
    go clean # remove object files and cached files
    go get -v -u all # update everything related to the dependencies
    go build # finger crossed!