articles/golang.md: update article

This commit is contained in:
tocariimaa 2025-02-28 19:11:34 -03:00
parent da2a493490
commit 0bc255d184

View file

@ -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))