IntelijIDEA (Goland) uses /private/var/folders/ - macos

My Goland's runner (run/debug configurations) uses /private/var/folders/7b/50mzg8x17q55rxfg3b0kpj88xcm2lx/T in os.Args[0]. I know that os.Args[0] is the path to my program, but can I do os.Args[0] to be my working directory in Goland runner?
P.S. Working directory in Edit configurations set properly

I know that os.Args[0] is the path to my program, but can I do os.Args[0] to be my working directory in Goland runner?
No, you cannot make os.Args[0] to be the working directory, since as you correctly identified, it's used to locate your program on disk.
There are two changes you can make:
change your code to stop relying on os.Args[0] and start using os.Getwd() to get the working directory. Then you can edit your Run Configuration via Run | Edit Configurations... | <name of the run configuration> | Working Directory parameter.
if you really want you binary to be in a certain directory, then you can go to Run | Edit Configurations... | <name of the run configuration> | Output directory to have the IDE run the compiler and place the executable wherever you need to.
If you need to make these changes for all future Run Configurations, then edit Run | Edit Configurations... | Templates | Go Build, or Go Test and change either the Working Directory or the Output Directory fields. Existing Run Configurations will not be changed.

Related

How to proper configure "Go Build" and what are the differences between Run Kind

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.

cppcheck-vs-addin - How to remove folder from check

I'm trying to configure cppcheck-vs-addin to automatically check my code on save. So far, so good. However, when I run it on my whole project, I want to exclude several folders (containing sources and headers I have no control on).
Files im trying to exclude are in folder libs\something\files.*
Folder tree is something like
src
| Folder A
| Folder B
libs
| LibsA
| LibsB
What I have tried so far :
-In settings, I added -ilibs to the additionnal arguments field
-In Edit solution suppressions / Excluded include path : .*\\libs\\.* (this should work for headers file, but I also have source files)
-In Edit solution suppressions / Files excluded from check .*\\libs\\.* (this option only seem to work on file name, not on the containing folder, so in this case it does nothing)
Additionnal question, is it possible to view the cppcheck.exe command that is run? It could help understanding what im doing.
If you have installed CPPCheck (and that it is on it's default location), add the path C:\Program Files (x86)\Cppcheck to Environment variable. Now update your pre build events from your project property and invoke cppcheck directly from there. Check this image how you can specify PreBuild Events
Visual Studio C++ Project Property Page to setup Pre-Build Event
Now you can provide argument to exclude directory (like any third party code etc.) from scan.
cppcheck --project=$(MSBuildProjectFullPath) -i "$(ProjectDir)foo\src\" --output-file="$(OutDir)$(TargetName).xml"
--project=$(MSBuildProjectFullPath) selects your current project file (.vcproj or .vcxproj) file,
-i Specifies the directory you want to exclude from scan
--output-file="$(OutDir)$(TargetName).xml" creates the output file in project output directory with analysis results.
To see detail argument list, type cppcheck --help in your command line.

Running GUI apps in Goland IDE

When I build in Terminal, I can use a flag to say I want to build for GUI:
go build -ldflags="-H windowsgui"
However, I just started using JetBrains Goland and I don't how to run GUI apps. What can I do?
go build will only build the application.
To actually run the application, you should go to Run | Edit Configurations... | + | Go Application and configure the application as you need.
Here you will need to set two options:
add -ldflags="-H windowsgui" to the Go tool arguments option
configure the Output directory to be in the same directory as your .manifest file
Setting the output directory is critical in order to run the the application without encountering the following panic panic: TTM_ADDTOOL failed described in this issue.
Then you can run the configuration via Run | Run... and select the configuration you've just created.

How to run the whole project in GoLand?

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.

How to configure haxe build file (HXML) to build from src directory?

I'm trying to build a pre-existing HaxePunk project in sublime (switching away from FlashDevelop).
problem: Error: Could not process argument
Here's my .hxml file:
-neko
-cp "c:/path/to/project/src"
-main Main
I've read somewhere that you shouldn't use the /src convention for your src files. That's annoying, since I want assets and binaries in their own directories separate from src files. How do I properly configure this?
You really should use the the src convention and not stuff everything within the same directory. You also don't want to make the build specific to your machine, so in you example above you don't want an absolute path but a relative one. So try the following:
#content of c:/path/to/project/build.hxml
-neko bin/output.n
-cp src
-main Main
Note that for -cp you use the relative path. The path is relative to where haxe is executed. That usually coincides with where your build.hxml file is, but it is not mandatory.
Also, you didn't specify an output file for neko. Note that you will have to create the directory bin by hand because the compiler will not do that for you and will complain if it doesn't exist.
These information are general and in no way tied with Sublime. Sublime should play just nice with these settings.

Resources