Go Language Tutorial
Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software.
Go was initiated at the end of 2007 by Robert Griesemer, Rob Pike, and Ken Thompson, with later contributions from Ian Lance Taylor, Russ Cox, and others. It was open-sourced in November 2009 and the stable version Go 1 was released early in 2012. Now, Go's development is fully open and it has an active community.
Features of Go Language
- Concise, fast, and secure
- Concurrent, fun, and open-source
- Memory management, array safety, and rapid compilation
Applications of Go Language
Go is designed to be a language for system programming for large central servers that host web servers, storage clusters, or similar applications.
In the field of high-performance distributed systems, Go undoubtedly offers higher development efficiency than most other languages. It provides extensive support for concurrency, which is ideal for game server development.
First Go Program
Next, let's write our first Go program, hello.go (the extension for Go language source files is .go). The code is as follows:
hello.go File
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
To execute Go code, you can use the go run
command.
Executing the above code outputs:
$ go run hello.go
Hello, World!
Additionally, we can use the go build
command to generate a binary file:
$ go build hello.go
$ ls
hello hello.go
$ ./hello
Hello, World!