Writing

Programming

How to Use Context in Go for Cancellation and Timeouts

package main import ( "context" "fmt" "net/http" "time" ) func handler(w http.ResponseWriter, r *http.Request) { // r.Context() is cancelled when: // - Client disconnects // - Request times out // - Handler returns ctx := r.Context() // Add our own timeout ctx, cancel := context.WithTimeout(ctx, 5*t…

Read article →

How to Handle Errors Effectively in Go

package main import ( "errors" "fmt" "net" ) func connectToServer(addr string) error { conn, err := net.Dial("tcp", addr) if err != nil { return fmt.Errorf("connecting to server: %w", err) } defer conn.Close() return nil } func main() { err := connec…

Read article →

Scala vs. GO. Introduction | by Javier Ramos | ITNEXT

Go, in the other hand, is a newer, simpler language created by Google to overcome the criticisms of C++; designing a language with multi core processors in mind. Both are great languages that can achieve great performance for concurrent applications and stream processing but their design is quite di…

Read article →

Go vs Scala | Know The 8 Most Amazing Differences

Back to Scala vs Go based on this model, GO provides a more straightforward and smaller set of orthogonal primitives that easily interact with ease and are expected. A developer can quickly build his need by learning a small number of primitives, ...

Read article →