Oscar Florez
Oscar Florez

Reputation: 123

How to compile a golang program within the golang code?

I need to compile programs within golang in golang. Is there any native form without using exec.Command("go","build") ?

Upvotes: 2

Views: 1819

Answers (2)

Anshu
Anshu

Reputation: 1327

You can try this

First set the $GOPATH

then set the $GOBIN

after that you can run go build or go get..

Upvotes: 0

Chris Berger
Chris Berger

Reputation: 136

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.

Upvotes: 3

Related Questions