go-updates: Added variables and constants additions (#1931)

Co-authored-by: Zhenya Sikirzhitsky <zhenya_sikirzhitsky@epam.com>
This commit is contained in:
Genesis 2023-01-04 12:44:10 +03:00 committed by GitHub
parent d7fc5ccf02
commit 66b6648e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

33
go.md
View File

@ -51,19 +51,52 @@ Or try it out in the [Go repl](https://repl.it/languages/go), or [A Tour of Go](
```go
var msg string
var msg = "Hello, world!"
var msg string = "Hello, world!"
var x, y int
var x, y int = 1, 2
var x, msg = 1, "Hello, world!"
msg = "Hello"
```
#### Declaration list
``` go
var (
x int
y = 20
z int = 30
d, e = 40, "Hello"
f, g string
)
```
#### Shortcut of above (Infers type)
```go
msg := "Hello"
x, msg := 1, "Hello"
```
### Constants
```go
const Phi = 1.618
const Size int64 = 1024
const x, y = 1, 2
const (
Pi = 3.14
E = 2.718
)
const (
Sunday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
)
```
Constants can be character, string, boolean, or numeric values.