renamed to main.go and wrote some beginner code.

This commit is contained in:
Ziad Arafat committed 2024-01-06 17:47:26 -07:00
1 parent 2211a6d3de
commit 8164b83b0a
1 file changed
+49
+49
View File
@@ -0,0 +1,49 @@
package main
import (
"fmt"
"math"
"math/rand"
"time"
)
func add(x, y int) int {
return x + y
}
func main() {
fmt.Println("Hello, World!")
fmt.Println("The time is", time.Now())
fmt.Println("My favorite number is", rand.Intn(10))
fmt.Printf("Now you have %v problems.\n", math.Sqrt(7))
fmt.Println(math.Pi)
fmt.Println(add(42, 13))
var i, j int = 1, 2
fmt.Println(i, j)
var c, python, java = true, false, "no!" // type inference
// without type inference
// var c bool = true
// var python bool = false
// var java string = "no!"
fmt.Println(c, python, java)
const Pi float32 = 3.14
fmt.Println(Pi)
var sum int = 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println(sum)
}