1
0
mirror of https://github.com/golang/go synced 2024-10-01 09:38:36 -06:00
go/internal/lsp/info.go
Ian Cottrell 44dd571771 internal/lsp: add version and bug commands
Also log gopls version information on startup in server mode.

Change-Id: If7bf85d19f993430709b1fae83083e6fdfe1b2ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/175199
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-11 04:16:02 +00:00

39 lines
820 B
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.
// +build go1.12
package lsp
import (
"fmt"
"io"
"runtime/debug"
)
func printBuildInfo(w io.Writer, verbose bool) {
if info, ok := debug.ReadBuildInfo(); ok {
fmt.Fprintf(w, "%v\n", info.Path)
printModuleInfo(w, &info.Main)
if verbose {
for _, dep := range info.Deps {
printModuleInfo(w, dep)
}
}
} else {
fmt.Fprintf(w, "no module information, gopls not built in module mode\n")
}
}
func printModuleInfo(w io.Writer, m *debug.Module) {
fmt.Fprintf(w, " %s@%s", m.Path, m.Version)
if m.Sum != "" {
fmt.Fprintf(w, " %s", m.Sum)
}
if m.Replace != nil {
fmt.Fprintf(w, " => %v", m.Replace.Path)
}
fmt.Fprintf(w, "\n")
}