mirror of
https://github.com/golang/go
synced 2024-11-06 04:26:11 -07:00
6fc5d0bc36
For debugging purposes, we print the output of `go env` on start. Now, we print a view-specific `go env`, which will helps us when debugging multi-project workspaces. Additional information included: the folder of the view, if the view has a valid build configuration, and the build flags for the view. Updates golang/go#37978 Change-Id: Iadffd46f8ac5410971558a304b8bbcb2f9bdbcc3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225137 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
84 lines
2.2 KiB
Go
84 lines
2.2 KiB
Go
// Copyright 2019 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 cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"net/url"
|
|
"os"
|
|
"strings"
|
|
|
|
"golang.org/x/tools/internal/lsp/browser"
|
|
"golang.org/x/tools/internal/lsp/debug"
|
|
)
|
|
|
|
// version implements the version command.
|
|
type version struct {
|
|
app *Application
|
|
}
|
|
|
|
func (v *version) Name() string { return "version" }
|
|
func (v *version) Usage() string { return "" }
|
|
func (v *version) ShortHelp() string { return "print the gopls version information" }
|
|
func (v *version) DetailedHelp(f *flag.FlagSet) {
|
|
fmt.Fprint(f.Output(), ``)
|
|
f.PrintDefaults()
|
|
}
|
|
|
|
// Run prints version information to stdout.
|
|
func (v *version) Run(ctx context.Context, args ...string) error {
|
|
debug.PrintVersionInfo(ctx, os.Stdout, v.app.Verbose, debug.PlainText)
|
|
return nil
|
|
}
|
|
|
|
// bug implements the bug command.
|
|
type bug struct{}
|
|
|
|
func (b *bug) Name() string { return "bug" }
|
|
func (b *bug) Usage() string { return "" }
|
|
func (b *bug) ShortHelp() string { return "report a bug in gopls" }
|
|
func (b *bug) DetailedHelp(f *flag.FlagSet) {
|
|
fmt.Fprint(f.Output(), ``)
|
|
f.PrintDefaults()
|
|
}
|
|
|
|
const goplsBugPrefix = "x/tools/gopls: "
|
|
const goplsBugHeader = `Please answer these questions before submitting your issue. Thanks!
|
|
|
|
#### What did you do?
|
|
If possible, provide a recipe for reproducing the error.
|
|
A complete runnable program is good.
|
|
A link on play.golang.org is better.
|
|
A failing unit test is the best.
|
|
|
|
#### What did you expect to see?
|
|
|
|
|
|
#### What did you see instead?
|
|
|
|
|
|
`
|
|
|
|
// Run collects some basic information and then prepares an issue ready to
|
|
// be reported.
|
|
func (b *bug) Run(ctx context.Context, args ...string) error {
|
|
buf := &bytes.Buffer{}
|
|
fmt.Fprint(buf, goplsBugHeader)
|
|
debug.PrintVersionInfo(ctx, buf, true, debug.Markdown)
|
|
body := buf.String()
|
|
title := strings.Join(args, " ")
|
|
if !strings.HasPrefix(title, goplsBugPrefix) {
|
|
title = goplsBugPrefix + title
|
|
}
|
|
if !browser.Open("https://github.com/golang/go/issues/new?title=" + url.QueryEscape(title) + "&body=" + url.QueryEscape(body)) {
|
|
fmt.Print("Please file a new issue at golang.org/issue/new using this template:\n\n")
|
|
fmt.Print(body)
|
|
}
|
|
return nil
|
|
}
|