Product Features Demo Pricing Resources Contact Documentation Articles Company Customers Legal Stuff

Go Naming Conventions

The style guide tutorial you never knew you didn't need

October 18, 2018 - It’s been said that naming is one of the two hardest problems in computer science along with cache invalidation and ‘off-by-one’ errors. (See what I did there?) Do you ever find yourself wondering what policies and practices you could adopt to make your life easier when reading code you wrote months ago? Or maybe you’re up at night wishing you know how to write code in such a way as to maximize adoption and convenience for your users? Continue reading »

Cloning Private Dependencies in Docker and Go

One topic that seems to come up repeatedly on Stack Overflow or other online forums is the topic of how to GO GET private dependencies. We can help.

September 13, 2018 - One topic that seems to come up repeatedly on Stack Overflow or other online forums is the topic of how to go get private dependencies. Specifically, if I have a private Git repository on Github or Bitbucket, how do I bring that code locally via the go get tool such that automated builds can produce a clean, consistent build without interaction from a user? This problem is largely solved for public Github dependencies but continues to be a challenge for private dependencies. Continue reading »

Let's build an xUnit-style test runner for Go!

Why? What do you mean 'why'? Because we can! What's wrong with you?

July 2, 2018 - Writing test functions in Go is easy: package stuff import "testing" func TestStuff(t *testing.T) { t.Log("Hello, World!") } Running test functions is also easy: $ go test -v === RUN TestStuff --- PASS: TestStuff (0.00s) stuff_test.go:6: Hello, World! PASS ok 0.006s Preparing shared state for multiple test functions is problematic. The usual recommendation is to use table-drive tests. But this approach has its limits. For us, xUnit is the ideal solution. Continue reading »

A History of Testing in Go at Smarty

A response to the question: Should I follow Smarty and leave GoConvey for gunit?

March 28, 2018 - I was recently asked two interesting questions: Why did you move from GoConvey to gunit? Are you recommending folks do the same? These are great questions, and since I’m a co-creator of GoConvey and principle author of gunit I feel responsible to give a thorough answer. For the impatient, here’s the TL;DR: Question 1: Why did you move to gunit? After using GoConvey and feeling consistent friction with that approach, we came up with an alternate approach that was more aligned with what we value in a testing library and which eliminated said friction. Continue reading »

Scanning CSV in Go

Wouldn't it be nice if csv.Reader was more like bufio.Scanner?

January 5, 2018 - For the purpose of this article, consider the following CSV data, slightly modified from the docs for encoding/csv: csvData := strings.NewReader(strings.Join([]string{ `first_name,last_name,username`, `"Rob","Pike",rob`, `Ken,Thompson,ken`, `"Robert","Griesemer","gri"`, }, "\n")) Here’s how you read the data, line by line, using the Reader provided in that package: reader := csv.NewReader(csvData) for { record, err := reader.Read() if err == io.EOF { break } if err != nil { // handle the error... // break? Continue reading »

Our Testing Tools

We care about testing our software and we create tools and libraries that help us.

November 3, 2016 - Introduction TL;DR: Choose an approach to software testing that helps your organization create the best possible end results. That might mean using and/or creating a few tools and/or libraries along the way. Or, maybe not. What follows is a description of what we do at SmartyStreets, couched as a response to Dan Mullineux’s equally valid way of doing things. The cost A favourite test helper library, with some simple test assertion functions clearly has some value… They [testing libraries] are not so bad, but they come at a cost, defer to avoid them. Continue reading »

Testing in Go by example: Part 5

An elegant and effective strategy for dealing with time in unit tests

September 15, 2015 - For this installment of the Testing in Go series I’ll share a really nifty way to deal with time in your unit tests. When the behavior you are testing depends on the current time it can be tricky to assert on the results because the current time is a moving target. So, usually we end up resorting to approximations in our assertions that, while functional, always bother me a bit. Continue reading »

Testing in Go by example: Part 4

Our approach to assertions in Go code

August 11, 2015 - I think it’s time for a slight detour. In part 1 we covered the basics of testing in go. In part 2 we covered a few slick ways to execute tests. In part 3 we covered some of our recent endeavors at Smarty to build on the basics. Toward the end of that post we went into some detail regarding our approach to assertions. The assertions referenced in the GoConvey project are actually their own separate project that are imported into GoConvey. Continue reading »

Code as Art

Artists put effort into their work that they don't have to. As coders, so do we. This is important, because it's actually what separates Art from work.

May 21, 2015 - Here at Smarty, we’re mostly programmers and developers. There are a few needles in the haystack here that don’t know “Unix” from “eunuchs”, which is unfortunate, but we’re working on that. And because we’re all tech geeks over here, we like to talk about code, and tech, and why all that stuff is important. In that spirit, we decided to talk about code in a way that maybe all of us should have considered a long time ago. Continue reading »

Testing in Go by example: Part 3

Conveying behavior with our approach to BDD in Go

May 11, 2015 - Review: Welcome to part 3 of our “Testing in Go” series. If you’re new here, feel free to catch up before reading on. In part 1 of this series I eluded to our perceptions of the standard testing tools provided by the Go tool and the standard library and what was missing for us. We all have different expectations of a testing tool and so it’s no wonder that so many have been created. Continue reading »

Testing in Go by example: Part 1

How to use the built-in 'testing' package.

February 27, 2015 - Here’s part 1 of our “Testing in Go” series. Introduction Thinking about trying Go? You won’t regret it! It’s great that testing is baked into the "testing" package from the standard library and the corresponding go test command (which has all sorts of useful and interesting flags). We’d like to show you how easy it is to get started using the built-in testing tools and introduce you to some tools we’ve created. Continue reading »

Testing in Go by example: Part 2

Tests that aren't easy to execute will be ignored.

February 27, 2015 - Here’s part 2 of our “Testing in Go” series. If you’re new, feel free to catch up before reading on. Basics You’ve already learned how to execute tests in Go for a single package. $ go test There’s a bit more to it, though. You can run any package from anywhere if you provide the import path. For example, this command runs the actual tests for the “testing” package from the standard library: Continue reading »

HTML Coverage Reports with GoConvey

For packages that pass all tests, coverage reports are generated and made available by clicking the package name.

February 18, 2014 - You asked for it and now you’ve got it. For packages that pass all tests, coverage reports are generated and made available by clicking the package name, which in that case becomes a link (provided you’ve cleared your browser’s cache!). Right now the coverage command that is run is something like this: $ go test -covermode=set -coverprofile=<package_name>.txt That command generates a plain text profile used in the following command: Continue reading »

Your Convey needs more Focus

One of the great benefits of TDD/BDD is that you usually don't have to spend much, if any time at all in a debugger...

February 7, 2014 - One of the great benefits of TDD/BDD is that you usually don’t have to spend much, if any time at all in a debugger. To enter a debugger is to admit a loss of control over the system under test. Even so, there are times when you do need to debug something, even if you’re maintaining the discipline. Lately, most of my coding is in GoLang. Coming from using an IDE almost exclusively to write Python (using PyCharm) and C# (using VS and ReSharper), and knowing how great the visual debugging tools are it’s hard to fathom using a console-based debugger for GoLang code. Continue reading »

GoConvey - (yet) another testing tool for GoLang

GoConvey features a clean DSL, comprehensive set of built-in assertions, an auto-reloading web UI and fully integrates with GoTest.

December 26, 2013 - It’s now been a few months since I decided that the kind of testing tools I wanted for Go programming hadn’t yet been created (or I just hadn’t found them yet…). So, about 4 months ago I started work on GoConvey and a month later came the first release. The coolest thing about GoConvey (other than the clean DSL, comprehensive set of built-in assertions, and the fact that it integrates fully with go test) is the built-in auto-reloading web UI that reports your test results to your web browser whenever a relevant file is saved (HTML5 notifications included). Continue reading »