- copy
go.modandgo.sumfiles 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.gofile :
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.sumandvendor - paste them on your offline PC, edit
go.modmodule name if necessary - run your go commands with the flag
-mod=vendorlikego run -mod=vendor main.go
TODO
useful~