# Go Lang Installation and Visual Studio Code configuration.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679803888137/83a64281-ac7a-4c52-a136-31047a6a517c.png align="left")

Here are the installation steps for Go on Windows, macOS, and Linux along with configuring Go in VSCode:

### Installing Go on Windows

1. Download the latest Go installer for Windows from the official website: [**https://golang.org/dl/**](https://golang.org/dl/)
    
2. Run the installer and follow the instructions.
    
3. After installation, open Command Prompt or PowerShell and type the following command to verify that Go is installed correctly:
    

```go
go version
```

1. If Go is installed correctly, you should see the version number printed in the terminal.
    
2. Next, set up the GOPATH environment variable. This variable specifies the location of your Go workspace, which is where you will store your Go projects and packages. To set up the GOPATH variable, follow these steps:
    
    * Open the Start menu and search for "Environment Variables."
        
    * Click "Edit the system environment variables."
        
    * Click "Environment Variables."
        
    * Under "System Variables," click "New" and add the following:
        
        * Variable name: GOPATH
            
        * Variable value: C:\\Users\\YourUserName\\go
            
    * Replace "YourUserName" with your actual username.
        
3. Finally, install the Go extension in VSCode by going to the extensions marketplace and searching for "Go." Click "Install" and then reload VSCode.
    

### **Installing Go on macOS/OSX**

1. Download the latest Go installer for macOS from the official website: [**https://golang.org/dl/**](https://golang.org/dl/)
    
2. Run the installer and follow the instructions.
    
3. After installation, open Terminal and type the following command to verify that Go is installed correctly:
    
    ```go
    go version
    ```
    
4. If Go is installed correctly, you should see the version number printed in the terminal.
    
5. Next, set up the GOPATH environment variable. This variable specifies the location of your Go workspace, which is where you will store your Go projects and packages. To set up the GOPATH variable, follow these steps:
    

* Open Terminal and type the following command:
    
* ```go
        nano ~/.bash_profile
    ```
    
    * This will open the .bash\_profile file in the Nano text editor.
        
    * Add the following line to the file
        
    * ```go
            export GOPATH=$HOME/go
        ```
        
    * Save the file and exit Nano by pressing "Control + X" and then "Y" and "Enter."
        
    * Finally, run the following command to reload your .bash\_profile:
        
    * ```go
            source ~/.bash_profile
        ```
        
    * Finally, install the Go extension in VSCode by going to the extensions marketplace and searching for "Go." Click "Install" and then reload VSCode.
        
    
    ### **Installing Go on Linux**
    
    1. Download the latest Go binary archive for Linux from the official website ([**https://golang.org/dl/**](https://golang.org/dl/)).
        
    2. Extract the downloaded archive to `/usr/local` using the following command:
        
    
    ```go
    sudo tar -C /usr/local -xzf go<version>.linux-<architecture>.tar.gz
    ```
    
    Replace `<version>` and `<architecture>` with the appropriate values for your system. 3. Add the Go binary directory to your `PATH` environment variable by adding the following line to your `~/.profile` or `~/.bashrc` file:
    
    ```go
    export PATH=$PATH:/usr/local/go/bin
    ```
    
    1. Once the installation is complete, open the terminal and type `go version` to verify that Go is installed.
        
    
    ### **Configuring Go on VSCode**
    
    1. Install the Go extension for VSCode by clicking on the Extensions icon in the left sidebar, searching for "Go" and clicking Install.
        
    2. Once the extension is installed, open the Settings tab in VSCode by clicking on the gear icon in the bottom left corner and selecting "Settings".
        
    3. In the search bar, type "go.gopath" and set the value to the directory where you will store your Go projects. This is where Go will look for packages and dependencies.
        
    4. In the search bar, type "go.toolsGopath" and set the value to the same directory as the "go.gopath" setting. This is where Go will store its tools and binaries.
        
    5. Close the Settings tab and create a new folder for your Go project.
        
    6. Open the new folder in VSCode and create a new file called "main.go".
        
    7. Add the following code to the "main.go" file:
        
    
    ```go
    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello, world!")
    }
    ```
    
    1. Save the file and press F5 to run the code. You should see "Hello, world!" printed on the terminal.
        
    
    That's it! You should now be able to use Go on VSCode.
    

I hope this helps, you!!

**More such articles:**

[https://medium.com/techwasti](Link)

[https://www.youtube.com/channel/UCiTaHm1AYqMS4F4L9zyO7qA](Link)

[https://www.techwasti.com/](Link)

\==========================\*\*=========================

**If this article adds any value to you then please clap and comment.**

**Let’s connect on** [**Stackoverflow**](http://stackoverflow.com/users/3187349/maheshwar-ligade)**,** [**LinkedIn**](https://in.linkedin.com/in/maheshwar-ligade-14447841)**, &** [**Twitter**](https://twitter.com/MaheshwarLigade)**.**
