@@ -143,44 +143,44 @@ func getLatestVersion() (string, error) {
143
143
http .NoBody ,
144
144
)
145
145
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 )
147
147
}
148
148
req .Header .Add ("Accept" , "application/vnd.github.v3+json" )
149
149
resp , err := http .DefaultClient .Do (req )
150
150
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 )
152
152
}
153
153
defer resp .Body .Close ()
154
154
body , err := io .ReadAll (resp .Body )
155
155
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 )
157
157
}
158
158
release := latestRelease {}
159
159
err = json .Unmarshal (body , & release )
160
160
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 )
162
162
}
163
163
return release .TagName , nil
164
164
}
165
165
166
166
func buildTemplateContext () (map [string ]string , error ) {
167
167
golangciYamlExample , err := os .ReadFile (".golangci.example.yml" )
168
168
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 )
170
170
}
171
171
172
172
snippets , err := extractExampleSnippets (golangciYamlExample )
173
173
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 )
175
175
}
176
176
177
177
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 )
179
179
}
180
180
181
181
lintersOut , err := exec .Command ("./golangci-lint" , "help" , "linters" ).Output ()
182
182
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 )
184
184
}
185
185
186
186
lintersOutParts := bytes .Split (lintersOut , []byte ("\n \n " ))
@@ -190,7 +190,7 @@ func buildTemplateContext() (map[string]string, error) {
190
190
helpCmd .Env = append (helpCmd .Env , "HELP_RUN=1" ) // make default concurrency stable: don't depend on machine CPU number
191
191
help , err := helpCmd .Output ()
192
192
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 )
194
194
}
195
195
196
196
helpLines := bytes .Split (help , []byte ("\n " ))
@@ -202,7 +202,7 @@ func buildTemplateContext() (map[string]string, error) {
202
202
203
203
latestVersion , err := getLatestVersion ()
204
204
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 )
206
206
}
207
207
208
208
return map [string ]string {
0 commit comments