Can something be done if I download the package source files elsewhere and place them in ~/go/pkg/mod under the correct directory or use go mod vendor?
Why are you running go mod tidy in your VM though? You could just run it on the machine with internet access and then push the resulting tidied go.mod and go.sum to your VM.
Actually I have no way to move my code out of the VM to another Ubuntu environment that has internet. My team is working on getting around that issue. But it will take some time.
Can you go mod vendor and tidy BEFORE you push your code to the offline VM? The bottom line is: if you want to use dependencies from the internet, you’re going to need the internet at some point in your toolchain. If you want to grab dependencies that you haven’t used in your code yet (but you know you will need) you could do imports/vendoring as suggested in this gist: