- copy
go.mod
andgo.sum
files from the offline PC to the internet PC
- create a folder on the internet PC
- create a go module :
go mod init test
- create a
offline_modules.go
file :
package offline_modules
func main() {}
- add the dependencies you want to download (use
_
) :
package offline_modules
import (
_ "github.com/gorilla/mux"
_ "github.com/sirupsen/logrus"
)
func main() {}
-
run
go mod vendor
-
the vendor folder should have new folders in it representing dependencies
- copy
go.mod
,go.sum
andvendor
- paste them on your offline PC, edit
go.mod
module name if necessary - run your go commands with the flag
-mod=vendor
likego run -mod=vendor main.go
TODO
useful~