Reading os/exec.Cmd Output Without Race Conditions

And without cmd.StdoutPipe

Golang Weekly issue 164 features a nice article, Advanced command execution in Go with os/exec, which details several ways of working with os/exec, especially how to read STDOUT and STDERR while the command is running. This common task is commonly done wrong, where “wrong” means “the code has a race condition”. This blog post shows how to read STDOUT and STDERR from an os/exec.Cmd while it’s running and without race conditions. Read more...

Custom MongoDB Replica Set Write Concern

For data center-aware write acks

One of the great things about MongoDB is write concern: Write concern describes the level of acknowledgement requested from MongoDB for write operations to a standalone mongod or to replica sets or to sharded clusters. Awesome! I want 1 write ack from any secondary in the primary DC so when the primary crashes we’re guaranteed to have an up-to-date secondary in the primary DC ready to be elected primary. Read more...