tools: Index | Files | Directories

package debug

import ""

Package debug exports debug information for gopls.


Package Files

info.go metrics.go rpc.go serve.go trace.go


const (
    PlainText = PrintMode(iota)
const Version = "master"

Version is a manually-updated mechanism for tracking versions.


var BaseTemplate = template.Must(template.New("").Parse("" /* 944 byte string literal not displayed */,
    "fuint64":  fuint64,
    "fuint32":  fuint32,
    "fcontent": fcontent,
    "localAddress": func(s string) string {

        host, port, err := net.SplitHostPort(s)
        if err != nil {
            return s
        ip := net.ParseIP(host)
        if ip == nil {
            return s
        if ip.IsLoopback() || ip.IsUnspecified() {
            return "localhost:" + port
        return s
    "options": func(s *cache.Session) []string {
        return showOptions(s.Options())
var CacheTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 252 byte string literal not displayed */,
var ClientTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 335 byte string literal not displayed */,
var DebugTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(`
{{define "title"}}GoPls Debug pages{{end}}
{{define "body"}}
<a href="/debug/pprof">Profiling</a>
var FileTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 341 byte string literal not displayed */,
var InfoTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(`
{{define "title"}}GoPls version information{{end}}
{{define "body"}}
var MainTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 673 byte string literal not displayed */,
var MemoryTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 1811 byte string literal not displayed */,
var RPCTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 717 byte string literal not displayed */,
var ServerTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 262 byte string literal not displayed */,
var SessionTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 374 byte string literal not displayed */,
var TraceTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 713 byte string literal not displayed */,
var ViewTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse("" /* 255 byte string literal not displayed */,

func PrintVersionInfo Uses

func PrintVersionInfo(ctx context.Context, w io.Writer, verbose bool, mode PrintMode)

PrintVersionInfo writes version information to w, using the output format specified by mode. verbose controls whether additional information is written, including section headers.

func StdTrace Uses

func StdTrace(exporter event.Exporter) event.Exporter

func WithInstance Uses

func WithInstance(ctx context.Context, workdir, agent string) context.Context

WithInstance creates debug instance ready for use using the supplied configuration and stores it in the returned context.

type Client Uses

type Client struct {
    Session      *cache.Session
    DebugAddress string
    Logfile      string
    GoplsPath    string
    ServerID     string

A Client is an incoming connection from a remote client.

type Instance Uses

type Instance struct {
    Logfile              string
    StartTime            time.Time
    ServerAddress        string
    DebugAddress         string
    ListenedDebugAddress string
    Workdir              string
    OCAgentConfig        string

    LogWriter io.Writer

    State *State
    // contains filtered or unexported fields

An Instance holds all debug information associated with a gopls instance.

func GetInstance Uses

func GetInstance(ctx context.Context) *Instance

func (*Instance) MonitorMemory Uses

func (i *Instance) MonitorMemory(ctx context.Context)

MonitorMemory starts recording memory statistics each second.

func (*Instance) PrintServerInfo Uses

func (i *Instance) PrintServerInfo(ctx context.Context, w io.Writer)

PrintServerInfo writes HTML debug info to w for the Instance.

func (*Instance) Serve Uses

func (i *Instance) Serve(ctx context.Context) error

Serve starts and runs a debug server in the background. It also logs the port the server starts on, to allow for :0 auto assigned ports.

func (*Instance) SetLogFile Uses

func (i *Instance) SetLogFile(logfile string, isDaemon bool) (func(), error)

SetLogFile sets the logfile for use with this instance.

type Module Uses

type Module struct {
    Replace *ModuleVersion `json:"replace,omitempty"`

type ModuleVersion Uses

type ModuleVersion struct {
    Path    string `json:"path,omitempty"`
    Version string `json:"version,omitempty"`
    Sum     string `json:"sum,omitempty"`

type PrintMode Uses

type PrintMode int

type Rpcs Uses

type Rpcs struct {
    Inbound  []*rpcStats // stats for incoming lsp rpcs sorted by method name
    Outbound []*rpcStats // stats for outgoing lsp rpcs sorted by method name
    // contains filtered or unexported fields

func (*Rpcs) ProcessEvent Uses

func (r *Rpcs) ProcessEvent(ctx context.Context, ev core.Event, lm label.Map) context.Context

type Server Uses

type Server struct {
    ID           string
    DebugAddress string
    Logfile      string
    GoplsPath    string
    ClientID     string

A Server is an outgoing connection to a remote LSP server.

type ServerVersion Uses

type ServerVersion struct {
    Deps []*Module `json:"deps,omitempty"`

ServerVersion is the format used by gopls to report its version to the client. This format is structured so that the client can parse it easily.

func VersionInfo Uses

func VersionInfo() *ServerVersion

VersionInfo returns the build info for the gopls process. If it was not built in module mode, we return a GOPATH-specific message with the hardcoded version.

type State Uses

type State struct {
    // contains filtered or unexported fields

State holds debugging information related to the server state.

func (*State) Cache Uses

func (st *State) Cache(id string) *cache.Cache

Cache returns the Cache that matches the supplied id.

func (*State) Caches Uses

func (st *State) Caches() []*cache.Cache

Caches returns the set of Cache objects currently being served.

func (*State) Client Uses

func (st *State) Client(id string) *Client

Client returns the Client matching the supplied id.

func (*State) Clients Uses

func (st *State) Clients() []*Client

Clients returns the set of Clients currently being served.

func (*State) Servers Uses

func (st *State) Servers() []*Server

Servers returns the set of Servers the instance is currently connected to.

func (*State) Session Uses

func (st *State) Session(id string) *cache.Session

Session returns the Session that matches the supplied id.

func (*State) Sessions Uses

func (st *State) Sessions() []*cache.Session

Sessions returns the set of Session objects currently being served.

func (*State) View Uses

func (st *State) View(id string) *cache.View

View returns the View that matches the supplied id.

func (*State) Views Uses

func (st *State) Views() []*cache.View

Views returns the set of View objects currently being served.

type TraceResults Uses

type TraceResults struct {
    Traces   []*traceSet
    Selected *traceSet


logPackage log provides helper methods for exporting log events to the internal/event package.
tagPackage tag provides the labels used for telemetry throughout gopls.

Package debug imports 37 packages (graph) and is imported by 13 packages. Updated 2021-01-16. Refresh now. Tools for package owners.