go-zero/tools/goctl/bug/env.go
anqiansong 5979b2aa0f
Update template (#1335)
Co-authored-by: anqiansong <anqiansong@bytedance.com>
2021-12-15 23:24:32 +08:00

35 lines
536 B
Go

package bug
import (
"bytes"
"fmt"
"runtime"
"strings"
"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))
}
return strings.TrimSuffix(w.String(),"\n")
}
func getEnv() env {
e := make(env)
e[os] = runtime.GOOS
e[arch] = runtime.GOARCH
e[goctlVersion] = version.BuildVersion
e[goctlVersion] = runtime.Version()
return e
}