Go is a new language, a concurrent, garbage-collected, fast-compiled language. It can compile a large Go program in a few seconds on a single computer. Go provides a model for software construction that makes dependency analysis easier and avoids most C-style include files and library headers. Go is a statically typed language, and its type system has no hierarchy. Therefore users do not need to spend time defining relationships between types, which feels more lightweight than typical object-oriented languages. Go is a completely garbage-collected language and provides basic support for concurrent execution and communication. By its design, Go is intended to provide a method for constructing system software on multi-core machines.
Go (also known as Golang) is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google.
Robert Griesemer, Rob Pike and Ken Thompson began designing Go in September 2007, and later Ian Lance Taylor, Russ Cox joins the project.
Go is developed based on the Inferno operating system. Go was officially announced in November 2009, becoming an open source project and implemented on Linux and Mac OS X platforms, and later added implementation under Windows systems. In 2016, Go was selected as "TIOBE's Best Language of 2016" by the software evaluation company TIOBE.
Currently, Go releases a second-level version every six months (that is, upgrading from a.x to a.y).
Let’s experience the first Go program!
The first Go program
Instance
package main import "fmt" func main() { fmt.Println("Hello, World!") }
Run instance»
Click "Run instance" button to view online instances
Go's syntax is close to C language, but the declaration of variables is different. Go supports garbage collection. Go's parallel model is based on Tony Hall's Communicating Sequential Process (CSP). Other languages that adopt a similar model include Occam and Limbo, but it also has features of Pi operations, such as channel transmission. Plugin support is opened in version 1.8, which means that some functions can now be dynamically loaded from Go.
Compared with C, Go does not include functions such as enumeration, exception handling, inheritance, generics, assertions, virtual functions, etc., but it adds slice type, concurrency, pipes, garbage collection, Language-level support for features such as interfaces. The Go 2.0 version will support generics, but has a negative attitude towards the existence of assertions, and also defends that it does not provide type inheritance.
Unlike Java, Go has built-in associative arrays (also known as hash tables (Hashes) or dictionaries (Dictionaries)), just like the string type.
Tips: Our Go tutorials will help you learn Go from beginner to advanced. If you have any questions, please go to the PHP Chinese website Go Community to ask your questions, and enthusiastic netizens will answer them for you.
Go writing style
There are several regulations in Go, and these are mandatory. When the following regulations are not matched, compilation will generate an error.
There is no need to write a semicolon (;) after each line of the program.
Braces ({) cannot be placed in new lines.
if judgments and for loops do not need to be enclosed in parentheses.
Go also has a built-in gofmt tool, which can automatically clean up excess whitespace in the code, align variable names, and convert aligned spaces into tabs.
Go language features
Simple, fast, safe
- ##Parallel, interesting, open source
- Memory management, array safety, fast compilation
Tips: Each chapter of this tutorial contains many Go examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and use the Go language.
Latest chapter
- Go 语言开发工具 2016-10-18
- Go 错误处理 2016-10-18
- Go 语言接口 2016-10-18
- Go 语言类型转换 2016-10-18
- Go 语言递归函数 2016-10-18
- Go 语言Map(集合) 2016-10-18
- Go 语言范围(Range) 2016-10-18
- Go 语言切片(Slice) 2016-10-18
Related courses
- The latest ThinkPHP 5.1 world premiere video tutorial (60 days to become a PHP expert online training course) 2022-02-17
- Let's briefly talk about starting a business in PHP 2023-01-04
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things 2018-01-25
- Login verification and classic message board 2018-03-02
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum] 2022-06-28
- Quick Start Node.JS Full Version 2022-09-30
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance) 2022-12-08
- Horse soldier spring video tutorial 2022-04-12