What does Go language belong to?

青灯夜游
Release: 2023-02-10 16:20:00
Original
3675 people have browsed it

Go language is a statically compiled language. The go language is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google, and Go is developed based on the Inferno operating system. In the Go language, variables have clear types, and the compiler will also check the correctness of the variable type. The general form of declaring variables is "var name type".

What does Go language belong to?

The operating environment of this tutorial: windows10 system, GO 1.18, thinkpad t480 computer.

Go language is a statically compiled language.

Go (also known as Golang) is a statically strongly typed, compiled language developed by Robert Griesemer, Rob Pike and Ken Thompson of Google. The Go language syntax is similar to C, but its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing.

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).

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 string types.

Declaring variables in Go language

Static language (strongly typed language) is a language in which the data type of the variable can be determined at compile time. Most static languages ​​require the use of variables. The data type must be defined before.

In the Go language, variables (variables) have clear types, and the compiler will also check the correctness of the variable type. In mathematical concepts, a variable represents a number that has no fixed value and can be changed. But from a computer system implementation perspective, a variable is one or more segments of memory used to store data.

The general form of declaring variables:

var name type
Copy after login

Among them, var is the keyword to declare the variable, name is the variable name, and type is the type of the variable.

It should be noted that the Go language is different from many programming languages ​​in that it puts the type of the variable after the name of the variable when declaring the variable. The advantage of this is that it can avoid ambiguous declaration forms like in C language, such as int* a, b;. Only a is a pointer and b is not. If you want both variables to be pointers, you need to write them separately. In Go, they can and easily be declared as pointer types:

var a, b *int
Copy after login

When a variable is declared, the system automatically assigns it a zero value of that type: int is 0, float is 0.0, bool is false, string is empty string, pointer is nil, etc. All memory in Go is initialized.

Recommended learning: Golang tutorial

The above is the detailed content of What does Go language belong to?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template