Introduction 概述
This chapter will cover basic concepts of the Go programming language, which will help us to develop our web server application in the later chapters. We will talk and learn about variables, constants, data types (simple and complex ones), give some best practices. At the beginning of the chapter, we will give a short introduction and history of the Go programming anguage as well as some advantages compared to ther programming languages.
本章将介绍Go编程语言的基本概念,这将有助于我们在后面的章节中开发web服务器应用程序。我们将讨论和学习变量、常量、数据类型(简单的和复杂的),并给出一些最佳实践。在本章的开头,我们将给出一个简短的介绍和Go编程语言的历史,以及与其他编程语言相比的一些优势。
Structure 文章结构
In this chapter, we will discuss the following topics:
- Fundamentals of Go programming language
- Advantages of Go programming language
- Keywords
- Packages
- Basic data types
- Variables
- constants
- complex data types
- Control structures
- Functions
在本章中,我们将讨论以下主题:
- Go编程语言基础
- Go编程语言的优势
- 关键字
- 包
- 基本数据类型
- 变量
- 常量
- 复杂的数据类型
- 控制结构
- 函数
Fundamentals of Go programming language
Go编程语言基础
Go is a procedural programming language based on concurrent programming. In procedural programming languages, procedures are stitched together to form a program. It is mainly used for the development of system and server software because it is designed to be performant.
Go是一种基于并发编程的过程式编程语言。在过程式编程语言中,过程被拼接在一起形成一个程序。它主要用于系统和服务器软件的开发,因为它的设计是高性能的。
Designed in 2007by Google employees Roert Griesemer, Rob Pike, and Ken Thompson as a part of an experiment, with the idea to improve programming productivity. Designers wanted to eliminate bad practices from the programming language used inside Google, but keep the good ones, in order to create an officient and elegant programming language that can be used for the development of complex software solutions.
2007年由Google员工Roert Griesemer、Rob Pike和Ken Thompson设计,作为实验的一部分,旨在提高编程效率。设计师们想要从谷歌内部使用的编程语言中剔除不好的做法,但保留好的做法,以创造一种高效而优雅的编程语言,可用于开发复杂的软件解决方案。
Go was offcially announced in November 2009, and the first version (1.0) was released in March 2012. As we can see Go is a relatively young and new programming language.
Go于2009年11月正式发布,第一个版本(1.0)于2012年3月发布。正如我们所看到的,Go是一种相对年轻的新编程语言。
Go has the official logo and mascot. The oficial logo represents stylized italic GO, with trailing streamlines, which symbolize speed and efficiency. The official mascot is a Gopher (rodent from North and Gentral America) and was desined by Renee French.
Go有官方标志和吉祥物。官方标志代表了风格化的斜体GO,拖尾流线,象征着速度和效率。官方吉祥物是一只地鼠(来自北美和北美的啮齿动物),由Renee French设计。
The latest stable version of Go is 1.20 released in February 2023. Some of the companies where Go is represented are BBC, Uber, Docker, Intel, and of course Google.
Go的最新稳定版本是1.20,于2023年2月发布。BBC、Uber、Docker、英特尔,当然还有谷歌都是Go语言的代表公司。
Advantages of Go programming language
Go编程语言的优势
Go has become one of the most popular programming languages in the past couple of years, according to the site Stack Overflow. According to Linkedin, there are more than 4000 open positions for Go developers in the United States alone.
根据Stack Overflow网站的数据,Go在过去几年中已经成为最受欢迎的编程语言之一。根据领英(Linkedin)的数据,仅在美国就有4000多个Go开发者的空缺职位。
What makes Go so popular? Here are some main advantages of the Go programming language:
- Easy and fast to learn: Go is designed to be as simple as possible, so the basics can be learned in a few hours.
- Good standard library: We can execute all tasks and find solutions for usual problems without complex workarounds.
- Fast build time: Large projects can be compiled and built in less than 30 seconds.
- Performance: Large-scale applications with a lot of input/output can be easily handled.
是什么让Go如此受欢迎?下面是Go编程语言的一些主要优点:
- 易于学习:Go被设计得尽可能简单,所以基本知识可以在几个小时内学会。
- 良好的标准库:我们可以执行所有任务并找到解决常见问题的方法,而无需复杂的变通方法。
- 快速构建时间:大型项目可以在不到30秒的时间内编译和构建。
- 性能:具有大量输入/输出的大规模应用程序可以轻松处理。