2022-12-03
This commit is contained in:
30
chapter-2/05_naming_variables_constants.go
Normal file
30
chapter-2/05_naming_variables_constants.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// any unicode letter/number is valid for names in go - don't use them
|
||||
|
||||
// snake_case is rarely used, use camelCase
|
||||
|
||||
// prefer shorter names, k,v for key,value in for loops etc
|
||||
|
||||
// if using single letter var names, you can follow the type. E.g i for int, b for bool
|
||||
|
||||
// when naming vars/consts in the package level, favour more descriptive names
|
||||
// !!! the smaller the scope of the variable, the shorter the name !!!
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
_0 := 0_0
|
||||
_ᔜ := 20
|
||||
π := 3
|
||||
a := "hello" // Unicode U+FF41
|
||||
fmt.Println(_0)
|
||||
fmt.Println(_ᔜ)
|
||||
fmt.Println(π)
|
||||
fmt.Println(a)
|
||||
|
||||
a = "hello" // Unicode U+FF41
|
||||
a := "goodbye" // standard lowercase a (Unicode U+0061)
|
||||
fmt.Println(a)
|
||||
fmt.Println(a)
|
||||
}
|
||||
Reference in New Issue
Block a user