Golang code comprehension tools

Software engineers spend a greater part of time reading and understanding programs. Indeed, most of the time it takes to develop a program is spent reading it and making logical conclusion about what it does. Go programmers are no exception. Thanks to gofmt they should not worry about source code formatting. The machines are better suited to analyse source code and accomplish comprehension tasks than us. In this article we will explore several of Go comprehension tools that are responsible for locating definitions, ascertaining types of expressions, deducing implementation relation, computing method sets, finding callers/callees, jumping through channels, understanding aliasing....

September 6, 2015 · 3 min · Svetlin Ralchev

Golang refactoring tools

Go language provides many useful tools as part of its development eco system. We will explore most of them in the upcoming blog posts. But in the article lets focus on refactoring tools. Gofmt In average programming languages developers can adapt to different formatting styles. Common problem is how to approach unknown code base without a long prescriptive style guide. Go takes an unusual approach and keep this responsibility to format the source code for you....

August 30, 2015 · 6 min · Svetlin Ralchev

Sharing Golang packages to C and Go

The latest Go 1.5 version is out. As part of the new features, Go compiler can compile packages as a shared libraries. It accepts -buildmode argument that determines how a package is compiled. These are the following options: archive: Build the listed non-main packages into .a files. Packages named main are ignored. c-archive: Build the listed main package, plus all packages it imports, into a C archive file. c-shared: Build the listed main packages, plus all packages that they import, into C shared libraries....

August 23, 2015 · 4 min · Svetlin Ralchev

Conditional compilation in Golang

When developing Go package or application that depends on specific features of the underlying platform or architecture it is often necessary to use a specialised implementation. There are two parts of Go conditional compilation system, which we will now explore in more detail. Build constraints A build constraints (known as build tags) is an optional top line comment that starts with // +build package api Declaration of build constraints follows the following rules:...

August 16, 2015 · 4 min · Svetlin Ralchev

Delve: Next generation debugger for Golang

In my previous post I demonstrated how you can debug golang applications with LLDB. In this article I will illustrate the most recent debugger for Go: Delve The debugger is a community effort to bring a debugger in the toolchain of every Go developer. It’s written in Go to debug Go code. It’s still in active development, but we can still benefit from its basic features. Installation You should install Delve with the following command:...

August 8, 2015 · 4 min · Svetlin Ralchev