DEV Community

Discussion on: Building a finance tracking REST API using Go with TDD - Part 1

alirezabashiri profile image
Alireza Bashiri Author • Edited on

Good catch! $GOPATH I mean. That's obviously a mistake. About the test cases in a single file I have no problem with it, for example; if you look at Django testing that's how they're doing it. I believe in one simple package and many test files and I always do it.

Here's a simple example;


Also as I'm going to show, with which has a specific field called Temp we're going to create a temporary database for each test case and do the isolation.

func TestMain(m *testing.M) {
    testServer = newServer(
            User:     "alireza",
            Password: "alireza",
            Database: "alireza_test",

    testServer.db.CreateTable(&budget{}, &orm.CreateTableOptions{
        Temp: true,


I've more than 5 years of experience developing various web applications using RubyOnRails and Django but I've to tell you there's too much complexity in them but they're productive for people who are master and I think one reason that Go got too much attention was that it's easy for even juniors to master and write a simple web application or a RESTful API. But simplicity comes at a cost and using a programming language and a specific framework needs experience and dedication and choosing Go could be a wrong decision in some cases.