Go, I miss stack traces

over 1 year ago • written in English

Today I was debugging Docker which is written in Go.

--- FAIL: TestLookupImage (0.01 seconds)
        tags_unit_test.go:59: mkdir /tmp/docker-teste5d2-tRunner-474736604/vfs/dir/foo/etc/postgres: permission denied
exit status 1
FAIL    github.com/dotcloud/docker/graph        0.021s

Tests failed: ./graph

Test failures in: ./graph


That was strange because /tmp should be writable from anyone. Then I had to check Graph#Register but it was 50 lines long function which had 4 “return err” statements. The function was calling Image#StoreImage (with 11 “return err” statements) and it was calling archive.ApplyLayer (with 10 “return err” statements) and it had os.MkdirAll finally.

Long story short, 600 should be 0600 but anyway it was frustrating.

In this case, I miss exceptions or more precisely saying stack traces. Go has a special type for errors but the implementation doesn’t do anything. Maybe I can wrap errors by fmt.Errorf each levels instead of “return err”, or I can build own error type like biogo did.