• Data Structures and any Type
    The “any” type was added as an alias for the “interface{}” type for several reasons. One of the main reasons is that “any” is a more intuitive and descriptive name for this type. The term “interface{}” can be confusing for developers who are new to Go, especially those who are not familiar with the concept of interfaces in object-oriented programming. By using the term “any”, developers can immediately understand that this type can hold any value. It is a placeholder type that can represent any value at runtime. This means that you can assign any value to a variable of type “any” without encountering any type errors.
    type Node[T any] struct {
     value T
     next, prev *Node[T]
    }
    

    Sometimes we need to use a type assertion to convert the “any” type to a specific one when access.

  • Streams
    append-only log, windows
    func work(in <- chan int, out <- chan int, done <- chan struct{}){
      for {
          select {
              case <- done:
                  return
              case n := <-in:
                  out <- 2* n
          }
      }
    }