Installing Go on Windows 11 and Running Your First "Hello World" Program

👋 Welcome to my Hashnode profile! I'm a passionate technologist with expertise in AWS, DevOps, Kubernetes, Terraform, Datree, and various cloud technologies. Here's a glimpse into what I bring to the table: 🌟 Cloud Aficionado: I thrive in the world of cloud technologies, particularly AWS. From architecting scalable infrastructure to optimizing cost efficiency, I love diving deep into the AWS ecosystem and crafting robust solutions. 🚀 DevOps Champion: As a DevOps enthusiast, I embrace the culture of collaboration and continuous improvement. I specialize in streamlining development workflows, implementing CI/CD pipelines, and automating infrastructure deployment using modern tools like Kubernetes. ⛵ Kubernetes Navigator: Navigating the seas of containerization is my forte. With a solid grasp on Kubernetes, I orchestrate containerized applications, manage deployments, and ensure seamless scalability while maximizing resource utilization. 🏗️ Terraform Magician: Building infrastructure as code is where I excel. With Terraform, I conjure up infrastructure blueprints, define infrastructure-as-code, and provision resources across multiple cloud platforms, ensuring consistent and reproducible deployments. 🌳 Datree Guardian: In my quest for secure and compliant code, I leverage Datree to enforce best practices and prevent misconfigurations. I'm passionate about maintaining code quality, security, and reliability in every project I undertake. 🌐 Cloud Explorer: The ever-evolving cloud landscape fascinates me, and I'm constantly exploring new technologies and trends. From serverless architectures to big data analytics, I'm eager to stay ahead of the curve and help you harness the full potential of the cloud. Whether you need assistance in designing scalable architectures, optimizing your infrastructure, or enhancing your DevOps practices, I'm here to collaborate and share my knowledge. Let's embark on a journey together, where we leverage cutting-edge technologies to build robust and efficient solutions in the cloud! 🚀💻
Introduction
In this blog, we'll guide you through the process of installing Golang on Windows 11 and writing your first Go program, "Hello World." Follow these steps to get started with Golang on your Windows machine.
Step 1: Downloading and Installing Go
Visit the Official Go Website:
- Go to the official Go download page.
Download the Installer:
- Click on the Windows download link to get the installer (e.g.,
go1.22.5.windows-amd64.msi).
- Click on the Windows download link to get the installer (e.g.,
Run the Installer:
Double-click the downloaded
.msifile to run the installer.Follow the prompts to complete the installation. The installer will automatically add Go to your system PATH.
Step 2: Verifying the Installation
Open Command Prompt:
- Press
Win + R, typecmd, and hitEnter.
- Press
Check the Go Version:
Type
go versionand pressEnter.You should see the installed Go version (e.g.,
go version go1.22.5 windows/amd64).
Step 3: Setting Up Your Go Workspace
Create a Workspace Directory:
Open Command Prompt and navigate to your preferred location.
Create a new directory for your Go projects:
mkdir GoProjects cd GoProjects
Set the GOPATH Environment Variable:
The GOPATH is the root directory of your workspace.
You can set it in your environment variables. Right-click on
This PC, selectProperties, thenAdvanced system settings, and finallyEnvironment Variables.Add a new user variable named
GOPATHand set its value to the path of your workspace directory (e.g.,C:\Users\YourUsername\GoProjects).
Step 4: Writing Your First Go Program
Create a New Directory for Your Program:
Inside your workspace directory (
GoProjects), create a new directory for your "Hello World" program:mkdir hello cd hello
Create the Go Source File:
Open your favorite text editor or IDE (such as Visual Studio Code).
Create a new file named
hello.goand add the following code:package main import "fmt" func main() { fmt.Println("Hello, World!") }
Step 5: Running Your Go Program
Navigate to Your Program's Directory:
Open Command Prompt and navigate to the directory containing
hello.go:cd C:\Users\YourUsername\GoProjects\hello
Build and Run the Program:
To compile and run your program, use the following command:
go run hello.goYou should see the output:
Hello, World!
Explanation of the "Hello World" Program
package main: Defines the package name. The
mainpackage is a special package in Go that defines a standalone executable program.import "fmt": Imports the
fmtpackage, which provides formatting functions for input and output.func main(): The
mainfunction is the entry point of the program. When you run the program, themainfunction is executed.fmt.Println("Hello, World!"): Prints the string "Hello, World!" to the console. The
Printlnfunction adds a newline character at the end.
Conclusion
Congratulations! You've successfully installed Go on Windows 11 and run your first Go program. In this blog, we've covered the installation steps, setting up your workspace, and writing and running a simple "Hello World" program.
Stay tuned for more tutorials and tips on mastering Golang! Happy coding!




