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.
http://www.oscon.com/oscon2013/public/schedule/speaker/155088
Johan Euphrosine
Developer Programs Engineer, Google
http://www.oscon.com/oscon2013/public/schedule/speaker/155083
Brad Fitzpatrick
Software Engineer, Google
Continue readingWhen I was coding in C/C++ it was imperative to understand type. If you didn’t, you would get into a lot of trouble with both the compiler and running your code. Regardless of the language, type touches every aspect of programming syntax. A good understand of types and pointers is critical to good programming. This post will focus on type.
Take these bytes of memory for starters:
FFE4 FFE3 FFE2 FFE1 00000000 11001011 01100101 00001010
Continue readingSomeone asked a question on the forum today on how to gain the benefits of inheritance without embedding. It is really important for everyone to think in terms of Go and not the languages they are leaving behind. I can’t tell you much code I removed from my early Go implementations because it wasn’t necessary. The language designers have years of experience and knowledge. Hindsight is helping to create a language that is fast, lean and really fun to code in.
Continue readingMulti-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 be the only means to accessing shared resources.
Continue readingSince I started writing code in Go it has been a mystery to me how best to organize my code and use the package keyword. The package keyword is similar to using a namespace in C#, however the convention is to tie the package name to the directory structure.
Go has this web page that attempts to explain how to write Go Code.
http://golang.org/doc/code.html
When I started programming in Go this was one of the first documents I read.
Continue readingI have been writing Windows services in C/C++ and then in C# since 1999. Now that I am writing server based software in Go for the Linux OS I am completely lost. What is even more frustrating, is that for the first time the OS I am developing on (Mac OSX) is not the operating system I will be deploying my code on. That will be for another blog post.
I want to run my code as a background process (daemon) on my Mac.
Continue readingI was really surprised how easy it was to read an XML document using the encoding/xml package that comes with the standard library. The package works by defining structs that map the XML document. If you need more flexibility then use Gustavo Niemeyer’s xmlpath package (found here).
Here is the XML document we are going to read and de-serialize:
<straps>
<strap key="CompanyName" value="NEWCO" />
<strap key="UseEmail" value="true" />
Continue readingI 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 main
import (
Continue readingI 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 a custom type called Duration and a set of helper constants:
Continue readingI 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 at first, especially if you are used to using try/catch blocks.
Continue reading