| 1 | --- |
| 2 | title: "Gopls: Command-line interface" |
| 3 | --- |
| 4 | |
| 5 | The `gopls` command provides a number of subcommands that expose much |
| 6 | of the server's functionality. However, the interface is currently |
| 7 | **experimental** and **subject to change at any point.** |
| 8 | It is not efficient, complete, flexible, or officially supported. |
| 9 | |
| 10 | Its primary use is as a debugging aid. |
| 11 | For example, this command reports the location of references to the |
| 12 | symbol at the specified file/line/column: |
| 13 | |
| 14 | ``` |
| 15 | $ gopls references ./gopls/main.go:35:8 |
| 16 | Log: Loading packages... |
| 17 | Info: Finished loading packages. |
| 18 | /home/gopher/xtools/go/packages/gopackages/main.go:27:7-11 |
| 19 | /home/gopher/xtools/gopls/internal/cmd/integration_test.go:1062:7-11 |
| 20 | /home/gopher/xtools/gopls/internal/test/integration/bench/bench_test.go:59:8-12 |
| 21 | /home/gopher/xtools/gopls/internal/test/integration/regtest.go:140:8-12 |
| 22 | /home/gopher/xtools/gopls/main.go:35:7-11 |
| 23 | ``` |
| 24 | |
| 25 | See https://go.dev/issue/63693 for a discussion of its future. |
| 26 | |
| 27 | Learn about available commands and flags by running `gopls help`. |
| 28 | |
| 29 | Positions within files are specified as `file.go:line:column` triples, |
| 30 | where the line and column start at 1, and columns are measured in |
| 31 | bytes of the UTF-8 encoding. |
| 32 | Alternatively, positions may be specified by the byte offset within |
| 33 | the UTF-8 encoding of the file, starting from zero, for example |
| 34 | `file.go:#1234`. |
| 35 | (When working in non-ASCII files, beware that your editor may report a |
| 36 | position's offset within its file using a different measure such as |
| 37 | UTF-16 codes, Unicode code points, or graphemes). |