1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
16 "golang.org/x/tools/internal/lsp/browser"
17 "golang.org/x/tools/internal/lsp/debug"
18 "golang.org/x/tools/internal/lsp/source"
21 // version implements the version command.
26 func (v *version) Name() string { return "version" }
27 func (v *version) Usage() string { return "" }
28 func (v *version) ShortHelp() string { return "print the gopls version information" }
29 func (v *version) DetailedHelp(f *flag.FlagSet) {
30 fmt.Fprint(f.Output(), ``)
34 // Run prints version information to stdout.
35 func (v *version) Run(ctx context.Context, args ...string) error {
36 debug.PrintVersionInfo(ctx, os.Stdout, v.app.verbose(), debug.PlainText)
40 // bug implements the bug command.
43 func (b *bug) Name() string { return "bug" }
44 func (b *bug) Usage() string { return "" }
45 func (b *bug) ShortHelp() string { return "report a bug in gopls" }
46 func (b *bug) DetailedHelp(f *flag.FlagSet) {
47 fmt.Fprint(f.Output(), ``)
51 const goplsBugPrefix = "x/tools/gopls: <DESCRIBE THE PROBLEM>"
52 const goplsBugHeader = `ATTENTION: Please answer these questions BEFORE submitting your issue. Thanks!
55 If possible, provide a recipe for reproducing the error.
56 A complete runnable program is good.
57 A link on play.golang.org is better.
58 A failing unit test is the best.
60 #### What did you expect to see?
63 #### What did you see instead?
68 // Run collects some basic information and then prepares an issue ready to
70 func (b *bug) Run(ctx context.Context, args ...string) error {
71 buf := &bytes.Buffer{}
72 fmt.Fprint(buf, goplsBugHeader)
73 debug.PrintVersionInfo(ctx, buf, true, debug.Markdown)
75 title := strings.Join(args, " ")
76 if !strings.HasPrefix(title, goplsBugPrefix) {
77 title = goplsBugPrefix + title
79 if !browser.Open("https://github.com/golang/go/issues/new?title=" + url.QueryEscape(title) + "&body=" + url.QueryEscape(body)) {
80 fmt.Print("Please file a new issue at golang.org/issue/new using this template:\n\n")
88 func (sj *apiJSON) Name() string { return "api-json" }
89 func (sj *apiJSON) Usage() string { return "" }
90 func (sj *apiJSON) ShortHelp() string { return "print json describing gopls API" }
91 func (sj *apiJSON) DetailedHelp(f *flag.FlagSet) {
92 fmt.Fprint(f.Output(), ``)
96 func (sj *apiJSON) Run(ctx context.Context, args ...string) error {
97 fmt.Fprintf(os.Stdout, source.GeneratedAPIJSON)