Golang

1. Stream

1.1. 0x22B2

  • post theGoPL, will finish of TDD with Go
  • have found it to be productive when starting out building a new service
  • not so much integrating into existing ones : will solidify the habit of writing tests

1.2. 0x22AF

  • finished Chapter 4 of cloud native Go
  • aggressively, rigorously cementing the detailed fundamentals now with "The Go Programming Language" and getting used to reading the docs

1.3. 0x22AB

  • finished "Let's Go"
  • will do "Let's Go Further" sometime down the lane
  • getting into "Cloud Native Go" now though
  • will soon start with open source contribs in the CNCF landscape
  • The concurrency model of golang : CSP-Concurrency
  • choosing golang as my principal language for the close future
  • is the lingua-cloud-native and do see myself personally benefitting moving away from the lisp romantic that I am for some time and building practical stuff.
  • as usual, I begin with verifying org babel works

    package main
    
    import "fmt"
    
    func main(){
            fmt.Println(`Verifying Org-Babel works for golang
    exporting both input and output as I usually do with all source that I write`)
    }
    
  • works, and I'm ready to go..
  • unbuffered channels:

    package main
    
    import "fmt"
    
    func main() {
            ch := make(chan string)
    
            for i:= 0; i < 3; i++{
                    go func() {
                            message := <-ch
                            fmt.Println(message)
                            ch <- "pong"
                    }()
    
                    ch <- "ping"
                    fmt.Println(<-ch)
            }
    }
    
    ping
    pong
    ping
    pong
    ping
    pong
    
  • buffered channels

    package main
    
    import "fmt"
    
    func main(){
            ch := make(chan map[string]int,3)
    
            ch <- map[string]int{"a": 1, "b": 2}
            ch <- map[string]int{"c": 3, "d": 4}
            ch <- map[string]int{"e": 5, "f": 6}
    
            fmt.Println(<- ch)
            fmt.Println(<- ch)
    
            close(ch)
    
            recv, present := <- ch
    
            fmt.Println(recv, present)
    
            recv, present = <- ch
    
            fmt.Println(recv, present)
    
    }
    
    map[a:1 b:2]
    map[c:3 d:4]
    map[e:5 f:6] true
    map[] false
    
  • looping over channels

    package main
    import "fmt"
    
    func main(){
            ch := make(chan int,3)
    
            ch <- 1
            ch <- 2
            ch <- 3
    
            close(ch)
            // looping without close would result in a deadlock
    
            for i := range ch {
                    fmt.Println(i)
            }
    
    
    }
    
    1
    2
    3
    
  • concurrency seems to have been dramatically simplified

    package main
    
    import (
            "fmt"
            "time"
    )
    
    func main() {
            var ch chan int
    
            for i:= 0; i < 2; i++{
                    select {
                    case m := <- ch:
                            fmt.Println(m)
                    case <-time.After(1 * time.Second):
                            fmt.Println("Timed out at:", time.Now())
                                    }
            }
    }
    
    
    Timed out at: 2024-08-20 16:58:29.476867225 +0530 IST m=+1.000813585
    Timed out at: 2024-08-20 16:58:30.477541565 +0530 IST m=+2.001487824
    
    • might start exploring building generative AI applications in golang
    • I do have an active project that demands LLM integrations
    • I think I might benefit by porting the whole operations into golang
    • have been enjoying it so far.
    • might just stick to golang for all that I write henceforth for a while
    • I haven't specialised in some time, am seriously considering mastering this for good
    • is very straightforward while still allowing for the programming primitives that I enjoy (has a psuedo lisp dialect, closures, lambdas, etc with a priority for pragmatic concurrency)
    • my doom emacs toolchain for golang with dap is also convenient to setup and work with.
    • am willing to explore all the intricacies and the complex things that I can do with go.
    • the core language is minimal but already can anticipate all that I can do with it.
    • going to give this a serious thought.
    • checking out the context package

1.4. 0x2273

  • another book : software engineering in golang
  • another book : let's go

1.5. 0x2266

  • starting a book: building an orchestrator in golang

1.6. 0x2221

  • pushing for competency : reading the ultimate go notebook
  • will also read up a lot about writing efficient software in general along the way (concurrency, hyperscaled infrastructure oriented software, and the likes)

1.7. 0x21E7

  • starting out with go to get into cloud native applications and rewriting a product

2. Resources

2.1. BOOK: Building an orchestrator in golang

2.2. BOOK: Cloud Native Go

2.3. BOOK: The Go Programming Language

2.4. BOOK: Learn Go with Tests

Tags::golang: