Skip to content

Commit

Permalink
cmd/go: split out cmd/go/internal/cfg
Browse files Browse the repository at this point in the history
This is one CL in a long sequence of changes to break up the
go command from one package into a plausible group of packages.

This sequence is concerned only with moving code, not changing
or cleaning up code. There will still be more cleanup after this sequence.

The entire sequence will be submitted together: it is not a goal
for the tree to build at every step.

For #18653.

Change-Id: Icb3f168ade91e7da5fcab89ac75b768daefff359
Reviewed-on: https://go-review.googlesource.com/36191
Reviewed-by: David Crawshaw <[email protected]>
  • Loading branch information
rsc committed Feb 3, 2017
1 parent 762eb40 commit a918864
Show file tree
Hide file tree
Showing 20 changed files with 401 additions and 351 deletions.
17 changes: 9 additions & 8 deletions src/cmd/go/bug.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"bytes"
"cmd/go/internal/cfg"
"fmt"
"io"
"io/ioutil"
Expand All @@ -28,7 +29,7 @@ The report includes useful system information.
}

func init() {
cmdBug.Flag.BoolVar(&buildV, "v", false, "")
cmdBug.Flag.BoolVar(&cfg.BuildV, "v", false, "")
}

func runBug(cmd *Command, args []string) {
Expand All @@ -38,13 +39,13 @@ func runBug(cmd *Command, args []string) {
fmt.Fprint(&buf, "#### System details\n\n")
fmt.Fprintln(&buf, "```")
fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
env := newEnv
env := cfg.NewEnv
env = append(env, extraEnvVars()...)
for _, e := range env {
// Hide the TERM environment variable from "go bug".
// See issue #18128
if e.name != "TERM" {
fmt.Fprintf(&buf, "%s=\"%s\"\n", e.name, e.value)
if e.Name != "TERM" {
fmt.Fprintf(&buf, "%s=\"%s\"\n", e.Name, e.Value)
}
}
printGoDetails(&buf)
Expand Down Expand Up @@ -97,7 +98,7 @@ func printOSDetails(w io.Writer) {
if err == nil {
fmt.Fprintf(w, "/etc/release: %s\n", out)
} else {
if buildV {
if cfg.BuildV {
fmt.Printf("failed to read /etc/release: %v\n", err)
}
}
Expand All @@ -114,7 +115,7 @@ func printCDetails(w io.Writer) {
// Print up to the first newline.
fmt.Fprintf(w, "gdb --version: %s\n", firstLine(out))
} else {
if buildV {
if cfg.BuildV {
fmt.Printf("failed to run gdb --version: %v\n", err)
}
}
Expand All @@ -123,7 +124,7 @@ func printCDetails(w io.Writer) {
func inspectGoVersion(w io.Writer) {
data, err := httpGET("https://golang.org/VERSION?m=text")
if err != nil {
if buildV {
if cfg.BuildV {
fmt.Printf("failed to read from golang.org/VERSION: %v\n", err)
}
return
Expand All @@ -150,7 +151,7 @@ func printCmdOut(w io.Writer, prefix, path string, args ...string) {
cmd := exec.Command(path, args...)
out, err := cmd.Output()
if err != nil {
if buildV {
if cfg.BuildV {
fmt.Printf("%s %s: %v\n", path, strings.Join(args, " "), err)
}
return
Expand Down
Loading

0 comments on commit a918864

Please sign in to comment.