alt
codecamp
Golang Essentials: Installing Go
Previous
Next
☰
About
Profile
Account
Login
Sign Up
Logout
Run
Test
Mark Complete
## Installing Go (Golang) Go, also known as Golang, is an open-source programming language that makes it easy to build simple, reliable, and efficient software. Here's how you can install Go on your machine. ### Step 1: Download Go Visit the official Go downloads page at [https://golang.org/dl/](https://golang.org/dl/) and download the appropriate installer for your operating system (Windows, macOS, or Linux). ### Step 2: Install Go #### For Windows: - Run the downloaded MSI file and follow the prompts to install Go. - By default, Go is installed in the `C:\Go` directory. You can change the location if necessary. - Ensure that the `PATH` environment variable includes the Go binary path `C:\Go\bin`. #### For macOS: - Open the downloaded PKG file and follow the installation wizard. - Go will be installed in `/usr/local/go`. - Verify the installation and set the `PATH` environment variable by adding `/usr/local/go/bin` to your shell profile (e.g., `.bash_profile`, `.zshrc`). #### For Linux: - Extract the archive you downloaded into `/usr/local`, creating a Go directory: ```bash sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz ``` Replace $VERSION, $OS, and $ARCH with the downloaded version, your OS, and architecture, respectively. ### Step 3: Verify Installation Open a terminal or command prompt and type: ```bash go version ``` This command should print the installed version of Go, confirming that Go is successfully installed on your system. ### Conclusion After following these steps, you should have Go installed on your machine, ready for development.
### Practical Exercise: Verifying Go Installation **Objective:** Verify that Go is correctly installed and set up on your system. **Steps:** 1. **Open Terminal or Command Prompt:** - On Windows, open Command Prompt or PowerShell. - On macOS or Linux, open the Terminal. 2. **Check Go Version:** - Type the following command and press Enter: ```bash go version ``` - This command should display the version of Go installed on your system, e.g., `go version go1.17.2 linux/amd64`. 3. **Write a Simple Go Program (Optional):** - Create a new file named `hello.go`. - Write a simple Go program, for example: ```go package main import "fmt" func main() { fmt.Println("Hello, Go!") } ``` - Save the file and run it using the command: ```bash go run hello.go ``` - If Go is correctly installed, this command will print `Hello, Go!` to the console. This exercise ensures that Go is not only installed but also correctly set up to run Go programs on your system.