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.
5 // Package debug exports debug information for gopls.
18 PlainText = PrintMode(iota)
23 // Version is a manually-updated mechanism for tracking versions.
24 var Version = "master"
26 // PrintServerInfo writes HTML debug info to w for the Instance.
27 func (i *Instance) PrintServerInfo(ctx context.Context, w io.Writer) {
28 section(w, HTML, "Server Instance", func() {
29 fmt.Fprintf(w, "Start time: %v\n", i.StartTime)
30 fmt.Fprintf(w, "LogFile: %s\n", i.Logfile)
31 fmt.Fprintf(w, "Working directory: %s\n", i.Workdir)
32 fmt.Fprintf(w, "Address: %s\n", i.ServerAddress)
33 fmt.Fprintf(w, "Debug address: %s\n", i.DebugAddress)
35 PrintVersionInfo(ctx, w, true, HTML)
38 // PrintVersionInfo writes version information to w, using the output format
39 // specified by mode. verbose controls whether additional information is
40 // written, including section headers.
41 func PrintVersionInfo(ctx context.Context, w io.Writer, verbose bool, mode PrintMode) {
43 printBuildInfo(w, false, mode)
46 section(w, mode, "Build info", func() {
47 printBuildInfo(w, true, mode)
51 func section(w io.Writer, mode PrintMode, title string, body func()) {
54 fmt.Fprintln(w, title)
55 fmt.Fprintln(w, strings.Repeat("-", len(title)))
58 fmt.Fprintf(w, "#### %s\n\n```\n", title)
60 fmt.Fprintf(w, "```\n")
62 fmt.Fprintf(w, "<h3>%s</h3>\n<pre>\n", title)
64 fmt.Fprint(w, "</pre>\n")