2021-12-15 22:43:58 +08:00
|
|
|
package bug
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
2021-12-15 23:24:32 +08:00
|
|
|
"strings"
|
2021-12-15 22:43:58 +08:00
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/internal/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
type env map[string]string
|
|
|
|
|
|
|
|
func (e env) string() string {
|
|
|
|
if e == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
w := bytes.NewBuffer(nil)
|
|
|
|
for k, v := range e {
|
|
|
|
w.WriteString(fmt.Sprintf("%s = %q\n", k, v))
|
|
|
|
}
|
|
|
|
|
2021-12-15 23:24:32 +08:00
|
|
|
return strings.TrimSuffix(w.String(),"\n")
|
2021-12-15 22:43:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func getEnv() env {
|
|
|
|
e := make(env)
|
|
|
|
e[os] = runtime.GOOS
|
|
|
|
e[arch] = runtime.GOARCH
|
|
|
|
e[goctlVersion] = version.BuildVersion
|
2021-12-15 23:24:32 +08:00
|
|
|
e[goctlVersion] = runtime.Version()
|
2021-12-15 22:43:58 +08:00
|
|
|
return e
|
|
|
|
}
|