Error Handling In Go, Part II

IntroductionIn part I of this post, we learned about the error interface and how the standard library provides support for creating error interface values via the errors package. We also learned how to work with error interface values and use them to identify when an error has occured. Finally, we saw how some packages in the standard library export error interface variables to help us identify specific errors.Knowing when

Object Oriented Programming Mechanics

Go is an object oriented programming language. It may not have inheritance, but in this 20 minute video from the Bangalore meetup, I will show you how object oriented programming practices and techniques can be applied to your Go programs. From an object oriented standpoint, Go does provides the ability to add behavior to your types via methods, allows you to implement polymorphic behavior via interfaces and gives you a

Escape-Analysis Flaws

PreludeIt will be helpful to read this four-part series first on escape analysis and data semantics. Details on how to read an escape analysis report and pprof output have been outlined here. after working with Go for 4 years, I am continually amazed by the language. Thanks to the static code analysis the compiler performs, the compiler can apply interesting optimizations

Concurrency Trap #2: Incomplete Work

IntroductionIn my first post on Goroutine Leaks, I mentioned that concurrency is a useful tool but it comes with certain traps that don’t exist in synchronous programs. To continue with this theme, I will introduce a new trap called incomplete work. Incomplete work occurs when a program terminates before outstanding Goroutines (non-main goroutines) complete. Depending on the nature of the Goroutine that is being terminated forcefully, this may

Thread Pooling in Go Programming

After working in Go for some time now, I learned how to use an unbuffered channel to build a pool of goroutines. I like this implementation better than what is implemented in this post.  That being said, this post still has value in what it describes. my world of server development thread pooling has been the key to building robust code on the Microsoft

Installing Go, Gocode, GDB and LiteIDE

Check out my new installtion document: removed the sections about gocode and GDB. These are not necessary any longer. I also added links for more editors.WindowsThis is a great post by Wade Wegner for installing Go on your Windows Machine: OS XThe following instructions will guide you through installing Go on your Mac.

Understanding Defer, Panic and Recover

I am building my TraceLog package and it is really important that the package logs any internal exceptions and prevents panics from shutting down the application. The TraceLog package must never be responsible for shutting down an application. I also have internal go routines that must never terminate until the application is shut down gracefully.Understanding how to use Defer and Recover in your application can be a bit tricky

Go's time.Duration Type Unravelled

I have been struggling with using the Time package that comes in the Go standard library. My struggles have come from two pieces of functionality. First, trying to capture the number of milliseconds between two different time periods. Second, comparing that duration in milliseconds against a pre-defined time span. It sounds like a no brainier but like I said, I have been struggling.In the Time package there is

Send an email in Go with smtp.SendMail

I wanted to send an email from my TraceLog package when a critical exception occurred. Fortunately Go’s standard library has a package called smpt which can be found inside the net package. When you look at the documentation you are left wanting.I spent 20 minutes researching how to use this package. After fighting through the parameters and bugs, I came up with this sample code:package mainimport

Singleton Design Pattern in Go

Multi-threaded applications are very complicated, especially when your code is not organized and consistent with how resources are accessed, managed and maintained. If you want to minimize bugs you need philosophies and rules to live by. Here are some of mine:Resource allocation and de-allocation should be abstracted and managed within the same type.Resource thread safeness should be abstracted and managed within the same type.A public interface should

OSCON 2013 - The Gophers Are Coming

On June 22nd through the 26th, Portland Oregon is hosting OSCON (Open Source Convention). The event is run by O’Reilly. After looking at the speakers list it appears it is going to be a great convention.There are three Gophers who will be giving talks. Check out the links:Francesc Campoy Flores Go Developer Programs Engineer, Google Inc.

Understanding Pointers and Memory Allocation

In the documentation provided by the Go language team you will find great information on pointers and memory allocation. Here is a link to that documentation: need to start with the understanding that all variables contain a value. Based on the type that variable represents will determine how we can use it to manipulate the memory it contains. Read this post to learn more:

An RSS Feed Searching Framework Using Go

This article was written for and published by Safari Books OnlineBack in May, I finally decided that it was time to move away from the Microsoft stack to Linux. The cost of developing, licensing, and purchasing cloud computing on the Microsoft stack is too expensive. My company was approved for BizSpark, which made development possible for a small company like mine, but what am I going to do three years