Initial commit - learning the basics

This commit is contained in:
V
2025-08-30 13:55:18 +01:00
commit 194ca9b7a9
27 changed files with 830 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
package main
import (
"fmt"
"math/cmplx"
)
var c, java, python bool
var n, m int = 1, 2
var (
ToBe bool = false
MaxInt uint64 = 1<<64 - 1
z complex128 = cmplx.Sqrt(-5 + 12i)
)
func add(x, y int) int {
return x + y
}
func swap (x, y string) (string, string) {
return y, x
}
func split(sum int) (x, y int) {
x = sum * 4 / 9
y = sum - x
return
}
func main() {
fmt.Println(add(42,13))
x := [3]int{2,1,1}
fmt.Println(x)
a, b := swap("hello", "go")
fmt.Println(a, b)
fmt.Println(split(17))
var i int
fmt.Println(i, c, python, java)
c, java, python := true, true, "no!"
k := 3
fmt.Println(k, n, m, c, python, java)
fmt.Printf("Type: %T Value: %v\n", ToBe, ToBe)
fmt.Printf("Type: %T Value: %v\n", MaxInt, MaxInt)
fmt.Printf("Type: %T Value: %v\n", z, z)
g := 42
f := float64(g)
u := uint(f)
fmt.Println(g, f, u)
const Pi = 3.14
const World = "世界"
const Truth = true
fmt.Println("Hello", World)
fmt.Println("Happy", Pi, "Day")
fmt.Println("Go rules?", Truth)
}
+12
View File
@@ -0,0 +1,12 @@
package main
import (
"fmt"
"math/rand"
"math"
)
func main() {
fmt.Println("My favorite number is", rand.Intn(10))
fmt.Println(math.Pi)
}