articles/golang.md: update article
This commit is contained in:
parent
da2a493490
commit
0bc255d184
1 changed files with 3 additions and 2 deletions
|
@ -44,7 +44,8 @@ package main
|
|||
|
||||
import "fmt"
|
||||
|
||||
// functions starting in uppercase are exported
|
||||
// Functions starting in uppercase are exported, not needed here but for
|
||||
// demonstration purposes.
|
||||
func Fact(n uint) uint {
|
||||
res := uint(1)
|
||||
for n > 0 { // no while loop in Go
|
||||
|
@ -56,7 +57,7 @@ func Fact(n uint) uint {
|
|||
|
||||
func main() {
|
||||
// Array literal, the `...` is used to infer its size
|
||||
// If you instead left the [] empty it becomes an slice (heap allocated)
|
||||
// If you instead left the [] empty it becomes a slice (heap allocated)
|
||||
ns := [...]uint{0, 4, 10, 1, 5, 8}
|
||||
for _, n := range ns {
|
||||
fmt.Printf("Fact(%d) = %d\n", n, Fact(n))
|
||||
|
|
Loading…
Add table
Reference in a new issue