hi Richard
 
I have added the code as you suggested in go.bbclass and then i created meta-mylayer and try to build there "go-helloworld_0.1.bb". It builds fine.
 
When i commented GO_IMPORT in the recipe the error i am getting is:
 
ERROR: ExpansionError during parsing /home/cg/CG/Programming/Yocto/poky/meta-mylayer/recipes-go/go-helloworld/go-helloworld.bb             | ETA:  --:--:--
bb.data_smart.ExpansionError: Failure expanding variable GO_SRCURI_DESTSUFFIX, expression was ${@os.path.join(os.path.basename(d.getVar('S')), 'src', d.getVar('GO_IMPORT')) + '/'} which triggered exception TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
The variable dependency chain for the failure is: GO_SRCURI_DESTSUFFIX -> SRC_URI
 
This is caused from this line in the recipe: 
SRC_URI = "git://go.googlesource.com/example;branch=master;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX}"
 
So it looks that expanding GO_SRCURI_DESTSUFFIX variable is executed before anonymous python function and the error "GO_IMPORT is not set" will not be generated.
 
If you don't have anything to comment , I will try to dive deeper and see how I can adapt it...
 
Br
Christos