Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to understand the value types of Go language

Shulou Source: shulou.com Published: 2022-06-01 00:54:13 09月25日 Update

Go language value type how to understand, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

What is gogo is the abbreviation of golang? golang is a static strongly typed, compiled, concurrent and garbage-collected programming language developed by Google. Its syntax is similar to C language, but it does not include functions such as enumeration, exception handling, inheritance, generics, assertions, virtual functions and so on.

Go By Example- value type

The data types of the Go language can be divided into value types and reference types, which are first mentioned here.

Value Typ

Value types: in the go language, int, float, bool, and string are all value types. Variables that use these types point directly to values that exist in memory, and the values of variables of value types are stored in the stack. When you use the equal sign = to assign the value of one variable to another, such as j = I, you actually copy the value of I in memory. You can get the memory address of the variable I through & I.

Features: variables store values directly, memory is usually allocated in the stack, and the stack is released after the function call

Fmt.Println is similar to the print function in Python.

From the above figure, we can find that we can calculate directly in fmt.Println, and we also support the use of "," to separate the output. Here, the integer and floating point numbers are added respectively, and the Bool type is logically operated. These operations are basically written in the same way as Python. Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Type variable language memory operation function content function storage help support clarity similarity almost picture above lieutenant general writing addition hairstyle can be done through Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB NVidia Docker Shulou Technology