-
Remove any existing
go.mod
andgo.sum
files -
Set your
GO111MODULE
to auto using
go env -w GO111MODULE=auto
-
go mod init <module_name>
-
import the necessary external packages in your go files
-
go mod tidy
-
the above command will install all the dependencies
IMPORTANT: If you open a folder containing multiple separate GO projects in vs code then you will error that
unable to import the package
. That is because Go is getting confused looking at multiple go.mod files at the same time. To fix this issue, open a single Go project in a single vs code instance