Book Image

Mastering Go

By : Mihalis Tsoukalos
Book Image

Mastering Go

By: Mihalis Tsoukalos

Overview of this book

<p>Often referred to as Golang (albeit wrongly), the Go programming language is really making strides thanks to some masterclass developments, architected by the greatest programming minds. Shopify CEO Tobias Lutke has been recently quoted as saying “Go will be the server language of the future.” Go programmers are in high demand, but - more controversially - Go takes the stage where C and Unix programmers previously led the way.</p> <p>The growth of the Go language has seen it become the means by which systems, networking, web, and cloud applications are implemented. If you’re a Go programmer, you’ll already know some Go syntax and will have written some small projects. However, most Go programmers face the difficulty of having to integrate their Golang skills with production code. With Mastering Go, the author shows you just how to tackle this problem. You'll benefit by mastering the use of the libraries and utilize its features, speed, and efficiency for which the Go ecology is justly famous.</p> <p>Offering a compendium of Go, the book begins with an account of how Go has been implemented. You'll also benefit from an in-depth account of concurrency and systems and network programming imperative for modern-day native cloud development through the course of the book.</p>
Table of Contents (19 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Exercises


  • Try to implement a concurrent version of wc(1) that uses a buffered channel.
  • Next, try to implement a concurrent version of wc(1) that uses shared memory.
  • Finally, try to implement a concurrent version of wc(1) that uses a monitor goroutine.
  • Modify the Go code of workerPool.go in order to save the results in a file. Use a mutex and a critical section while dealing with the file, or a monitor goroutine that will keep writing your data on the disk.
  • What will happen to the workerPool.go program when the value of the size global variable becomes 1? Why?
  • Modify the Go code of workerPool.go in order to implement the functionality of the wc(1) command-line utility.
  • Modify the Go code of workerPool.go so that the size of the clients and data buffered channels can be defined as command-line arguments.
  • Try to write a concurrent version of the find(1) command-line utility that uses a monitor goroutine.
  • Modify the code of simpleContext.go so that the anonymous function used in all f1(), f2(), and...