It feels like gosh trims leading and trailing spaces from variables:
$ cat x.sh
#!/bin/sh
FOO=" Q "
echo a${FOO}b
export FOO
env | grep FOO | sed 's/$/$/'
$ sh x.sh
a Q b
FOO= Q $
$ go run main.go x.sh
aQb
FOO= Q $
I would have expected gosh x.sh and sh x.sh to produce identical output, but gosh outputs "aQb" while sh outputs "a Q b".
Looks like the variable has the spaces, but they are trimmed during variable expansion?