Ejemplo n.º 1
0
func Build(p *project.Project) error {

	cmdArgs := getArgs(p)
	cmd := run.NewExec(filepath.Join(p.GetConfig().GoBin+"go"), cmdArgs, p.GetEnvs())
	if StdOut == nil {
		StdOut = os.Stdout
	}

	cmd.StdOut = StdOut
	cmd.StdErr = StdOut

	fmt.Fprintln(StdOut, "Build project:", p.GetConfig().ProjectName)
	fmt.Fprintln(StdOut, "Build path:", p.GetProjectPath())
	fmt.Fprintln(StdOut, "Build command:", filepath.Join(p.GetConfig().GoBin+"go"), cmdArgs)
	fmt.Fprintln(StdOut, "Build:")

	return cmd.Run()
}
Ejemplo n.º 2
0
func GetDepends(p *project.Project, downloadOnly bool) error {
	cmdArgs := []string{"get"}
	if downloadOnly {
		cmdArgs = append(cmdArgs, "-d")
	}
	cmdArgs = append(cmdArgs, "-v")
	cmdArgs = append(cmdArgs, p.GetConfig().MainPkgPath)
	cmd := run.NewExec(filepath.Join(p.GetConfig().GoBin+"go"), cmdArgs, p.GetEnvs())
	if StdOut == nil {
		StdOut = os.Stdout
	}

	cmd.StdOut = StdOut
	cmd.StdErr = StdOut

	fmt.Fprintln(StdOut, "Get project dependens:", p.GetConfig().ProjectName)
	fmt.Fprintln(StdOut, "Get command:", filepath.Join(p.GetConfig().GoBin+"go"), cmdArgs)
	fmt.Fprintln(StdOut, "Get:")

	return cmd.Run()
}
Ejemplo n.º 3
0
func gocode(p *project.Project, filename string, cur cursor) Candidates {
	out := bytes.NewBuffer([]byte{})
	cmd := run.NewExec("gocode", []string{"-f=json", "--in=" + filename, "autocomplete", strconv.Itoa(cur.offset)}, p.GetEnvs())
	cmd.StdOut = out
	cmd.Run()

	var cands Candidates
	pos := strings.Index(out.String()[1:], "[")
	buf := out.Bytes()
	if json.Unmarshal(buf[pos+1:len(buf)-1], &cands) == nil {
		if len(cur.partial) > 1 {
			cands.SetPercent(cur.partial)
		}
	}
	return cands
}