From 8a6d0f91131ce0edaccb27774230be7bdf75fc05 Mon Sep 17 00:00:00 2001 From: Zakaria Date: Mon, 7 Sep 2026 21:01:20 -0400 Subject: [PATCH 1/8] commit from Arch --- courses/1 | 19 ------------------- courses/main.go | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 courses/1 diff --git a/courses/1 b/courses/1 deleted file mode 100644 index 50c6344..0000000 --- a/courses/1 +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" -) - -const name = "Sara" - -love := "Kahlousha" -number := 43900900 - -func main() { - - const world = "Mykids" - fmt.Println("Hello,", world) - - fmt.Println("I love ", name) - -} diff --git a/courses/main.go b/courses/main.go index b3719a9..f2a82cd 100644 --- a/courses/main.go +++ b/courses/main.go @@ -9,7 +9,7 @@ const ( // In other words, the binary number that is 1 followed by 100 zeroes. Big = 1 << 100 - //shoft it right 99 places + // shoft it right 99 places Small = Big >> 99 ) From 24f546c2d58fc9f80714daaef99c7d8f7865d6de Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 8 Sep 2026 01:38:39 -0400 Subject: [PATCH 2/8] pushing through lazygit --- pointers/pointers.go | 2 -- testingLazyGIT/go.mod | 3 +++ testingLazyGIT/main.go | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 testingLazyGIT/go.mod create mode 100644 testingLazyGIT/main.go diff --git a/pointers/pointers.go b/pointers/pointers.go index dfaeac1..400f5f4 100644 --- a/pointers/pointers.go +++ b/pointers/pointers.go @@ -6,7 +6,6 @@ import ( ) func main() { - var sum float64 var n int @@ -27,5 +26,4 @@ func main() { } average := sum / float64(n) fmt.Println("The average of the total numbers is:", average) - } diff --git a/testingLazyGIT/go.mod b/testingLazyGIT/go.mod new file mode 100644 index 0000000..e092793 --- /dev/null +++ b/testingLazyGIT/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.27.0 diff --git a/testingLazyGIT/main.go b/testingLazyGIT/main.go new file mode 100644 index 0000000..5f40cda --- /dev/null +++ b/testingLazyGIT/main.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + "math" +) + +func main() { + a := 81.0 + fmt.Printf("the total a^2 will be: %f\n", math.Sqrt(a)) +} From c446285d637cf653e99bfbd10283dcb9f85bbbb6 Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 8 Sep 2026 01:40:37 -0400 Subject: [PATCH 3/8] deleting the lazygit test --- testingLazyGIT/go.mod | 3 --- testingLazyGIT/main.go | 11 ----------- 2 files changed, 14 deletions(-) delete mode 100644 testingLazyGIT/go.mod delete mode 100644 testingLazyGIT/main.go diff --git a/testingLazyGIT/go.mod b/testingLazyGIT/go.mod deleted file mode 100644 index e092793..0000000 --- a/testingLazyGIT/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module main - -go 1.27.0 diff --git a/testingLazyGIT/main.go b/testingLazyGIT/main.go deleted file mode 100644 index 5f40cda..0000000 --- a/testingLazyGIT/main.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -import ( - "fmt" - "math" -) - -func main() { - a := 81.0 - fmt.Printf("the total a^2 will be: %f\n", math.Sqrt(a)) -} From 662e044c2c8a324fae9b618a2c36366d20a7b9d5 Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 8 Sep 2026 13:19:05 -0400 Subject: [PATCH 4/8] learning closure | IMPORTANT (revisit) --- closures/go.mod | 3 +++ closures/main.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 closures/go.mod create mode 100644 closures/main.go diff --git a/closures/go.mod b/closures/go.mod new file mode 100644 index 0000000..e092793 --- /dev/null +++ b/closures/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.27.0 diff --git a/closures/main.go b/closures/main.go new file mode 100644 index 0000000..962248e --- /dev/null +++ b/closures/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" +) + +func fib() func() int { + a, b := 0, 1 + return func() int { + a, b = b, a+b + return b + } +} + +func main() { + f := fib() + for x := f(); x < 100; x = f() { + fmt.Println(x) + } +} From dd7e213077799ecbc6d7741735feb511e5d851f9 Mon Sep 17 00:00:00 2001 From: Zakaria Date: Wed, 9 Sep 2026 00:15:16 -0400 Subject: [PATCH 5/8] getting deeper with slices, empty slice vs nil slice | len() and cap() etc.. --- closures/main.go | 3 ++- formatIO/{b.txt => Testb.txt} | 0 formatIO/{c.txt => Testc.txt} | 0 formatIO/{a.txt => testA.txt} | 0 slices/go.mod | 3 +++ slices/main.go | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) rename formatIO/{b.txt => Testb.txt} (100%) rename formatIO/{c.txt => Testc.txt} (100%) rename formatIO/{a.txt => testA.txt} (100%) create mode 100644 slices/go.mod create mode 100644 slices/main.go 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) +} From c7e02d7e06dfd2d5264c968f57d0af246d91df0c Mon Sep 17 00:00:00 2001 From: Zakaria Date: Thu, 10 Sep 2026 21:18:04 -0400 Subject: [PATCH 6/8] fixing the mess --- Homework_1/go.mod | 5 ++++ Homework_1/main.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++ go.work | 1 + go.work.sum | 6 +++++ slices/main.go | 5 ---- 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 Homework_1/go.mod create mode 100644 Homework_1/main.go create mode 100644 go.work.sum diff --git a/Homework_1/go.mod b/Homework_1/go.mod new file mode 100644 index 0000000..8fb439d --- /dev/null +++ b/Homework_1/go.mod @@ -0,0 +1,5 @@ +module letsgo/homework1 + +go 1.27.0 + +require golang.org/x/net v0.59.0 // indirect diff --git a/Homework_1/main.go b/Homework_1/main.go new file mode 100644 index 0000000..775f642 --- /dev/null +++ b/Homework_1/main.go @@ -0,0 +1,59 @@ +package main + +import ( + "bytes" + "fmt" + "os" + "strings" + + "golang.org/x/net/html" +) + +var raw = ` + + + +
+ node one image +

First node first child

+
+
+ node two image +

Second node second child

+
+ + + + ` + +func main() { + doc, err := html.Parse(bytes.NewReader([]byte(raw))) + if err != nil { + fmt.Fprintf(os.Stderr, "Parsing failed: %s\n", err) + os.Exit(-1) + } + + words, images := counterofwordsandimages(doc) + fmt.Printf("There are %d words and %d images\n", words, images) +} + +func counterofwordsandimages(doc *html.Node) (int, int) { + var words, images int + + visit(doc, &words, &images) + + return words, images +} + +func visit(n *html.Node, words, images *int) { + if n.Type == html.TextNode { + *words += len(strings.Fields(n.Data)) + } else if n.Type == html.ElementNode && n.Data == "img" { + *images++ + } + for c := n.FirstChild; c != nil; c = c.NextSibling { + visit(c, words, images) + } +} diff --git a/go.work b/go.work index 5cc5fb3..0fc29cb 100644 --- a/go.work +++ b/go.work @@ -3,6 +3,7 @@ go 1.27.0 use ( ./Composite_Types ./For_If_Switch + ./Homework_1 ./courses ./formatIO ./functions diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..c12a7c5 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,6 @@ +golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA= +golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues= +golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg= +golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc= +golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E= diff --git a/slices/main.go b/slices/main.go index 1ca3f1f..f92e79a 100644 --- a/slices/main.go +++ b/slices/main.go @@ -17,11 +17,6 @@ func main() { 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} From 3880ff31f41161842f9408f3dcc9482976af17be Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 15 Sep 2026 10:41:01 -0400 Subject: [PATCH 7/8] leanring struct... kinda pain in the brain --- struct/go.mod | 3 +++ struct/main.go | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 struct/go.mod create mode 100644 struct/main.go diff --git a/struct/go.mod b/struct/go.mod new file mode 100644 index 0000000..2dc9774 --- /dev/null +++ b/struct/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.27.1 diff --git a/struct/main.go b/struct/main.go new file mode 100644 index 0000000..815ae97 --- /dev/null +++ b/struct/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "time" +) + +type Employee struct { + Name string + EID int + Boss *Employee + Hired time.Time +} + +func main() { + e := Employee{ + Name: "Zack", + EID: 1, + Hired: time.Now(), + } + + fmt.Println(e.Name, e.Hired.Format(time.RFC1123)) +} From 2a24912a064e5e817133fa6b2a90785bd03d692c Mon Sep 17 00:00:00 2001 From: Zakaria Date: Tue, 15 Sep 2026 14:06:38 -0400 Subject: [PATCH 8/8] tags in struct, conversion and comparability --- struct/main.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/struct/main.go b/struct/main.go index 815ae97..ab5d4ec 100644 --- a/struct/main.go +++ b/struct/main.go @@ -1,23 +1,19 @@ package main import ( + "encoding/json" "fmt" - "time" ) -type Employee struct { - Name string - EID int - Boss *Employee - Hired time.Time +type Response struct { + Page int `json:"page"` + Words []string `json:"words, omitempty"` } func main() { - e := Employee{ - Name: "Zack", - EID: 1, - Hired: time.Now(), - } + r := &Response{Page: 1, Words: []string{"Leena", "Sami", "Sara", "Zaki"}} - fmt.Println(e.Name, e.Hired.Format(time.RFC1123)) + j, _ := json.MarshalIndent(r, "", " ") + + fmt.Println(string(j)) }