Component Test – Write a test to confirm that the repo is formatted

I have a quick test to verify that all committed files in the repo are formatted. I'm new, so I'm not sure what's the best way to do it. In particular, error handling is pretty cruel as it occupies about half of the lines.

How can it be improved?

package pack

import (
    "os"
    "os/exec"
    "path/filepath"
    "testing"
)

func TestFormatting(t *testing.T) {
    var commandArgs ()string
    commandArgs = append(commandArgs, "-l")
    root := "../.."
    err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
        if filepath.Ext(path) != ".go" {
            return nil
        }
        absPath, e := filepath.Abs(path)
        if e != nil {
            return e
        }
        commandArgs = append(commandArgs, absPath)
        return nil
    })
    if err != nil {
        t.Logf(err.Error())
        t.Fail()
    }

    out, err := exec.Command("gofmt", commandArgs...).Output()
    if err != nil {
        t.Logf(err.Error())
        t.Fail()
    }
    output := string(out)
    if output != "" {
        t.Logf("Testing Formatting")
        t.Logf(output)
        t.Fail()
    }
}