Building your first HTTP Server

We have seen the enormous power and ease of use of go language till now, lets today build a simple http server on Go. A fairly straight forward and simple server, which accepts requests on port 8080 and sends a response. We know exactly what we want, something which listens and serves. Surprisingly, in go […]

Continue reading →

Checking for all white spaces in string

In the previous posts we have seen various features of the go language. Now lets start to build some meaningful things from our learnings. Lets Start with building a utility function which accepts a string and returns a boolean value telling if there are all white/blank characters in string. Here is the code Here IsAllWhiteSpace() […]

Continue reading →

Communicating between goroutines using channels

We just learned about goroutines. The functions which can be executed in parallel in their own threads. Lets now see how we can establish communication between independent goroutines. The inter thread communication in go is established over channels. Channels also act as synchronization points, meaning if a sender sends something over channel, it would (normally) […]

Continue reading →

Multi threading using goroutines

Almost all modern programming languages have support for multi threading & in almost all of the languages multithreading is fragile, you seem to lose control over your threads who share same memory space. Sharing same memory serves as a communication tool for threads. So producer produces a “thing”.. keeps it in memory, consumer comes and […]

Continue reading →

Understanding Embedded types

Interfaces are not the only thing borrowed from Object Oriented Languages in Go. Go also provides way to create relationships between structures and “inherit” properties/methods from other structures. Let us see how we can have a has-a relationship b/w structures. In the above code We define a struct lottery and then embed the lottery struct […]

Continue reading →

Understanding Interfaces in Go

In a world full of Object Oriented Languages, we have all worked with Interfaces, they are simple and elegant. Go borrows the good things from the world of Object Oriented Programming and interfaces are one of the best things there. Lets see how we work with interfaces in Go, type NamePrinter interface { printName() } […]

Continue reading →

Recovering from panic

We all must panic when Voldemort returns, however we must be quick to recover from panic also. Whenever we expect a situation where panic can occur we must be ready to recover from it and must defer the recovery to the end of the function call so that all possible panic situations in the function […]

Continue reading →