diff --git a/cmd/gopls/main.go b/cmd/gopls/main.go index 3111da25cc..d8ab33705b 100644 --- a/cmd/gopls/main.go +++ b/cmd/gopls/main.go @@ -19,5 +19,5 @@ import ( func main() { debug.Version += "-cmd.gopls" - tool.Main(context.Background(), cmd.New("", nil), os.Args[1:]) + tool.Main(context.Background(), cmd.New("gopls-legacy", "", nil), os.Args[1:]) } diff --git a/gopls/main.go b/gopls/main.go index 8788239d71..8f49ccc935 100644 --- a/gopls/main.go +++ b/gopls/main.go @@ -17,5 +17,5 @@ import ( ) func main() { - tool.Main(context.Background(), cmd.New("", nil), os.Args[1:]) + tool.Main(context.Background(), cmd.New("gopls", "", nil), os.Args[1:]) } diff --git a/internal/lsp/cmd/cmd.go b/internal/lsp/cmd/cmd.go index c4590379db..6826d04032 100644 --- a/internal/lsp/cmd/cmd.go +++ b/internal/lsp/cmd/cmd.go @@ -45,6 +45,9 @@ type Application struct { // The base cache to use for sessions from this application. cache source.Cache + // The name of the binary, used in help and telemetry. + name string + // The working directory to run commands in. wd string @@ -59,12 +62,13 @@ type Application struct { } // Returns a new Application ready to run. -func New(wd string, env []string) *Application { +func New(name, wd string, env []string) *Application { if wd == "" { wd, _ = os.Getwd() } app := &Application{ cache: cache.New(), + name: name, wd: wd, env: env, } @@ -72,7 +76,7 @@ func New(wd string, env []string) *Application { } // Name implements tool.Application returning the binary name. -func (app *Application) Name() string { return "gopls" } +func (app *Application) Name() string { return app.name } // Usage implements tool.Application returning empty extra argument usage. func (app *Application) Usage() string { return " [command-flags] [command-args]" } diff --git a/internal/lsp/cmd/cmd_test.go b/internal/lsp/cmd/cmd_test.go index 3dbab9ed50..64d74ebe6b 100644 --- a/internal/lsp/cmd/cmd_test.go +++ b/internal/lsp/cmd/cmd_test.go @@ -39,7 +39,7 @@ func testCommandLine(t *testing.T, exporter packagestest.Exporter) { r := &runner{ exporter: exporter, data: data, - app: cmd.New(data.Config.Dir, data.Exported.Config.Env), + app: cmd.New("gopls-test", data.Config.Dir, data.Exported.Config.Env), ctx: tests.Context(t), } tests.Run(t, r, data) diff --git a/internal/lsp/cmd/definition_test.go b/internal/lsp/cmd/definition_test.go index bf1531a658..992149d0fe 100644 --- a/internal/lsp/cmd/definition_test.go +++ b/internal/lsp/cmd/definition_test.go @@ -55,7 +55,7 @@ func TestDefinitionHelpExample(t *testing.T) { fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} { args := append(baseArgs, query) got := captureStdOut(t, func() { - tool.Main(tests.Context(t), cmd.New("", nil), args) + tool.Main(tests.Context(t), cmd.New("gopls-test", "", nil), args) }) if !expect.MatchString(got) { t.Errorf("test with %v\nexpected:\n%s\ngot:\n%s", args, expect, got) diff --git a/internal/lsp/cmd/format_test.go b/internal/lsp/cmd/format_test.go index b486fac1b9..b7cdabdcfe 100644 --- a/internal/lsp/cmd/format_test.go +++ b/internal/lsp/cmd/format_test.go @@ -37,7 +37,7 @@ func (r *runner) Format(t *testing.T, data tests.Formats) { //TODO: our error handling differs, for now just skip unformattable files continue } - app := cmd.New(r.data.Config.Dir, r.data.Config.Env) + app := cmd.New("gopls-test", r.data.Config.Dir, r.data.Config.Env) got := captureStdOut(t, func() { tool.Main(r.ctx, app, append([]string{"-remote=internal", "format"}, args...)) })