Preface: This project is used to record my (647) study and accumulation in Go language direction. This series is fairly basic and is recommended for developers who want to get started with Go. The directory is as follows: Go language foundation (1) — Introduction, environment configuration, HelloWorld Go language foundation (2) — Basic common syntax Go language foundation (3) — Object-oriented programming Go language foundation (4) — high-quality fault tolerance Go language foundation (5) — Concurrent programming Go language foundation (6) — Testing, Reflection, Unsafe Go Basics (7) — Architecture & Common Tasks Go Basics (8) — Performance Tuning


First, the origin of Go

Go, or Golang. It was developed by Google engineers in 2007. In 2009, it was officially released.

Why it was born: New challenges in server software development

  1. Multi-core hardware architecture.
  2. Very large scale distributed computing cluster.
  3. The Web model leads to unprecedented scale of development and speed of update.

The founder of Go

  1. Rob Pike: Early developer of Unix and founder of UTF-8.
  2. Ken Thompson: Creator of Unix, C, Turing Award, 1983.
  3. Robert Griesemer: Developer of Google’S V8 JS Engine and Hot Spot.

Three, Go language features

1. Simple

Go has only 25 keywords

Key words:

Go C C++
25 37 84

2. Efficient

  • Supports the garbage collection mechanism.
  • Supports “pointer” direct memory access.

3. Productivity

  • Only composition (composition) is supported.
  • Inheritance is not supported.

The difference between composition and inheritance: Inheritance (IS-A) : A subclass inherits its parent class’s property and method implementation. Composition (HAS-A) : Class A has an instantiated object of class B, which in turn has the capability of class B.

Install Go

  • First download and install Go: Go official website download address
  • Download the IDE and related Go plug-ins: for personal useVSCodeAnd, of course,sublime,AtomYou can wait.

PS: After the download, run the go version command to check whether the installation is successful.

go version
Copy the code

If successful, the following page is displayed:

Write the first Go program

  • Step 1: Create a hello_world.go file.

  • Step 2: Write the following code:

Import (// introduces the code dependency library"fmt"
	"os") // Function implementation funcmain() {

	fmt.Println("Hello World") os.exit (0) // Program Exit status}Copy the code
  • Open the terminal and find the relevant source directory.

Compile command:

go build hello_world.go
Copy the code

Run the command:

go run hello_world.go
Copy the code

Finally, this series is summed up and completed in practice under the technical sharing of Teacher CAI Chao. Thank you for your technical sharing.

PS: Attached, share link: Go Language from entry to actual combat.

I wish you success in your studies and success in your work. Thank you very much!