I need to compile programs within golang in golang. Is there any native form without using exec.Command("go","build") ?
Unfortunately I think using exec.Command is your best bet to harness the tools written by the Go community in order to compile your go programs within a go program.
You can try this
First set the $GOPATH
then set the $GOBIN
after that you can run go build or go get..