Compare commits

..

1 commit

Author SHA1 Message Date
d5ab4eeb57
first hello module 2024-03-18 17:30:03 +01:00
8 changed files with 26 additions and 90 deletions

3
hello/go.mod Normal file
View file

@ -0,0 +1,3 @@
module hello
go 1.22.1

11
hello/hello.go Normal file
View file

@ -0,0 +1,11 @@
package main
import "fmt"
func Hello() string {
return "Hello, world!"
}
func main () {
fmt.Println(Hello())
}

12
hello/hello_test.go Normal file
View file

@ -0,0 +1,12 @@
package main
import "testing"
func TestHello(t *testing.T) {
given := Hello()
expected := "Hello, world!"
if given != expected {
t.Errorf("given: %v, expected: %v", given, expected)
}
}

View file

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

View file

@ -1,10 +0,0 @@
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)
}

View file

@ -1,26 +0,0 @@
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)
}

View file

@ -1,19 +0,0 @@
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))
}

View file

@ -1,28 +0,0 @@
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)
}
}