/explore

Click through on any links that interest you or select the planets on the right to continue exploring the Outer Web.
You are here

hjr265.me
| | timilearning.com

This post will contain some examples of good and bad Go code, using them to show common mistakes that can be made when starting to build concurrent programs, and how those can be corrected. It will cover goroutines, mutexes, condition variables, and channels.
2.7 parsecs

Travel
| |
| | golangbot.com

A Mutex is used to provide a locking mechanism to ensure that only one Goroutine is running the critical section of code at any point in time. Mutexes help avoid race conditions.
2.9 parsecs

Travel
| |
| | www.4async.com

Go?1.17?1.17?1.18?6?Go 1.18?1.17? ?Go?interface{}?Go?interface{}? ?Go?...
3.5 parsecs

Travel
| |
| | konradreiche.com

Writing a generic protobuf writer in Go is straightforward. We simply use proto.Marshal with the protobuf message because proto.Marshal expects the proto.Message interface, which all generated protobuf messages implement. However, when it comes to reading serialized protobuf data into a specific Go type, historically, we had to specify the type explicitly: var post pb.Post if err := proto.Unmarshal(b, &post); err != nil { return nil, err } This approach is clear and explicit: what you see is what you get. But what if you need a more generic solution? You might encounter a scenario similar to mine: a cache abstraction designed to handle different kinds of protobuf messages generically. My initial attempt looked like this:
25.7 parsecs

Travel
|