diff --git a/closures/main.go b/closures/main.go index 962248e..c093aad 100644 --- a/closures/main.go +++ b/closures/main.go @@ -14,7 +14,8 @@ func fib() func() int { func main() { f := fib() - for x := f(); x < 100; x = f() { + fmt.Println("This Fibonacci sequense < 10000") + for x := f(); x < 10000; x = f() { fmt.Println(x) } } diff --git a/formatIO/b.txt b/formatIO/Testb.txt similarity index 100% rename from formatIO/b.txt rename to formatIO/Testb.txt diff --git a/formatIO/c.txt b/formatIO/Testc.txt similarity index 100% rename from formatIO/c.txt rename to formatIO/Testc.txt diff --git a/formatIO/a.txt b/formatIO/testA.txt similarity index 100% rename from formatIO/a.txt rename to formatIO/testA.txt diff --git a/slices/go.mod b/slices/go.mod new file mode 100644 index 0000000..e092793 --- /dev/null +++ b/slices/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.27.0 diff --git a/slices/main.go b/slices/main.go new file mode 100644 index 0000000..1ca3f1f --- /dev/null +++ b/slices/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" +) + +func main() { + var s []int + t := []int{} + u := make([]string, 5) + v := make([]string, 0, 5) + + fmt.Printf("%d, %d, %T, %5t, %#[3]v\n", len(s), cap(s), s, s == nil) + fmt.Printf("%d, %d, %T, %5t, %#[3]v\n", len(t), cap(t), t, t == nil) + fmt.Printf("%d, %d, %T, %5t, %#[3]v\n", len(u), cap(u), u, u == nil) + fmt.Printf("%d, %d, %T, %5t, %#[3]v\n", len(v), cap(v), v, v == nil) + + s = append(s, 1, 1) + fmt.Printf("%d, %d, %T, %5t, %#[3]v\n", len(s), cap(s), s, s == nil) + fmt.Println("*****************************") + fmt.Println("*****************************") + fmt.Println("*****************************") + fmt.Println("*****************************") + fmt.Println("*****************************") + + a := [...]int{1, 2, 3} + + b := a[:1] + + c := b[:2] + + fmt.Printf("a[%p] = %v\n", &a, a) + fmt.Printf("b[%p] = %[1]v\n", b) + fmt.Printf("c[%p] = %[1]v\n", c) +}