Skip to content

Commit 7e668d5

Browse files
authored
chore: migrate to golangci-lint v2 (#962)
Signed-off-by: Donnie Adams <[email protected]>
1 parent 4b87a83 commit 7e668d5

File tree

20 files changed

+158
-144
lines changed

20 files changed

+158
-144
lines changed

.golangci.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1+
version: "2"
12
run:
23
timeout: 5m
3-
44
output:
55
formats:
6-
- format: colored-line-number
7-
6+
text:
7+
path: stdout
88
linters:
9-
disable-all: true
9+
default: none
1010
enable:
11-
- errcheck
12-
- gofmt
13-
- gosimple
14-
- govet
15-
- ineffassign
16-
- staticcheck
17-
- typecheck
18-
- thelper
19-
- unused
20-
- goimports
21-
- whitespace
22-
- revive
23-
fast: false
11+
- errcheck
12+
- govet
13+
- ineffassign
14+
- revive
15+
- staticcheck
16+
- thelper
17+
- unused
18+
- whitespace
19+
exclusions:
20+
generated: lax
21+
presets:
22+
- comments
23+
- common-false-positives
24+
- legacy
25+
- std-error-handling
26+
paths:
27+
- third_party$
28+
- builtin$
29+
- examples$
30+
issues:
2431
max-same-issues: 50
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports
36+
exclusions:
37+
generated: lax
38+
paths:
39+
- third_party$
40+
- builtin$
41+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ smoke: build
2222
smoke:
2323
go test -v -tags='smoke' ./pkg/tests/smoke/...
2424

25-
GOLANGCI_LINT_VERSION ?= v1.60.1
25+
GOLANGCI_LINT_VERSION ?= v2.1.2
2626
lint:
2727
if ! command -v golangci-lint &> /dev/null; then \
2828
echo "Could not find golangci-lint, installing version $(GOLANGCI_LINT_VERSION)."; \

pkg/builtin/builtin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ func DefaultModel(name, defaultModel string) (types.Tool, bool) {
280280
// Legacy syntax not used anymore
281281
name = strings.TrimSuffix(name, "?")
282282
t, ok := tools[name]
283-
t.Parameters.Name = name
284-
t.Parameters.ModelName = defaultModel
283+
t.Name = name
284+
t.ModelName = defaultModel
285285
t.ID = name
286286
t.Instructions = "#!" + name
287287
return SetDefaults(t), ok

pkg/builtin/defaults.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func SetDefaultModel(model string) {
1818
}
1919

2020
func SetDefaults(tool types.Tool) types.Tool {
21-
if tool.Parameters.ModelName == "" {
22-
tool.Parameters.ModelName = GetDefaultModel()
21+
if tool.ModelName == "" {
22+
tool.ModelName = GetDefaultModel()
2323
}
2424
return tool
2525
}

pkg/chat/chat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Start(ctx context.Context, prevState runner.ChatState, chatter Chatter, prg
6161
if startInput != "" {
6262
input = startInput
6363
startInput = ""
64-
} else if targetTool := prog.ToolSet[prog.EntryToolID]; !((prevState == nil || prevState == "") && targetTool.Arguments == nil && targetTool.Instructions != "") {
64+
} else if targetTool := prog.ToolSet[prog.EntryToolID]; prevState != nil && prevState != "" || targetTool.Arguments != nil || targetTool.Instructions == "" {
6565
// The above logic will skip prompting if this is the first loop and the chat expects no args
6666
input, ok, err = prompter.Readline()
6767
if !ok || err != nil {

pkg/cli/gptscript.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) {
366366

367367
// If the file is external, then set the SCRIPTS_PATH to the current working directory. Otherwise,
368368
// set it to the directory of the script and set the file to the base.
369-
if !(strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "github.com")) {
369+
if !strings.HasPrefix(file, "http://") && !strings.HasPrefix(file, "https://") && !strings.HasPrefix(file, "github.com") {
370370
absPathToScript, err := filepath.Abs(file)
371371
if err != nil {
372372
return fmt.Errorf("cannot determine absolute path to script %s: %v", file, err)
@@ -469,8 +469,8 @@ func (r *GPTScript) Run(cmd *cobra.Command, args []string) (retErr error) {
469469
// Don't use cmd.Context() because then sigint will cancel everything
470470
return tui.Run(context.Background(), args[0], tui.RunOptions{
471471
ClientOpts: &gptscript2.GlobalOptions{
472-
OpenAIAPIKey: r.OpenAIOptions.APIKey,
473-
OpenAIBaseURL: r.OpenAIOptions.BaseURL,
472+
OpenAIAPIKey: r.APIKey,
473+
OpenAIBaseURL: r.BaseURL,
474474
DefaultModel: r.DefaultModel,
475475
DefaultModelProvider: r.DefaultModelProvider,
476476
},

pkg/engine/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (e *Engine) runCommand(ctx Context, tool types.Tool, input string, toolCate
171171
// If this is a sub-call, then don't return the error; return the error as a message so that the LLM can retry.
172172
return fmt.Sprintf("ERROR: got (%v) while running tool, OUTPUT: %s", err, stdoutAndErr), nil
173173
}
174-
log.Errorf("failed to run tool [%s] cmd %v: %v", tool.Parameters.Name, cmd.Args, err)
174+
log.Errorf("failed to run tool [%s] cmd %v: %v", tool.Name, cmd.Args, err)
175175
return "", fmt.Errorf("ERROR: %s: %w", stdoutAndErr, err)
176176
}
177177

pkg/engine/daemon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (e *Engine) startDaemon(tool types.Tool) (string, error) {
175175
return w.Close()
176176
}
177177

178-
log.Infof("launched [%s][%s] port [%d] %v", tool.Parameters.Name, tool.ID, port, cmd.Args)
178+
log.Infof("launched [%s][%s] port [%d] %v", tool.Name, tool.ID, port, cmd.Args)
179179
if err := cmd.Start(); err != nil {
180180
stop()
181181
return url, err
@@ -195,7 +195,7 @@ func (e *Engine) startDaemon(tool types.Tool) (string, error) {
195195
go func() {
196196
err := cmd.Wait()
197197
if err != nil {
198-
log.Debugf("daemon exited tool [%s] %v: %v", tool.Parameters.Name, cmd.Args, err)
198+
log.Debugf("daemon exited tool [%s] %v: %v", tool.Name, cmd.Args, err)
199199
}
200200
_ = r.Close()
201201
_ = w.Close()

pkg/engine/engine.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ func (c *Context) WrappedContext(e *Engine) context.Context {
285285
}
286286

287287
func populateMessageParams(ctx Context, completion *types.CompletionRequest, tool types.Tool) error {
288-
completion.Model = tool.Parameters.ModelName
289-
completion.MaxTokens = tool.Parameters.MaxTokens
290-
completion.JSONResponse = tool.Parameters.JSONResponse
291-
completion.Cache = tool.Parameters.Cache
292-
completion.Chat = tool.Parameters.Chat
293-
completion.Temperature = tool.Parameters.Temperature
294-
completion.InternalSystemPrompt = tool.Parameters.InternalPrompt
288+
completion.Model = tool.ModelName
289+
completion.MaxTokens = tool.MaxTokens
290+
completion.JSONResponse = tool.JSONResponse
291+
completion.Cache = tool.Cache
292+
completion.Chat = tool.Chat
293+
completion.Temperature = tool.Temperature
294+
completion.InternalSystemPrompt = tool.InternalPrompt
295295

296296
if tool.Chat && completion.InternalSystemPrompt == nil {
297297
completion.InternalSystemPrompt = new(bool)

pkg/engine/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (e *Engine) runHTTP(ctx Context, tool types.Tool, input string) (cmdRet *Re
112112
}
113113
}
114114

115-
req.Header.Set("X-GPTScript-Tool-Name", tool.Parameters.Name)
115+
req.Header.Set("X-GPTScript-Tool-Name", tool.Name)
116116

117117
if err := json.Unmarshal([]byte(input), &map[string]any{}); err == nil {
118118
req.Header.Set("Content-Type", "application/json")

0 commit comments

Comments
 (0)