原文作者: Naveen R
译者:jacsice 转载请注明出处。更多进阶译文请查看咔叽咔叽
这是golang入门系列里面的第一篇。
什么是 Golang
is an open source, compiled and statically typed programming language created by google.
The primary focus of Golang is to make the development of highly available and scalable web apps simple and easy.
是google创造的开源的,可编译的,静态类型的编程语言。
Golang的主要关注点在于使开发高可用的,可扩展的web apps简单便捷。
Why Golang
Why would you choose Golang as your service side programming language when there are tonnes of other languages such as python, ruby, nodejs... that do the same job.
Here are some of the pros which I found in choosing Go
- Concurrency is an inherent part of the language. As a result writing multithreaded programs is a piece of cake. This is achieved by Goroutines and channels which we will discuss later in the upcoming tutorials.
- 并发是该语音与生俱来的部分。使得写多线程的程序小菜一碟。这些是通过goroutines和channels完成的。
- Golang is a compiled language. The source code is compiled to native binary. This is missing in interpreted languages such as JavaScript used in nodejs.
- Golang是一种编译语言。源代码被编译为二进制文件。在诸如nodejs中使用的JavaScript之类的解释语言中缺少此功能。
- The language spec is pretty simple. The entire spec fits in a page and you can even use it to write your own compiler :)
- 语言的规范非常简单。全部的规范都在这一个页面里面,你甚至可以用它来当做你的编译器。
- The go compiler supports static linking. All the go code can be statically linked into one big fat binary and it can be deployed in cloud servers easily without worrying about dependencies.
- go编译器支持静态链接。所有go代码都可以静态链接到一个大的二进制文件中,并且可以轻松地部署在云服务器中,而不必担心依赖性。
Installation
Golang is supported on all the three platforms Mac, Windows and Linux. You can download the binary for the corresponding platform from golang.org/dl/
Mac OS
Download the OS X installer from golang.org/dl/. Double tap to start the installation. Follow the prompts and this should have Golang installed in
and would have also added the folder
to your PATH environment variable.
Windows
Download the MSI installer from golang.org/dl/. Double tap to start the installation and follow the prompts. This will install Golang in location
and will also add the directory
to your path environment variable.
Linux
Download the tar file from golang.org/dl/ and unzip it to /usr/local.
Add /usr/local/go/bin to the PATH environment variable. This should install go in linux.