Installing & Verifying GO in VS at MAC

aditya goel
4 min readJan 26, 2022

--

Step #1.) First download the GO-package :-

Step #2.) Proceed to install the GO-package, by double clicking on the same :-

Step #3.) Verify now, whether the GO has been installed or not ?

Step #4.) Verify the path, where GO has been installed ?

Step #5.) Verify the PATh variable, which would indicate where GO has been installed.

Step #6.) Now, head to VS-Studio Code and install the plugin of GO in VS :-

Step #7.) Now, In VSCode, goto View → Command Palette → Locate Configured GO Tools. With this, we can see output of GO related variables :-

Step #8.) Now, head to our working directory and create a file called as “go.mod” by this command and observe that, we have a new file being created under this directory.

go mod init hello

Step #9.) Let’s create a “main.go” file and write some sample code of GOLANG :-

// You can edit this code!
// Click here and start typing.
package main
import "fmt"
func main() {
var companies = [4]string{"Amazon", "Microsoft", "Yahoo", "Google"}
fmt.Println("Array of Strings is: ", companies)
var intArrays [5]int
intArrays[0] = 78
intArrays[1] = 85
intArrays[2] = 91
intArrays[3] = 93
intArrays[4] = 97
fmt.Println("Array of Integers is: ", intArrays)
fmt.Println("Size of IntegersArray is: ", len(intArrays))
fmt.Println("Size of StringArray is: ", len(companies))
}

Step #10.) Let’s now try running this sample go file by clicking on :- Run → Run Without Debugging.

Step #11.) Let’s observe the output of the same :-

Step #12.) Another way of executing the GO Programs is, using Integrated Terminal by using command :-

go run <NAME_OF_FILE.go>

Step #13.) We can also execute the GO files directly using below command too:-

go run .

Step #13.) We can also generate the Build along with RunTime from a given source file of GO :-

go build .
  • Upon performing the build operation, note that compiled binary file specifically designed for MAC operating-system, has been generated with name “hello”.
  • We can execute this executable binary directly ONLY at this particular OS i.e. MAC and it shall NOT work on Windows.

That’s all in this section. If you liked reading this blog, kindly do press on clap button multiple times, to indicate your appreciation. We would see you in next series.

References :-

--

--