Skip to content

Commit 8bdc4d3

Browse files
authored
fix: help command (#2681)
1 parent 7bbbe77 commit 8bdc4d3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pkg/commands/executor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func NewExecutor(version, commit, date string) *Executor {
110110
e.log.Fatalf("Can't read config: %s", err)
111111
}
112112

113-
if commandLineCfg.Run.Go == "" && e.cfg.Run.Go == "" {
113+
if (commandLineCfg == nil || commandLineCfg.Run.Go == "") && e.cfg != nil && e.cfg.Run.Go == "" {
114114
e.cfg.Run.Go = config.DetectGoVersion()
115115
}
116116

scripts/expand_website_templates/main.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -143,44 +143,44 @@ func getLatestVersion() (string, error) {
143143
http.NoBody,
144144
)
145145
if err != nil {
146-
return "", fmt.Errorf("failed to prepare a http request: %s", err)
146+
return "", fmt.Errorf("failed to prepare a http request: %w", err)
147147
}
148148
req.Header.Add("Accept", "application/vnd.github.v3+json")
149149
resp, err := http.DefaultClient.Do(req)
150150
if err != nil {
151-
return "", fmt.Errorf("failed to get http response for the latest tag: %s", err)
151+
return "", fmt.Errorf("failed to get http response for the latest tag: %w", err)
152152
}
153153
defer resp.Body.Close()
154154
body, err := io.ReadAll(resp.Body)
155155
if err != nil {
156-
return "", fmt.Errorf("failed to read a body for the latest tag: %s", err)
156+
return "", fmt.Errorf("failed to read a body for the latest tag: %w", err)
157157
}
158158
release := latestRelease{}
159159
err = json.Unmarshal(body, &release)
160160
if err != nil {
161-
return "", fmt.Errorf("failed to unmarshal the body for the latest tag: %s", err)
161+
return "", fmt.Errorf("failed to unmarshal the body for the latest tag: %w", err)
162162
}
163163
return release.TagName, nil
164164
}
165165

166166
func buildTemplateContext() (map[string]string, error) {
167167
golangciYamlExample, err := os.ReadFile(".golangci.example.yml")
168168
if err != nil {
169-
return nil, fmt.Errorf("can't read .golangci.example.yml: %s", err)
169+
return nil, fmt.Errorf("can't read .golangci.example.yml: %w", err)
170170
}
171171

172172
snippets, err := extractExampleSnippets(golangciYamlExample)
173173
if err != nil {
174-
return nil, fmt.Errorf("can't read .golangci.example.yml: %s", err)
174+
return nil, fmt.Errorf("can't read .golangci.example.yml: %w", err)
175175
}
176176

177177
if err = exec.Command("make", "build").Run(); err != nil {
178-
return nil, fmt.Errorf("can't run go install: %s", err)
178+
return nil, fmt.Errorf("can't run go install: %w", err)
179179
}
180180

181181
lintersOut, err := exec.Command("./golangci-lint", "help", "linters").Output()
182182
if err != nil {
183-
return nil, fmt.Errorf("can't run linters cmd: %s", err)
183+
return nil, fmt.Errorf("can't run linters cmd: %w", err)
184184
}
185185

186186
lintersOutParts := bytes.Split(lintersOut, []byte("\n\n"))
@@ -190,7 +190,7 @@ func buildTemplateContext() (map[string]string, error) {
190190
helpCmd.Env = append(helpCmd.Env, "HELP_RUN=1") // make default concurrency stable: don't depend on machine CPU number
191191
help, err := helpCmd.Output()
192192
if err != nil {
193-
return nil, fmt.Errorf("can't run help cmd: %s", err)
193+
return nil, fmt.Errorf("can't run help cmd: %w", err)
194194
}
195195

196196
helpLines := bytes.Split(help, []byte("\n"))
@@ -202,7 +202,7 @@ func buildTemplateContext() (map[string]string, error) {
202202

203203
latestVersion, err := getLatestVersion()
204204
if err != nil {
205-
return nil, fmt.Errorf("failed to get latest version: %s", err)
205+
return nil, fmt.Errorf("failed to get the latest version: %w", err)
206206
}
207207

208208
return map[string]string{

0 commit comments

Comments
 (0)