<commit_before>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package commands

import (
	"go/build"
	"os"
	"os/exec"
	"strings"
	"syscall"

	"github.com/garyburd/neovim-go/vim"
	"github.com/garyburd/neovim-go/vim/plugin"

	"nvim-go/gb"
	"nvim-go/nvim"
	"nvim-go/pkgs"
)

func init() {
	plugin.HandleCommand("Gobuild", &plugin.CommandOptions{Eval: "expand('%:p:h')"}, Build)
}

func cmdBuild(v *vim.Vim, dir string) {
	go Build(v, dir)
}

// Build building the current buffer's package use compile tool that determined from the directory structure.
func Build(v *vim.Vim, dir string) error {
	defer gb.WithGoBuildForPath(dir)()
	var (
		b vim.Buffer
		w vim.Window
	)

	p := v.NewPipeline()
	p.CurrentBuffer(&b)
	p.CurrentWindow(&w)
	if err := p.Wait(); err != nil {
		return nvim.Echoerr(v, err)
	}

	var compiler string
	buildDir := strings.Split(build.Default.GOPATH, ":")[0]
	if buildDir == os.Getenv("GOPATH") {
		compiler = "go"
	} else {
		compiler = "gb"
	}

	rootDir := pkgs.FindVcsDir(dir)

	cmd := exec.Command(compiler, "build")
	cmd.Dir = rootDir
	out, err := cmd.CombinedOutput()
	if err != nil {
		return nvim.Echoerr(v, err)
	}

	cmd.Run()

	s, _ := cmd.ProcessState.Sys().(syscall.WaitStatus)
	if s.ExitStatus() > 0 {
		loclist := nvim.ParseError(v, string(out), dir)
		if err := nvim.SetLoclist(p, loclist); err != nil {
			return nvim.Echoerr(v, err)
		}
		return nvim.OpenLoclist(p, w, loclist, true)
	}

	return nvim.Echohl(v, "GoBuild: ", "Function", "SUCCESS")
}
<commit_msg>Fix error handling to disable<commit_after>// Copyright 2016 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package commands

import (
	"go/build"
	"os"
	"os/exec"
	"strings"
	"syscall"

	"github.com/garyburd/neovim-go/vim"
	"github.com/garyburd/neovim-go/vim/plugin"

	"nvim-go/gb"
	"nvim-go/nvim"
	"nvim-go/pkgs"
)

func init() {
	plugin.HandleCommand("Gobuild", &plugin.CommandOptions{Eval: "expand('%:p:h')"}, Build)
}

func cmdBuild(v *vim.Vim, dir string) {
	go Build(v, dir)
}

// Build building the current buffer's package use compile tool that determined from the directory structure.
func Build(v *vim.Vim, dir string) error {
	defer gb.WithGoBuildForPath(dir)()
	var (
		b vim.Buffer
		w vim.Window
	)

	p := v.NewPipeline()
	p.CurrentBuffer(&b)
	p.CurrentWindow(&w)
	if err := p.Wait(); err != nil {
		return nvim.Echoerr(v, err)
	}

	var compiler string
	buildDir := strings.Split(build.Default.GOPATH, ":")[0]
	if buildDir == os.Getenv("GOPATH") {
		compiler = "go"
	} else {
		compiler = "gb"
	}

	rootDir := pkgs.FindVcsDir(dir)

	cmd := exec.Command(compiler, "build")
	cmd.Dir = rootDir
	out, _ := cmd.CombinedOutput()

	cmd.Run()

	s, _ := cmd.ProcessState.Sys().(syscall.WaitStatus)
	if s.ExitStatus() > 0 {
		loclist := nvim.ParseError(v, string(out), dir)
		if err := nvim.SetLoclist(p, loclist); err != nil {
			return nvim.Echoerr(v, err)
		}
		return nvim.OpenLoclist(p, w, loclist, true)
	}

	return nvim.Echohl(v, "GoBuild: ", "Function", "SUCCESS")
}

{'fraction_non_alphanumeric': 0.16151419558359623, 'fraction_numerical': 0.0037854889589905363, 'mean_word_length': 3.82648401826484, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '791622', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1238, 'n_words': 301}