Go Config file in Linux

Hi,
I’m relatively new to the language although I am familiar with other languages, and have been following many of the tutorials on how to program in Go. I work on a couple of machines, and I see that a colleague of mine was demonstrating (on his Windows machine) how to change parameters in his config file (GOOS and GOARCH) so that he could cross compile for other operating systems and architectures.

At home I run purely on Ubuntu Linux, and I have VSCode installed along with the Go compiler etc. It’s all the latest version as of 27 July 2020. I have been completely unsuccessful in finding any config file for my Go installation though (either under Go itself, or under any given project that I have created using Go example/practice code. I would think the configuration file would be associated with a particular project (IE so I can be creating two independent applications, one for say Linux, and the other for Windows, without routinely swapping the compiler back and forth. Is my thinking correct? If that’s the case I would expect to see the relevant config file under my src directory, along with my Go code, but as I say, it isn’t there.

If this file doesn’t exist by default, how do I go about creating it?

Thanks for the help. Go is proving to be a very nice language indeed (I come from a C and object oriented Pascal background).

I’m not aware of any config file.

Just set environment variables when running go:

$ GOOS=windows GOARCH=amd64 go build

You might be looking for the “Launch Configurations” from Visual Studio Code, see https://github.com/golang/vscode-go/blob/master/docs/debugging.md#launch-configurations

Sorted, thanks. That’s ultimately what I did. I originally did find that you can (via the terminal window) edit Go environment variables, but I was still having issues with VS Code cross compiling. Worked a charm though, if I opened a terminal window and built from there, similar to your suggestion. Thanks again.

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