Go is a statically typed and compiled high-level programming language crafted at Google to address various programming challenges, including multi-core processing, networking, computing clusters, and web development models.
The syntax of Go resembles a user interface in the language. It boasts a clean, straightforward, and easily understandable structure. Unlike some languages, Go omits default parameters and conventional private and public keywords. Instead, it relies on the initial letter of an identifier to discern its visibility.
Start developing Golang
Before delving into the fascinating problem-solving aspects and syntax of Golang, let's initiate our journey by setting up this language on various operating systems. For the purpose of this guide, we will be using Windows 11.
Install Ubuntu on WSL2
With the Windows Subsystem for Linux (WSL), developers can harness the capabilities of both the Windows and Linux operating systems.
Open the Windows Terminal and utilize it to install Ubuntu.
wsl --install -d Ubuntu
Install Docker desktop
Simple click to download https://www.docker.com/products/docker-desktop/
Once downloaded and installed, open Docker Desktop and navigate to Settings -> Resources -> WSL Integration
, then enable Ubuntu
.
Return to the WSL terminal, and witness the magic with the command:
docker ps
Install gvm
Install GVM, which offers an interface for managing Go versions, by executing the following command:
sudo apt-get update
sudo apt-get install bison
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Install Go and set the version to 1.21.4 using the following commands:
gvm install go1.21.4 -B
gvm use go1.21.4 --default
Switching to other Go versions is easy; simply use the two commands mentioned above.
Start develop with vscode
Dowload here: https://code.visualstudio.com/
Open Visual Studio Code, and install the Go
and WSL
extensions. Choose Open a Remote Window.
Hello World in Golang
Create a directory and navigate into it. Run the following command to initialize your Golang project:
go mod init github.com/reluth/hello-world
Create main.go
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
Open your terminal and run:
go run main.go
Output: Hello World!
Conclusion
Congratulations on completing the initial steps to set up your Go development environment on Windows 11!
By installing WSL2, Docker Desktop, GVM, and configuring Visual Studio Code, you've laid a solid foundation for building Go applications.
Feel free to explore more advanced features of Go, leverage its concurrency model, and tap into the rich ecosystem of libraries and tools available. Happy coding!
Top comments (2)
When it comes to Windows 11, it is currently the best programming environment. I changed to this system myself and I am very satisfied. If someone is looking for a good price for a license for this system, I highly recommend this store: royalcdkeys.com/products/windows-1...
Nice job, I like the way you structure your write up.