How can I use go with Modules

158 views
Skip to first unread message

Jason Bramsden

unread,
Dec 1, 2022, 12:12:28 PM12/1/22
to golang-nuts
BLUF: Is there any way to use the latest version of Go without Modules? Some flag or environment setting where I can disable it?

I've been developing on Go since 2011, and I find Modules so frustrating! 
Life was so much easier without Modules, I could download packages from a git repo using go get, and they would be accessible in the go/src directory. I could then easily run the examples code and make changes all in a nice directory structure.  I don't care about what version the code is at, which makes Modules pointless for the way that I develop.

With Modules, if I'm downloading a fork of a git repo, then it is so much more time-consuming, especially if the 3rd party fork code has issues. 

I could go back to an earlier version of the Go or I could switch to another compiler like TinyGo. 

Jason Bramsden

unread,
Dec 1, 2022, 12:38:59 PM12/1/22
to golang-nuts
I'm going to answer my own question as I've managed to figure it out. 
Set the following environment variable: GO111MODULE=off

When I previously looked at the environment variables using go env the GO111MODULE="", which I thought was off. But if this environment variable is not set then it is assumed to be on.

Also the naming of the environment variable should be changed, as it still has the version number of when Modules were first introduced, 1.11, this should be changed to GOMODULE. 

Christian Stewart

unread,
Dec 1, 2022, 1:33:49 PM12/1/22
to Jason Bramsden, golang-nuts
Hi Jason,

Your sentiment is understandable and was shared by many of us when modules were first announced.

 ..however..

The points you're making here have been proven to be moot with modules in the meantime. here's why;

You can still clone a go repository anywhere you want and run the examples / edit them. If you want to override dependencies you can use a go.work file in the parent directory of the git repositories and clone the other dependencies you want to override to that directory.

So there's no reason to hate on go modules anymore and almost all projects use it today.

Please explain why you find downloading a fork of a repo more time consuming with this approach and we will help explain how to do it quickly.

Best regards,
Christian

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/23540c6b-f0fe-4bed-9bc4-713965306257n%40googlegroups.com.

TheDiveO

unread,
Dec 2, 2022, 4:41:26 PM12/2/22
to golang-nuts
My 2cents here. One of the most terrible examples of pre-mod repos I've encountered are Docker's engine repos, subsuming also the repos moved into the moby realm: they mostly lack module information and they break upon checking them out on master or go getting them and trying to build, even on a specific release tag. Trying to use them as a dependency is also a pain because you need to check the vendoring of the moby main repo in order to pin the precise dependencies you'll need. The only exception is the Docker API client ... it is a proper mod.

I only started working with Go in a serious and professional manner in my paid company work after modules were finally to settle at 1.12/1.13. Without modules I weren't using Go even to toy programming. Paint me a happy Gopher, more so as workspaces finally make working on multiple modules in lock step possible.
Reply all
Reply to author
Forward
0 new messages