I am using an open source project called "yaegi" in a large project.
I need to use older version of "yaegi": v.0.8.11
, so I modified the go.mod
file and replaced:
github.com/traefik/yaegi v0.9.2 // indirect
with github.com/containous/yaegi v0.8.11
But when I build the project, it starts to update all the modules and replace it back to the most updated version:
root@ubuntu:~/myproj1# go build main.go
go: finding module for package github.com/traefik/yaegi/stdlib/unsafe
go: finding module for package github.com/traefik/yaegi/stdlib
go: finding module for package github.com/traefik/yaegi/interp
go: found github.com/traefik/yaegi/interp in github.com/traefik/yaegi v0.9.2
How can I prevent it and keep it using the old version v.0.8.11
?
I read that according to https://tip.golang.org/cmd/go/#hdr-Maintaining_module_requirements:
The
go
command itself automatically updates thego.mod
file to maintain a standard formatting and the accuracy ofrequire
statements.Any go command that finds an unfamiliar import will look up the module containing that import and add the latest version of that module to go.mod automatically. […]
Any go command can determine that a module requirement is missing and must be added […].
Maybe there is a way to bypass it?
//indirect
ingo.mod
means that at least one of your other modules you’re importing is dependent on that version of module, thereforego build
shall automatically update that module, no matter how you changed that line in yourgo.mod
. In your case if you don’t want to useyaegi
module ofv0.9.2
you have to first get rid of other dependencies dependent on that module from your project, and then fix yourgo.mod
to make your project requireyaegi v0.8.11
. You can just delete them or make them require earlier version ofyaegi
by using their older version or editing their source code. Also, instead of editinggo.mod
directly, I’d run something likego get -v github.com/containous/[email protected]
to checkout to a specific version of a module.