You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: utils.go
    path of file: ./repos/qt/internal/cmd
    
    the code of the file until where you have to start completion: package cmd

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
	"runtime"
	"strconv"
	"strings"
	"sync"

	"github.com/therecipe/qt/internal/utils"
)

var (
	std      []string
	stdMutex = new(sync.Mutex)

	imported      = make(map[string]string)
	importedMutex = new(sync.Mutex)

	importedStd       = make(map[string]struct{})
	importedStdMutex  = new(sync.Mutex)
	importsQmlOrQuick string
	importsInterop    string
	importsFlutter    string
)

func IsStdPkg(pkg string) bool {

	stdMutex.Lock()
	if std == nil {
		std = append(strings.Split(strings.TrimSpace(utils.RunCmd(exec.Command("go", "list", "std"), "go list std")), "\n"), "C")
	}
	stdMutex.Unlock()

	for _, spkg := range std {
		if pkg == spkg {
			return true
		}
	}
	return false
}

//TODO:
func GetImports(path, target, tagsCustom string, level int, onlyDirect bool) []string {
	utils.Log.WithField("path", path).WithField("level", level).Debug("get imports")

	env, tags, _, _ := BuildEnv(target, "", "")

	stdMutex.Lock()
	if std == nil {
		std = append(strings.Split(strings.TrimSpace(utils.RunCmd(exec.Command("go", "list", "std"), "go list std")), "\n"), "C")
	}
	stdMutex.Unlock()

	if tagsCustom != "" {
		tags = append(tags, strings.Split(tagsCustom, " ")...)
	}

	importMap := make(map[string]struct{})

	imp := "Deps"
	if onlyDirect {
		imp = "Imports"
	} else {
		defer func() {
			importedStdMutex.Lock()
			if importsQmlOrQuick == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/qml\" \"github.com/therecipe/qt/quick\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsQmlOrQuick = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports qml or quick")) != "")

				utils.Log.WithField("path", path).Debug("project depends on qml or quick: " + importsQmlOrQuick)
			}

			if importsInterop == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/interop\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsInterop = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports interop")) != "")

				utils.Log.WithField("path", path).Debug("project depends on interop: " + importsInterop)
			}

			if importsFlutter == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/flutter\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsFlutter = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports flutter")) != "")

				utils.Log.WithF
    
func GetImports(path, target, tagsCustom string, level int, onlyDirect bool) []string {
	utils.Log.WithField("path", path).WithField("level", level).Debug("get imports")

	env, tags, _, _ := BuildEnv(target, "", "")

	stdMutex.Lock()
	if std == nil {
		std = append(strings.Split(strings.TrimSpace(utils.RunCmd(exec.Command("go", "list", "std"), "go list std")), "\n"), "C")
	}
	stdMutex.Unlock()

	if tagsCustom != "" {
		tags = append(tags, strings.Split(tagsCustom, " ")...)
	}

	importMap := make(map[string]struct{})

	imp := "Deps"
	if onlyDirect {
		imp = "Imports"
	} else {
		defer func() {
			importedStdMutex.Lock()
			if importsQmlOrQuick == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/qml\" \"github.com/therecipe/qt/quick\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsQmlOrQuick = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports qml or quick")) != "")

				utils.Log.WithField("path", path).Debug("project depends on qml or quick: " + importsQmlOrQuick)
			}

			if importsInterop == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/interop\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsInterop = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports interop")) != "")

				utils.Log.WithField("path", path).Debug("project depends on interop: " + importsInterop)
			}

			if importsFlutter == "" {
				stdImport := make([]string, len(importedStd)+1)
				var c int
				for k := range importedStd {
					stdImport[c] = k
					c++
				}
				stdImport[len(stdImport)-1] = "github.com/therecipe/qt/internal/binding/runtime"

				cmd := utils.GoList(fmt.Sprintf("{{if not .Standard}}{{if eq .ImportPath \"%v\"}}{{else}}{{range .Imports}}{{if eq . \"github.com/therecipe/qt/flutter\"}}{{.}}{{end}}{{end}}{{end}}{{end}}", strings.Join(stdImport, "\" \"")), "-deps", utils.BuildTags(tags))
				if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
					cmd.Dir = path
				} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
					cmd.Dir = filepath.Dir(utils.GOMOD(path))
					vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
					cmd.Args = append(cmd.Args, vl[len(vl)-1])
				}
				for k, v := range env {
					cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
				}

				importsFlutter = fmt.Sprint(strings.TrimSpace(utils.RunCmd(cmd, "go list imports flutter")) != "")

				utils.Log.WithField("path", path).Debug("project depends on flutter: " + importsFlutter)
			}
			importedStdMutex.Unlock()
		}()
	}

	//TODO: cache
	cmd := utils.GoList("{{join .TestImports \"|\"}}|{{join .XTestImports \"|\"}}|{{join ."+imp+" \"|\"}}", utils.BuildTags(tags))
	if !utils.UseGOMOD(path) || (utils.UseGOMOD(path) && !strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/")) {
		cmd.Dir = path
	} else if utils.UseGOMOD(path) && strings.Contains(strings.Replace(path, "\\", "/", -1), "/vendor/") {
		cmd.Dir = filepath.Dir(utils.GOMOD(path))
		vl := strings.Split(strings.Replace(path, "\\", "/", -1), "/vendor/")
		cmd.Args = append(cmd.Args, vl[len(vl)-1])
	}

	for k, v := range env {
		cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
	}

	libs := strings.Split(strings.TrimSpace(utils.RunCmd(cmd, "go list deps")), "|")
	for i := len(libs) - 1; i >= 0; i-- {
		if strings.TrimSpace(libs[i]) == "" {
			libs = append(libs[:i], libs[i+1:]...)
			continue
		}

		importedMutex.Lock()
		dep, ok := imported[libs[i]]
		importedMutex.Unlock()
		if ok {
			importMap[dep] = struct{}{}
			libs = append(libs[:i], libs[i+1:]...)
			continue
		}

		for _, k := range std {
			if libs[i] == k {
				libs = append(libs[:i], libs[i+1:]...)
				break
			}
		}
	}

	wg := new(sync.WaitGroup)
	wc := make(chan bool, runtime.NumCPU()*2)
	wg.Add(len(libs))
	for _, l := range libs {
		wc <- true
		go func(l string) {
			defer func() {
				<-wc
				wg.Done()
			}()

			if strings.Contains(l, "github.com/therecipe/qt") && !(strings.Contains(l, "qt/internal") || strings.Contains(l, "qt/flutter") || strings.Contains(l, "qt/interop")) {
				if strings.Contains(l, "github.com/therecipe/qt/") {
					importedStdMutex.Lock()
					importedStd[l] = struct{}{}
					importedStdMutex.Unlock()
				}
				return
			}

			cmd := utils.GoList("{{.Dir}}", "-find", utils.BuildTags(tags), l)
			for k, v := range env {
				cmd.Env = append(cmd.Env, fmt.Sprintf("%v=%v", k, v))
			}

			dep := strings.TrimSpace(utils.RunCmd(cmd, "go list dir"))
			if dep == "" {
				return
			}

			importedMutex.Lock()
			importMap[dep] = struct{}{}
			imported[l] = dep
			importedMutex.Unlock()
		}(l)
	}
	wg.Wait()

	var imports []string
	for k := range importMap {
		imports = append(imports, k)
	}
	return imports
}