.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / cmd / getgo / system.go
1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build !plan9
6 // +build !plan9
7
8 package main
9
10 import (
11         "bytes"
12         "context"
13         exec "golang.org/x/sys/execabs"
14         "runtime"
15         "strings"
16 )
17
18 // arch contains either amd64 or 386.
19 var arch = func() string {
20         cmd := exec.Command("uname", "-m") // "x86_64"
21         if runtime.GOOS == "windows" {
22                 cmd = exec.Command("powershell", "-command", "(Get-WmiObject -Class Win32_ComputerSystem).SystemType") // "x64-based PC"
23         }
24
25         out, err := cmd.Output()
26         if err != nil {
27                 // a sensible default?
28                 return "amd64"
29         }
30         if bytes.Contains(out, []byte("64")) {
31                 return "amd64"
32         }
33         return "386"
34 }()
35
36 func findGo(ctx context.Context, cmd string) (string, error) {
37         out, err := exec.CommandContext(ctx, cmd, "go").CombinedOutput()
38         return strings.TrimSpace(string(out)), err
39 }