Debian Codegraph @

gopls/main.go

raw symbols SCIP
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.
4
5 // Gopls (pronounced “go please”) is an LSP server for Go.
6 // The Language Server Protocol allows any text editor
7 // to be extended with IDE-like features;
8 // see https://langserver.org/ for details.
9 //
10 // See https://go.dev/gopls for comprehensive documentation on Gopls.
11 package main
12
13 import (
14 "context"
15 "log"
16 "os"
17
18 "golang.org/x/telemetry"
19 "golang.org/x/telemetry/counter"
20 "golang.org/x/tools/gopls/internal/cmd"
21 "golang.org/x/tools/gopls/internal/filecache"
22 "golang.org/x/tools/gopls/internal/tool"
23 versionpkg "golang.org/x/tools/gopls/internal/version"
24 )
25
26 var version = "" // if set by the linker, overrides the gopls version
27
28 func main() {
29 versionpkg.VersionOverride = version
30
31 telemetry.Start(telemetry.Config{
32 ReportCrashes: true,
33 Upload: true,
34 })
35
36 // Force early creation of the filecache and refuse to start
37 // if there were unexpected errors such as ENOSPC. This
38 // minimizes the window of exposure to deletion of the
39 // executable, and ensures that all subsequent calls to
40 // filecache.Get cannot fail for these two reasons;
41 // see issue #67433.
42 //
43 // This leaves only one likely cause for later failures:
44 // deletion of the cache while gopls is running. If the
45 // problem continues, we could periodically stat the cache
46 // directory (for example at the start of every RPC) and
47 // either re-create it or just fail the RPC with an
48 // informative error and terminate the process.
49 if _, err := filecache.Get("nonesuch", [32]byte{}, filecache.Bytes); err != nil && err != filecache.ErrNotFound {
50 counter.Inc("gopls/nocache")
51 log.Fatalf("gopls cannot access its persistent index (disk full?): %v", err)
52 }
53
54 ctx := context.Background()
55 tool.Main(ctx, cmd.New(), os.Args[1:])
56 }