Go Tutorial
Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software.
Go was developed starting in late 2007 by Robert Griesemer, Rob Pike, and Ken Thompson, later joined by Ian Lance Taylor, Russ Cox, and others, and was finally open-sourced in November 2009, with the stable Go 1 released in early 2012. Today Go's development is completely open and has an active community.
Features of Go
- Simple, fast, and safe
- Concurrent, fun, and open-source
- Memory management, array safety, and fast compilation
Uses of Go
Go is designed as a systems programming language for giant central servers hosting web servers, storage clusters, or similar purposes.
In the field of high-performance distributed systems, Go undoubtedly offers higher development efficiency than most other languages. It provides massive concurrency support, which is ideal for game server development.
Your first Go program
Next, let's write our first Go program, hello.go (the extension of Go source files is .go); the code is as follows:
The hello.go file
package
main
import
"fmt"
func
main
()
{
fmt
.
Println
(
"Hello, World!"
)
}
Run Example »
To execute Go code, you can use the go run command.
Executing the above code outputs:
$ go run hello.go
Hello, World!
In addition, we can use the go build command to generate a binary file:
$ go build hello.go
$ ls
hello hello.go
$ ./hello
Hello, World!