There `flycheck-testsuite-resource-filename`, which makes all this superfluous.

Essentially, it should boil down to 

```lisp
(setenv "GOTPATH" (flycheck-testsuite-resource-filename "checkers/go"))
```

I don't think, you need to test whether the variable is set.  No harm should be done by just overwriting it.