From 0a2738db26082d3337f53d0c355301d05024c293 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Tue, 25 Jul 2017 17:38:21 -0700 Subject: [PATCH] making golang_include_workdir_gopath variable available. --- pkg/engine/engine_golang.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/engine/engine_golang.go b/pkg/engine/engine_golang.go index 5720d88..4d608bd 100644 --- a/pkg/engine/engine_golang.go +++ b/pkg/engine/engine_golang.go @@ -39,13 +39,20 @@ func (g *engineGolang) Init(pipelineData *pipeline.Data, config config.Interface g.CurrentMetadata = new(golangMetadata) g.NextMetadata = new(golangMetadata) - //golang requires that the package is in GOPATH. - //we can have multiple workspaces in the gopath by separating them with : - g.GoPath = g.PipelineData.GitParentPath - g.PipelineData.GitParentPath = path.Join(g.PipelineData.GitParentPath, "src") - os.MkdirAll(g.PipelineData.GitParentPath, 0666) - os.Setenv("GOPATH", fmt.Sprintf("%s:%s", os.Getenv("GOPATH"), g.GoPath)) - //TODO: g.GoPath root will not be deleted (its the parent of GitParentPath). + //TODO: figure out why setting the GOPATH workspace is causing the tools to timeout. + // golang recommends that your in-development packages are in the GOPATH. + // the problem with this is that for somereason gometalinter (and the underlying linting tools) take alot longer + // to run, and hit the default deadline limit ( --deadline=30s). + // we can have multiple workspaces in the gopath by separating them with colon (:), but it will require you to specify + // if you enable adding the workdir to the gopath, then you;ll need to increase the linter command to use --deadline=5m + // and handle the deletion of the gopath parent directory manually. + if g.Config.GetBool("golang_include_workdir_gopath") { + //TODO: g.GoPath root will not be deleted (its the parent of GitParentPath), figure out if we can do this automatically. + g.GoPath = g.PipelineData.GitParentPath + g.PipelineData.GitParentPath = path.Join(g.PipelineData.GitParentPath, "src") + os.MkdirAll(g.PipelineData.GitParentPath, 0666) + os.Setenv("GOPATH", fmt.Sprintf("%s:%s", os.Getenv("GOPATH"), g.GoPath)) + } //set command defaults (can be overridden by repo/system configuration) g.Config.SetDefault("engine_cmd_compile", "go build $(go list ./cmd/...)")