Airing my discontent with Go

I just wanted type out a general post about my experience working with Go for the first few attempts.

Never, never with any other language, have I had so many problems just importing dependencies.

No matter what I’ve tried, deleting my go.sum and running go mod tidy, moving my project directory around to different locations, Idk, what’s wrong.

I use go get to get the package, it says the package is installed, but when I got to add it to my imports it just can’t find it. I physically see it in my /usr/local/go directory, but my project just can’t find it. It’s even worse with local imports because it has to be in GOPATH or GOROOT. Why force me to do that instead of letting me navigate with a relative url to the package I want to import.

If it weren’t for that my project I’m working on absolutely requires Go I would have given up and moved on to something else a long time again.

Importing is the most basic thing and for some reason go has decided it make super convoluted and easy to break with this language.

Is there some basic guidelines that just aren’t well documented for this?

Hmm. Can you maybe post a copy of your go.mod? Which package are you trying to import and unable to? Have you read this?

This, plus the commands that you run and the error they return.

And maybe also the import strings you use.

The more details, the better.

I figured it out.

The way I do some of my development is over SSH, and mounting the remote system over sshfs. What this resulted in is because the IDE couldn’t see the installed packages because they weren’t on the same system that the IDE is running on. The code would run but the error in the IDE wouldn’t go away, so it was just a flase flag by the go plugin in the IDE.

This has never happened with my setup before because other languages I’ve used install deps directly in the working directory.

Feel free to go ahead and delete this post. I’m not super thrilled how it comes across (really whiny). Was getting tired and frustrated and let it get to me. Should have gotten up and gone for a walk instead of posting this.

1 Like

To initialize your project as a Go Module, navigate to the root directory of your project using the command line and run go mod init <module-name>. Replace <module-name> with the desired name for your module. This command creates a go.mod file that serves as the manifest for your dependencies. It’s important to note that the module name should be a valid module path (e.g., a URL or a path on a version control system). Initializing your project as a Go Module ensures that the dependencies are managed correctly. Thanks

The guide that I’m using to learn Go always uses the “module-name” as the directory name for the project. Is that a requirement? When I ran “go mod help init”, the first line of ouput said “usage: go mod init [module-path]”. I want to be sure that this “module-path” is fully independent of the file-path containing the project code. The help output also said module-path was optional and would be inferred from the contents; but if there are not yet any contents, what happens?

Despite my best efforts, I encountered a roadblock when it came to importing dependencies for my project. No matter what I tried—whether it was deleting the go.sum file and running go mod tidy or relocating my project directory—I couldn’t seem to get it right.

I resorted to using the go get command to install the required package, which seemingly succeeded without any errors. When I attempted to import it into my project, a frustrating hurdle emerged. The package simply couldn’t be found, despite physically locating it in the /usr/local/go directory. Things got even worse when dealing with local imports because they demanded placement within GOPATH or GOROOT.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.