Set environment variable for Go tests

FOO=BAR bash -c 'go list ./... | grep -v vendor | xargs -n1 go test -timeout=3s'

A good explanation why the original command doesn't work can be found in the answer to the question: https://unix.stackexchange.com/questions/134735/environment-variables-are-not-set-when-my-function-is-called-in-a-pipeline


I like to use godotenv in command mode

godotenv -f ./.env go test ./internal/... -cover

That's not how setting variables for pipes works. See:

 FOO=BAR echo "AAA" | FOO=WAZ printenv | grep FOO