Home > Enterprise >  go build command equivalent api
go build command equivalent api

Time:07-23

To compile a plugin in go I need to run the command below.

go build -buildmode=plugin

Is it possible to call some internal API instead of the command-line option to do this? I can always package the go binary and call os.exec("") but I want to avoid that if I can.

CodePudding user response:

Since go is build with go, the go/internal (https://pkg.go.dev/std see internal) place is where you want to start looking. It is a rabbit hole but contains all the items like environment variables (GOOS), build config, go root, etc.

Other projects building some code for immediate usage (like skaffold) seem to have opted for os.Exec

  •  Tags:  
  • go
  • Related