blob: 25844e37b317d146256c88d2b2b2eda561a65b04 [file] [log] [blame]
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package internal contains mostly utility functions.
package internal
import (
// GoEnv returns the key-value map of `go env`.
func GoEnv() (map[string]string, error) {
out, err := exec.Command("go", "env", "-json").Output()
if err != nil {
return nil, err
env := make(map[string]string)
if err := json.Unmarshal(out, &env); err != nil {
return nil, err
return env, nil