I'm trying to write some basic Go file and I don't have any code completion / intellisense when working only with go files.
Otherwise, when trying to write JS code for example it works great:
Any thoughts?
You have to set some settings like GOPATH and GOROOT in your IDE.
This is a setup process screenshot of an IDE setting.
Navigate to Preferences | Editor | File Types, find Text or File type auto-detected by context and remove main.go from the file name patterns list.
Related
Since a few days, Goland is not recognizing files named "types.go" as go source files. This is just a problem for syntax highlighting, as the project still runs normally, but it's quite annoying, because it affects both files from my project and from the standard library.
Whenever I try to import the ignored file I get the error:
Build constraints exclude all the Go files in '/[REDACTED]/internal/api/types'
But the file just contains some types definitions, without any build constraint directive.
For example here is a file called types.go
And here the same file renamed
I already tried to invalidate caches, reinstall go and Goland but the problem still remains
types.go is recognized as a plain-text file for some reason. You can navigate to Preferences/Settings | Editor | File Types find File type auto-detected by content or Text and exclude types.go from the patterns list.
Feel free to follow IDEA-258255 to make the process clearer.
I am using the primary GO extension.
I use VS code a lot, now I'm learning GO lang.
And when I open VS Code every time I'm getting this:
Error loading workspace: found module "main.go" twice in the workspace.
While running the code it's giving the right output.
I don't know how to fix this.
Anybody, help me with this error.
It would be better to open in VSCode only one folder with its own go.mod project.
A workspace with multiple go.mod/project should be supported with 1.18
The go command now supports a "Workspace" mode.
If a go.work file is found in the working directory or a parent directory, or one is specified using the -workfile flag, it will put the go command into workspace mode.
In workspace mode, the go.work file will be used to determine the set of main modules used as the roots for module resolution, instead of using the normally-found go.mod file to specify the single main module.
As described in "How to make VScode Go work in a Multi-Module Repo" from Varun Kumar, this used to work:
If you want to work with all the nested modules in a single workspace, there is an opt-in module feature that allows to work with multiple modules without creating workspace folders for each module. Set this in your settings -
"build.experimentalWorkspaceModule": true
But as per september 2022 is deprecated.
See more at gopls documentation "Setting up your workspace".
After my baby run through all of my keyboard, WebStorm is showing all my .yml files as text documents and I can't find a way to return it back how it was.
How do I solve this?
Ensure that YAML plugin is enabled (at Settings/Preferences | Plugins)
If it's there, then check Settings/Preferences | Editor | File Types -- make sure that file type for YAML files has *.yml pattern assigned.
(screenshot is from PhpStorm 2020.3 ... but it is the same in WebStorm)
In case if you are still using 2020.2 or older version, it looks like this:
I am new to Go language and also to the IDE GoLand so I am sorry if this is very basic.
I am currently trying to configure Run Kind for package for all my files, the problem is I cannot seem to get the configuration straight, I get this error:
"can't load package: package Course: unknown import path "Course": cannot find module providing package Course"
My GOROOT is the standard in C: and GOPATH is in my directory of workplace with the folders: scr, bin and pkg. Inside scr is course folder with training files for Go.
I have tried to google every option on how to properly configure the go Build configuration, I might be missing to install packages not sure to be honest, I have installed the gotools and everything from golang.org, and tried following the guide from GoLand in JetBrains but no luck in properly configuring package, or Dir options.
I can create a go Build for each file using Run Kind: File, but I want to create one for all the files inside the folder not one each time I want to run one.
Also I have no idea what -i in Go tool arguments means.
I believe what you need to do is simply enable go module integration. Find the setting at File | Settings | Go | Go Modules (vgo). In that panel also make sure Vgo executable is set to your Project SDK. If it's still not working, enabling the vendor experiment option at File | Settings | Go | Build Tags & Vendoring may help. Be sure your project specific settings aren't overriding these values as well.
I have a small project with several .go files. When I run main.go only this compiles but nothing else, so my application crushes. I understand that I have to change settings in Run -> Edit Configurations, but don't know what to do exactly. IDE also doesn’t see terminal pre-compiled package, so "Package" option instead of "File" doesn't work.
To run the whole project you have to go Run -> Edit Configuration, set Run Kind to Package and type in field Package your project directory name.