Skip to content

Commit

Permalink
Merge pull request #245 from fsouza/upgrade-go
Browse files Browse the repository at this point in the history
Upgrade Go to 1.20
  • Loading branch information
mattn authored Jul 29, 2023
2 parents 8290964 + ef2e6e3 commit 0739914
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 77 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
4 changes: 2 additions & 2 deletions langserver/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
6 changes: 3 additions & 3 deletions langserver/handle_text_document_code_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -27,7 +27,7 @@ func (h *langHandler) handleTextDocumentCodeAction(_ context.Context, _ *jsonrpc
return h.codeAction(params.TextDocument.URI, &params)
}

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")
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
5 changes: 2 additions & 3 deletions langserver/handle_text_document_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand All @@ -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}
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_did_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_did_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_did_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_did_save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
4 changes: 2 additions & 2 deletions langserver/handle_workspace_did_change_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -21,7 +21,7 @@ func (h *langHandler) handleWorkspaceDidChangeConfiguration(_ context.Context, _
return h.didChangeConfiguration(&params.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
}
Expand Down
4 changes: 2 additions & 2 deletions langserver/handle_workspace_did_change_workspace_folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand All @@ -20,7 +20,7 @@ func (h *langHandler) handleDidChangeWorkspaceWorkspaceFolders(_ context.Context
return h.didChangeWorkspaceFolders(&params)
}

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 {
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_workspace_execute_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
Expand Down
4 changes: 2 additions & 2 deletions langserver/handle_workspace_workspace_folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ 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}
}

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{
Expand Down
12 changes: 9 additions & 3 deletions langserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
Expand Down Expand Up @@ -300,7 +299,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()
Expand Down Expand Up @@ -646,7 +645,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)
Expand Down Expand Up @@ -700,3 +699,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
}
7 changes: 0 additions & 7 deletions langserver/handler_go112.go

This file was deleted.

14 changes: 0 additions & 14 deletions langserver/handler_go113.go

This file was deleted.

Loading

0 comments on commit 0739914

Please sign in to comment.