Introduction to Golang
Recommended Reading
- Add version info in your Go project
- An Implementation of random.shuffle in golang
- Channel based concurrency in Go
- Clear terminal screen/console in Golang
- Go 1.18 on MacOS: linkname must refer to declared function or variable
- Golang makefile example
- Golang
- Learning Go - Summary of Golang learning material
- Read and Set Environment variables in Go
- Reduce binary file size in Golang
- Summary of web shell in golang
- WaitGroup example in Go
https://devhints.io/go
https://github.com/a8m/golang-cheat-sheet
https://golang.sk/images/blog/cheatsheets/go-cheat-sheet.pdf
Introduction
Go, also known as Golang, is a programming language that was developed by Google in 2007. It is a modern language that is designed to be simple, fast, and efficient. It is widely used for building scalable web applications and network services. In this guide, we will cover the basics of Golang programming language in just 30 minutes.
Installing Golang
Before we start writing our first Go program, we need to install Golang on our system. Golang is available for all major operating systems, including Windows, macOS, and Linux. To install Golang, follow these simple steps:
- Go to the official Go website (
https://golang.org/dl/
) and download the installer for your operating system. - Run the installer and follow the on-screen instructions to complete the installation.
- Once the installation is complete, open your terminal or command prompt and type “go version” to verify that Golang is installed correctly.
Writing Your First Go Program
To write your first Go program, open your favorite text editor and create a new file with the “.go” extension. In this file, type the following code:
```go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
```
Save the file with a name of your choice, let’s say “hello.go”. Now, open your terminal or command prompt and navigate to the directory where you saved the “hello.go” file. Type the following command to compile and run the program:
```bash
go run hello.go
```
You should see the following output in your terminal:
```text
Hello, World!
```
Congratulations! You have just written and executed your first Go program.
Conclusion
In this guide, we covered the basics of Golang programming language in just 30 minutes. We learned how to install Golang and write our first Go program. Golang is a powerful and efficient language that is easy to learn and use. If you are interested in learning more about Golang, there are plenty of online resources available to get you started. Happy coding!