Get the App
SLTechnology News&Howtos  ›  Development  › 

Case Analysis of variable declaration in Go language

Shulou Source: shulou.com Published: 2022-06-01 02:34:22 10月05日 Update

In this article Xiaobian for you to introduce in detail "Go language variable declaration case analysis", the content is detailed, the steps are clear, the details are handled properly, I hope this "Go language variable declaration case analysis" article can help you solve your doubts, following the editor's ideas slowly in depth, together to learn new knowledge.

Variable declaration

Specifies the variable type, which defaults to zero if it is not initialized.

Var v_name v_typev_name = value

Zero is the default value set by the system when the variable is not initialized.

Example

Package main

Import "fmt"

Func main () {

/ / declare a variable and initialize

Var a = "RUNOOB"

Fmt.Println (a)

/ / zero value without initialization

Var b int

Fmt.Println (b)

/ / zero value of bool is false

Var c bool

Fmt.Println (c)

}

The execution result of the above example is:

RUNOOB0false has read this, the "Go language variable declaration example analysis" article has been introduced, want to master the knowledge of this article still need to practice and use to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Variables examples case analysis language analysis articles content appropriate that is ideas new knowledge more steps knowledge knowledge points articles types systems details results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Huawei Redmi OPPO Reno