From ef2e6e3bc39c319fba38d65d78b028bf806aaefc Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Sun, 9 Jul 2023 10:29:04 -0300 Subject: [PATCH] Upgrade Go to 1.20 - Update the version in `go.mod` - Change from `interface{}` to `any` - Stop using `io/ioutil` --- .github/workflows/ci.yml | 3 +- .github/workflows/release.yml | 2 +- .golangci.yaml | 2 +- go.mod | 9 ++++-- langserver/duration.go | 4 +-- langserver/handle_initialize.go | 2 +- langserver/handle_shutdown.go | 2 +- .../handle_text_document_code_action.go | 6 ++-- langserver/handle_text_document_completion.go | 2 +- langserver/handle_text_document_definition.go | 5 ++- langserver/handle_text_document_did_change.go | 2 +- langserver/handle_text_document_did_close.go | 2 +- langserver/handle_text_document_did_open.go | 2 +- langserver/handle_text_document_did_save.go | 2 +- langserver/handle_text_document_formatting.go | 2 +- langserver/handle_text_document_hover.go | 2 +- langserver/handle_text_document_symbol.go | 2 +- ...ndle_workspace_did_change_configuration.go | 4 +-- ..._workspace_did_change_workspace_folders.go | 4 +-- .../handle_workspace_execute_command.go | 2 +- .../handle_workspace_workspace_folders.go | 4 +-- langserver/handler.go | 12 +++++-- langserver/handler_go112.go | 7 ---- langserver/handler_go113.go | 14 -------- langserver/lsp.go | 32 +++++++++---------- main.go | 10 +++--- 26 files changed, 63 insertions(+), 77 deletions(-) delete mode 100644 langserver/handler_go112.go delete mode 100644 langserver/handler_go113.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93167de..a8d5b63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,13 +14,12 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: 1.x - name: Lint uses: golangci/golangci-lint-action@v3 with: - version: v1.50.1 args: --verbose - name: Test run: make test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a29f6b..2d9aa3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout code uses: actions/checkout@master - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: 1.x - name: Cross build diff --git a/.golangci.yaml b/.golangci.yaml index 28ffcb1..0c25b8a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -25,7 +25,7 @@ linters-settings: arguments: - maxLitCount: "3" allowStrs: '""' - allowInts: "0,1,2,3,4,5,0700,0660" + allowInts: "0,1,2,3,4,5,0700,0660,0o700,0o660" allowFloats: "0.0,0.,1.0,1.,2.0,2." - name: blank-imports - name: context-as-argument diff --git a/go.mod b/go.mod index f388664..c2c9517 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,15 @@ module github.com/mattn/efm-langserver -go 1.13 +go 1.20 require ( - github.com/kr/pretty v0.1.0 // indirect github.com/mattn/go-unicodeclass v0.0.1 github.com/reviewdog/errorformat v0.0.0-20220309155058-b075c45b6d9a github.com/sourcegraph/jsonrpc2 v0.1.0 - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) + +require ( + github.com/kr/pretty v0.1.0 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect +) diff --git a/langserver/duration.go b/langserver/duration.go index b4e2901..c8c6d98 100644 --- a/langserver/duration.go +++ b/langserver/duration.go @@ -16,7 +16,7 @@ func (d Duration) MarshalJSON() ([]byte, error) { // UnmarshalJSON method Unmash duration from string or decimal func (d *Duration) UnmarshalJSON(b []byte) error { - var v interface{} + var v any if err := json.Unmarshal(b, &v); err != nil { return err } @@ -37,7 +37,7 @@ func (d *Duration) UnmarshalJSON(b []byte) error { } // UnmarshalYAML method Unmash duration from string or decimal -func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/langserver/handle_initialize.go b/langserver/handle_initialize.go index 146465f..4b21991 100644 --- a/langserver/handle_initialize.go +++ b/langserver/handle_initialize.go @@ -9,7 +9,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleInitialize(_ context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleInitialize(_ context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_shutdown.go b/langserver/handle_shutdown.go index 875fc44..345e782 100644 --- a/langserver/handle_shutdown.go +++ b/langserver/handle_shutdown.go @@ -6,7 +6,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleShutdown(_ context.Context, conn *jsonrpc2.Conn, _ *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleShutdown(_ context.Context, conn *jsonrpc2.Conn, _ *jsonrpc2.Request) (result any, err error) { if h.lintTimer != nil { h.lintTimer.Stop() } diff --git a/langserver/handle_text_document_code_action.go b/langserver/handle_text_document_code_action.go index 2433902..153d53e 100644 --- a/langserver/handle_text_document_code_action.go +++ b/langserver/handle_text_document_code_action.go @@ -14,7 +14,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentCodeAction(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentCodeAction(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } @@ -27,7 +27,7 @@ func (h *langHandler) handleTextDocumentCodeAction(_ context.Context, _ *jsonrpc return h.codeAction(params.TextDocument.URI, ¶ms) } -func (h *langHandler) executeCommand(params *ExecuteCommandParams) (interface{}, error) { +func (h *langHandler) executeCommand(params *ExecuteCommandParams) (any, error) { if len(params.Arguments) != 1 { return nil, fmt.Errorf("invalid command") } @@ -170,7 +170,7 @@ func filterCommands(uri DocumentURI, commands []Command) []Command { results = append(results, Command{ Title: v.Title, Command: fmt.Sprintf("efm-langserver\t%s\t%s", v.Command, string(uri)), - Arguments: []interface{}{string(uri)}, + Arguments: []any{string(uri)}, }) } return results diff --git a/langserver/handle_text_document_completion.go b/langserver/handle_text_document_completion.go index 4d8ef90..15cd454 100644 --- a/langserver/handle_text_document_completion.go +++ b/langserver/handle_text_document_completion.go @@ -15,7 +15,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentCompletion(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentCompletion(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_definition.go b/langserver/handle_text_document_definition.go index 2c14c85..07b4da7 100644 --- a/langserver/handle_text_document_definition.go +++ b/langserver/handle_text_document_definition.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -17,7 +16,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentDefinition(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentDefinition(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } @@ -51,7 +50,7 @@ func (h *langHandler) findTag(fname string, tag string) ([]Location, error) { if token[0] == tag { token[2] = strings.TrimRight(token[2], `;"`) fullpath := filepath.Clean(filepath.Join(h.rootPath, token[1])) - b, err := ioutil.ReadFile(fullpath) + b, err := os.ReadFile(fullpath) if err != nil { continue } diff --git a/langserver/handle_text_document_did_change.go b/langserver/handle_text_document_did_change.go index ea7a641..61cc4cb 100644 --- a/langserver/handle_text_document_did_change.go +++ b/langserver/handle_text_document_did_change.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentDidChange(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentDidChange(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_did_close.go b/langserver/handle_text_document_did_close.go index 4b54ef3..5f1d022 100644 --- a/langserver/handle_text_document_did_close.go +++ b/langserver/handle_text_document_did_close.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentDidClose(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentDidClose(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_did_open.go b/langserver/handle_text_document_did_open.go index 8f84d8b..6b58425 100644 --- a/langserver/handle_text_document_did_open.go +++ b/langserver/handle_text_document_did_open.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentDidOpen(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentDidOpen(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_did_save.go b/langserver/handle_text_document_did_save.go index 304204d..7d6e791 100644 --- a/langserver/handle_text_document_did_save.go +++ b/langserver/handle_text_document_did_save.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentDidSave(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentDidSave(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_formatting.go b/langserver/handle_text_document_formatting.go index 004df52..70c59e8 100644 --- a/langserver/handle_text_document_formatting.go +++ b/langserver/handle_text_document_formatting.go @@ -16,7 +16,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentFormatting(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentFormatting(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_hover.go b/langserver/handle_text_document_hover.go index b9c6db4..bdae82e 100644 --- a/langserver/handle_text_document_hover.go +++ b/langserver/handle_text_document_hover.go @@ -15,7 +15,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentHover(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentHover(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_text_document_symbol.go b/langserver/handle_text_document_symbol.go index 461e21f..52c234f 100644 --- a/langserver/handle_text_document_symbol.go +++ b/langserver/handle_text_document_symbol.go @@ -16,7 +16,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleTextDocumentSymbol(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleTextDocumentSymbol(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_workspace_did_change_configuration.go b/langserver/handle_workspace_did_change_configuration.go index 01df7f9..163ad48 100644 --- a/langserver/handle_workspace_did_change_configuration.go +++ b/langserver/handle_workspace_did_change_configuration.go @@ -8,7 +8,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleWorkspaceDidChangeConfiguration(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleWorkspaceDidChangeConfiguration(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } @@ -21,7 +21,7 @@ func (h *langHandler) handleWorkspaceDidChangeConfiguration(_ context.Context, _ return h.didChangeConfiguration(¶ms.Settings) } -func (h *langHandler) didChangeConfiguration(config *Config) (interface{}, error) { +func (h *langHandler) didChangeConfiguration(config *Config) (any, error) { if config.Languages != nil { h.configs = *config.Languages } diff --git a/langserver/handle_workspace_did_change_workspace_folders.go b/langserver/handle_workspace_did_change_workspace_folders.go index 35ff499..6f58091 100644 --- a/langserver/handle_workspace_did_change_workspace_folders.go +++ b/langserver/handle_workspace_did_change_workspace_folders.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleDidChangeWorkspaceWorkspaceFolders(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleDidChangeWorkspaceWorkspaceFolders(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } @@ -20,7 +20,7 @@ func (h *langHandler) handleDidChangeWorkspaceWorkspaceFolders(_ context.Context return h.didChangeWorkspaceFolders(¶ms) } -func (h *langHandler) didChangeWorkspaceFolders(params *DidChangeWorkspaceFoldersParams) (result interface{}, err error) { +func (h *langHandler) didChangeWorkspaceFolders(params *DidChangeWorkspaceFoldersParams) (result any, err error) { var folders []string for _, removed := range params.Event.Removed { for _, folder := range h.folders { diff --git a/langserver/handle_workspace_execute_command.go b/langserver/handle_workspace_execute_command.go index a47db44..0cb0c89 100644 --- a/langserver/handle_workspace_execute_command.go +++ b/langserver/handle_workspace_execute_command.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleWorkspaceExecuteCommand(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleWorkspaceExecuteCommand(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } diff --git a/langserver/handle_workspace_workspace_folders.go b/langserver/handle_workspace_workspace_folders.go index c4fb1cc..85eab3a 100644 --- a/langserver/handle_workspace_workspace_folders.go +++ b/langserver/handle_workspace_workspace_folders.go @@ -7,7 +7,7 @@ import ( "github.com/sourcegraph/jsonrpc2" ) -func (h *langHandler) handleWorkspaceWorkspaceFolders(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handleWorkspaceWorkspaceFolders(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { if req.Params == nil { return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams} } @@ -15,7 +15,7 @@ func (h *langHandler) handleWorkspaceWorkspaceFolders(_ context.Context, _ *json return h.workspaceFolders() } -func (h *langHandler) workspaceFolders() (result interface{}, err error) { +func (h *langHandler) workspaceFolders() (result any, err error) { workspaces := []WorkspaceFolder{} for _, workspace := range h.folders { workspaces = append(workspaces, WorkspaceFolder{ diff --git a/langserver/handler.go b/langserver/handler.go index 30aaac2..c848508 100644 --- a/langserver/handler.go +++ b/langserver/handler.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "log" "net/url" "os" @@ -285,7 +284,7 @@ func matchRootPath(fname string, markers []string) string { dir := filepath.Dir(filepath.Clean(fname)) var prev string for dir != prev { - files, _ := ioutil.ReadDir(dir) + files, _ := os.ReadDir(dir) for _, file := range files { name := file.Name() isDir := file.IsDir() @@ -627,7 +626,7 @@ func (h *langHandler) addFolder(folder string) { } } -func (h *langHandler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) { +func (h *langHandler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) { switch req.Method { case "initialize": return h.handleInitialize(ctx, conn, req) @@ -677,3 +676,10 @@ func replaceCommandInputFilename(command, fname, rootPath string) string { return command } + +func succeeded(err error) bool { + exitErr, ok := err.(*exec.ExitError) + // When the context is canceled, the process is killed, + // and the exit code is -1 + return ok && exitErr.ExitCode() < 0 +} diff --git a/langserver/handler_go112.go b/langserver/handler_go112.go deleted file mode 100644 index 639fb86..0000000 --- a/langserver/handler_go112.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !go1.13 - -package langserver - -func succeeded(err error) bool { - return err == nil -} diff --git a/langserver/handler_go113.go b/langserver/handler_go113.go deleted file mode 100644 index 249b682..0000000 --- a/langserver/handler_go113.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build go1.13 - -package langserver - -import ( - "os/exec" -) - -func succeeded(err error) bool { - exitErr, ok := err.(*exec.ExitError) - // When the context is canceled, the process is killed, - // and the exit code is -1 - return ok && exitErr.ExitCode() < 0 -} diff --git a/langserver/lsp.go b/langserver/lsp.go index 0997c5d..036ce5d 100644 --- a/langserver/lsp.go +++ b/langserver/lsp.go @@ -195,7 +195,7 @@ type PublishDiagnosticsParams struct { } // FormattingOptions is -type FormattingOptions map[string]interface{} +type FormattingOptions map[string]any // DocumentFormattingParams is type DocumentFormattingParams struct { @@ -269,16 +269,16 @@ const ( // Command is type Command struct { - Title string `json:"title" yaml:"title"` - Command string `json:"command" yaml:"command"` - Arguments []interface{} `json:"arguments,omitempty" yaml:"arguments,omitempty"` - OS string `json:"-" yaml:"os,omitempty"` + Title string `json:"title" yaml:"title"` + Command string `json:"command" yaml:"command"` + Arguments []any `json:"arguments,omitempty" yaml:"arguments,omitempty"` + OS string `json:"-" yaml:"os,omitempty"` } // WorkspaceEdit is type WorkspaceEdit struct { - Changes interface{} `json:"changes"` // { [uri: DocumentUri]: TextEdit[]; }; - DocumentChanges interface{} `json:"documentChanges"` // (TextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]); + Changes any `json:"changes"` // { [uri: DocumentUri]: TextEdit[]; }; + DocumentChanges any `json:"documentChanges"` // (TextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]); } // CodeAction is @@ -307,13 +307,13 @@ type CompletionItem struct { AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` CommitCharacters []string `json:"commitCharacters,omitempty"` Command *Command `json:"command,omitempty"` - Data interface{} `json:"data,omitempty"` + Data any `json:"data,omitempty"` } // Hover is type Hover struct { - Contents interface{} `json:"contents"` - Range *Range `json:"range"` + Contents any `json:"contents"` + Range *Range `json:"range"` } // MarkedString is @@ -339,15 +339,15 @@ type MarkupContent struct { // WorkDoneProgressParams is type WorkDoneProgressParams struct { - WorkDoneToken interface{} `json:"workDoneToken"` + WorkDoneToken any `json:"workDoneToken"` } // ExecuteCommandParams is type ExecuteCommandParams struct { WorkDoneProgressParams - Command string `json:"command"` - Arguments []interface{} `json:"arguments,omitempty"` + Command string `json:"command"` + Arguments []any `json:"arguments,omitempty"` } // CodeActionKind is @@ -373,7 +373,7 @@ type CodeActionContext struct { // PartialResultParams is type PartialResultParams struct { - PartialResultToken interface{} `json:"partialResultToken"` + PartialResultToken any `json:"partialResultToken"` } // CodeActionParams is @@ -393,8 +393,8 @@ type DidChangeConfigurationParams struct { // NotificationMessage is type NotificationMessage struct { - Method string `json:"message"` - Params interface{} `json:"params"` + Method string `json:"message"` + Params any `json:"params"` } // DocumentDefinitionParams is diff --git a/main.go b/main.go index 3e46979..5058571 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "context" "flag" "fmt" - "io/ioutil" + "io" "log" "os" "path/filepath" @@ -56,7 +56,7 @@ func main() { } dir := filepath.Join(configHome, "efm-langserver") - if err := os.MkdirAll(dir, 0700); err != nil { + if err := os.MkdirAll(dir, 0o700); err != nil { log.Fatal(err) } @@ -87,7 +87,7 @@ func main() { } if quiet { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) } log.Println("efm-langserver: reading on stdin, writing on stdout") @@ -102,7 +102,7 @@ func main() { var connOpt []jsonrpc2.ConnOpt if logfile != "" { - f, err := os.OpenFile(logfile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0660) + f, err := os.OpenFile(logfile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0o660) if err != nil { log.Fatal(err) } @@ -114,7 +114,7 @@ func main() { } if quiet && (logfile == "" || loglevel < 5) { - connOpt = append(connOpt, jsonrpc2.LogMessages(log.New(ioutil.Discard, "", 0))) + connOpt = append(connOpt, jsonrpc2.LogMessages(log.New(io.Discard, "", 0))) } handler := langserver.NewHandler(config)