Compare commits

...

5 commits

5 changed files with 90 additions and 0 deletions

7
src/01-hello.go Normal file
View file

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}

10
src/02-values.go Normal file
View file

@ -0,0 +1,10 @@
package main
import "fmt"
func main() {
fmt.Println("concat" + " " + "strings")
fmt.Println("1 + 1 =", 1 + 1)
fmt.Println("7.0 / 3.0 =", 7.0 / 3.0)
fmt.Println(true && false)
}

26
src/03-variables.go Normal file
View file

@ -0,0 +1,26 @@
package main
import "fmt"
func main() {
var a = "initial"
fmt.Println(a)
a = "changed"
fmt.Println(a)
var b, c int = 1, 2
fmt.Println("b=", b, ", c=", c)
var d = true
fmt.Println(d)
var e int
fmt.Println(e)
f := "short"
fmt.Println(f)
f = "changed short"
fmt.Println(f)
}

19
src/04-constants.go Normal file
View file

@ -0,0 +1,19 @@
package main
import (
"fmt"
"math"
)
const s string = "this is a constant"
func main() {
fmt.Println(s)
const n = 500000000
const d = 3e20 / n
fmt.Println(d)
fmt.Println(int64(d))
fmt.Println(math.Sin(n))
}

28
src/05-for.go Normal file
View file

@ -0,0 +1,28 @@
package main
import "fmt"
func main() {
i := 1
for i <= 3 {
fmt.Println("number i =", i)
i = i + 1
}
for j := 0; j < 3; j++ {
fmt.Println("number j =", j)
}
for {
fmt.Println("loop with no condition")
break
}
for n := range 6 {
if n%2 == 0 {
fmt.Println("even number n = ", n)
continue
}
fmt.Println("odd number n = ", n)
}
}