Skip to content

Commit 7d449df

Browse files
committed
Removed dep on pkg/errors library
1 parent d410c2a commit 7d449df

File tree

31 files changed

+144
-189
lines changed

31 files changed

+144
-189
lines changed

.licenses/go/github.com/arduino/go-paths-helper.dep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: github.com/arduino/go-paths-helper
3-
version: v1.10.0
3+
version: v1.10.1
44
type: go
55
summary:
66
homepage: https://pkg.go.dev/github.com/arduino/go-paths-helper

.licenses/go/github.com/pkg/errors.dep.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

commands/board/list.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package board
1818
import (
1919
"context"
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"io"
2324
"net/http"
@@ -35,7 +36,6 @@ import (
3536
"github.com/arduino/arduino-cli/internal/inventory"
3637
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3738
"github.com/arduino/go-properties-orderedmap"
38-
"github.com/pkg/errors"
3939
"github.com/sirupsen/logrus"
4040
)
4141

@@ -73,10 +73,10 @@ func cachedAPIByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
7373
func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
7474
// ensure vid and pid are valid before hitting the API
7575
if !validVidPid.MatchString(vid) {
76-
return nil, errors.Errorf(tr("Invalid vid value: '%s'"), vid)
76+
return nil, errors.New(tr("Invalid vid value: '%s'", vid))
7777
}
7878
if !validVidPid.MatchString(pid) {
79-
return nil, errors.Errorf(tr("Invalid pid value: '%s'"), pid)
79+
return nil, errors.New(tr("Invalid pid value: '%s'", pid))
8080
}
8181

8282
url := fmt.Sprintf("%s/%s/%s", vidPidURL, vid, pid)
@@ -88,19 +88,19 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
8888
httpClient, err := httpclient.New()
8989

9090
if err != nil {
91-
return nil, errors.Wrap(err, tr("failed to initialize http client"))
91+
return nil, fmt.Errorf("%s: %w", tr("failed to initialize http client"), err)
9292
}
9393

9494
res, err := httpClient.Do(req)
9595
if err != nil {
96-
return nil, errors.Wrap(err, tr("error querying Arduino Cloud Api"))
96+
return nil, fmt.Errorf("%s: %w", tr("error querying Arduino Cloud Api"), err)
9797
}
9898
if res.StatusCode == 404 {
9999
// This is not an error, it just means that the board is not recognized
100100
return nil, nil
101101
}
102102
if res.StatusCode >= 400 {
103-
return nil, errors.Errorf(tr("the server responded with status %s"), res.Status)
103+
return nil, errors.New(tr("the server responded with status %s", res.Status))
104104
}
105105

106106
resp, err := io.ReadAll(res.Body)
@@ -113,7 +113,7 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
113113

114114
var dat map[string]interface{}
115115
if err := json.Unmarshal(resp, &dat); err != nil {
116-
return nil, errors.Wrap(err, tr("error processing response from server"))
116+
return nil, fmt.Errorf("%s: %w", tr("error processing response from server"), err)
117117
}
118118
name, nameFound := dat["name"].(string)
119119
fqbn, fbqnFound := dat["fqbn"].(string)

commands/daemon/debug.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ package daemon
1717

1818
import (
1919
"context"
20+
"errors"
2021
"os"
2122

2223
cmd "github.com/arduino/arduino-cli/commands/debug"
2324
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
24-
"github.com/pkg/errors"
2525
)
2626

2727
// Debug returns a stream response that can be used to fetch data from the
@@ -37,7 +37,7 @@ func (s *ArduinoCoreServerImpl) Debug(stream rpc.ArduinoCoreService_DebugServer)
3737
// Ensure it's a config message and not data
3838
req := msg.GetDebugRequest()
3939
if req == nil {
40-
return errors.Errorf(tr("First message must contain debug request, not data"))
40+
return errors.New(tr("First message must contain debug request, not data"))
4141
}
4242

4343
// Launch debug recipe attaching stdin and out to grpc streaming

commands/upload/upload.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package upload
1717

1818
import (
1919
"context"
20+
"errors"
2021
"fmt"
2122
"io"
2223
"path/filepath"
@@ -36,7 +37,6 @@ import (
3637
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3738
paths "github.com/arduino/go-paths-helper"
3839
properties "github.com/arduino/go-properties-orderedmap"
39-
"github.com/pkg/errors"
4040
"github.com/sirupsen/logrus"
4141
)
4242

@@ -711,14 +711,14 @@ func determineBuildPathAndSketchName(importFile, importDir string, sk *sketch.Sk
711711
buildPath := paths.New(importDir)
712712
sketchName, err := detectSketchNameFromBuildPath(buildPath)
713713
if err != nil {
714-
return nil, "", errors.Errorf(tr("autodetect build artifact: %s"), err)
714+
return nil, "", fmt.Errorf("%s: %w", tr("looking for build artifacts"), err)
715715
}
716716
return buildPath, sketchName, nil
717717
}
718718

719719
// Case 3: nothing given...
720720
if sk == nil {
721-
return nil, "", fmt.Errorf(tr("no sketch or build directory/file specified"))
721+
return nil, "", errors.New(tr("no sketch or build directory/file specified"))
722722
}
723723

724724
// Case 4: only sketch specified. In this case we use the generated build path
@@ -763,7 +763,7 @@ func detectSketchNameFromBuildPath(buildPath *paths.Path) (string, error) {
763763
}
764764

765765
if candidateName != name {
766-
return "", errors.Errorf(tr("multiple build artifacts found: '%[1]s' and '%[2]s'"), candidateFile, file)
766+
return "", errors.New(tr("multiple build artifacts found: '%[1]s' and '%[2]s'", candidateFile, file))
767767
}
768768
}
769769

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1
77

88
require (
99
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371
10-
github.com/arduino/go-paths-helper v1.10.0
10+
github.com/arduino/go-paths-helper v1.10.1
1111
github.com/arduino/go-properties-orderedmap v1.8.0
1212
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
1313
github.com/arduino/go-win32-utils v1.0.0
@@ -25,7 +25,6 @@ require (
2525
github.com/marcinbor85/gohex v0.0.0-20210308104911-55fb1c624d84
2626
github.com/mattn/go-colorable v0.1.13
2727
github.com/mattn/go-isatty v0.0.20
28-
github.com/pkg/errors v0.9.1
2928
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
3029
github.com/rogpeppe/go-internal v1.11.0
3130
github.com/schollz/closestmatch v2.1.0+incompatible

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ
5151
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
5252
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
5353
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
54-
github.com/arduino/go-paths-helper v1.10.0 h1:oeE6Mcl4lsz+knC3lzaCWkRQa3n3FbwdRSeGhy6uGbM=
55-
github.com/arduino/go-paths-helper v1.10.0/go.mod h1:LgEVnv+cqSl05vXD5LaUZGquDsX5OKmPNDJtjTL8928=
54+
github.com/arduino/go-paths-helper v1.10.1 h1:j8InnhLrSeoPiOvTnZL0XMFt7l407ciTBJJJs7W9bs4=
55+
github.com/arduino/go-paths-helper v1.10.1/go.mod h1:jcpW4wr0u69GlXhTYydsdsqAjLaYK5n7oWHfKqOG6LM=
5656
github.com/arduino/go-properties-orderedmap v1.8.0 h1:wEfa6hHdpezrVOh787OmClsf/Kd8qB+zE3P2Xbrn0CQ=
5757
github.com/arduino/go-properties-orderedmap v1.8.0/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
5858
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=

internal/arduino/builder/archive_compiled_files.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package builder
1717

1818
import (
1919
"github.com/arduino/go-paths-helper"
20-
"github.com/pkg/errors"
2120
)
2221

2322
// ArchiveCompiledFiles fixdoc
@@ -45,7 +44,7 @@ func (b *Builder) archiveCompiledFiles(buildPath *paths.Path, archiveFile *paths
4544
// something changed, rebuild the core archive
4645
if rebuildArchive {
4746
if err := archiveFilePath.Remove(); err != nil {
48-
return nil, errors.WithStack(err)
47+
return nil, err
4948
}
5049
} else {
5150
if b.logger.Verbose() {
@@ -63,11 +62,11 @@ func (b *Builder) archiveCompiledFiles(buildPath *paths.Path, archiveFile *paths
6362

6463
command, err := b.prepareCommandForRecipe(properties, "recipe.ar.pattern", false)
6564
if err != nil {
66-
return nil, errors.WithStack(err)
65+
return nil, err
6766
}
6867

6968
if err := b.execCommand(command); err != nil {
70-
return nil, errors.WithStack(err)
69+
return nil, err
7170
}
7271
}
7372

internal/arduino/builder/build_options_manager.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package builder
1717

1818
import (
1919
"encoding/json"
20+
"fmt"
2021
"path/filepath"
2122
"strings"
2223

@@ -25,7 +26,6 @@ import (
2526
"github.com/arduino/arduino-cli/internal/arduino/sketch"
2627
"github.com/arduino/go-paths-helper"
2728
properties "github.com/arduino/go-properties-orderedmap"
28-
"github.com/pkg/errors"
2929
)
3030

3131
// buildOptions fixdoc
@@ -100,7 +100,7 @@ func newBuildOptions(
100100
func (b *Builder) createBuildOptionsJSON() error {
101101
buildOptionsJSON, err := json.MarshalIndent(b.buildOptions.currentOptions, "", " ")
102102
if err != nil {
103-
return errors.WithStack(err)
103+
return err
104104
}
105105
return b.buildOptions.buildPath.Join("build.options.json").WriteFile(buildOptionsJSON)
106106
}
@@ -110,10 +110,10 @@ func (b *Builder) wipeBuildPath() error {
110110
// control when this should be printed.
111111
// logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED + constants.MSG_REBUILD_ALL)
112112
if err := b.buildOptions.buildPath.RemoveAll(); err != nil {
113-
return errors.WithMessage(err, tr("cleaning build path"))
113+
return fmt.Errorf("%s: %w", tr("cleaning build path"), err)
114114
}
115115
if err := b.buildOptions.buildPath.MkdirAll(); err != nil {
116-
return errors.WithMessage(err, tr("cleaning build path"))
116+
return fmt.Errorf("%s: %w", tr("cleaning build path"), err)
117117
}
118118
return nil
119119
}
@@ -125,11 +125,11 @@ func (b *Builder) wipeBuildPathIfBuildOptionsChanged() error {
125125

126126
// Load previous build options map
127127
var buildOptionsJSONPrevious []byte
128-
var _err error
129128
if buildOptionsFile := b.buildOptions.buildPath.Join("build.options.json"); buildOptionsFile.Exist() {
130-
buildOptionsJSONPrevious, _err = buildOptionsFile.ReadFile()
131-
if _err != nil {
132-
return errors.WithStack(_err)
129+
var err error
130+
buildOptionsJSONPrevious, err = buildOptionsFile.ReadFile()
131+
if err != nil {
132+
return err
133133
}
134134
}
135135

internal/arduino/builder/compilation.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/utils"
2626
"github.com/arduino/arduino-cli/internal/arduino/globals"
2727
"github.com/arduino/go-paths-helper"
28-
"github.com/pkg/errors"
2928
)
3029

3130
func (b *Builder) compileFiles(
@@ -104,7 +103,7 @@ func (b *Builder) compileFiles(
104103
wg.Wait()
105104
if len(errorsList) > 0 {
106105
// output the first error
107-
return nil, errors.WithStack(errorsList[0])
106+
return nil, errorsList[0]
108107
}
109108
objectFiles.Sort()
110109
return objectFiles, nil
@@ -124,25 +123,25 @@ func (b *Builder) compileFileWithRecipe(
124123
properties.SetPath("source_file", source)
125124
relativeSource, err := sourcePath.RelTo(source)
126125
if err != nil {
127-
return nil, errors.WithStack(err)
126+
return nil, err
128127
}
129128
depsFile := buildPath.Join(relativeSource.String() + ".d")
130129
objectFile := buildPath.Join(relativeSource.String() + ".o")
131130

132131
properties.SetPath("object_file", objectFile)
133132
err = objectFile.Parent().MkdirAll()
134133
if err != nil {
135-
return nil, errors.WithStack(err)
134+
return nil, err
136135
}
137136

138137
objIsUpToDate, err := utils.ObjFileIsUpToDate(source, objectFile, depsFile)
139138
if err != nil {
140-
return nil, errors.WithStack(err)
139+
return nil, err
141140
}
142141

143142
command, err := b.prepareCommandForRecipe(properties, recipe, false)
144143
if err != nil {
145-
return nil, errors.WithStack(err)
144+
return nil, err
146145
}
147146
if b.compilationDatabase != nil {
148147
b.compilationDatabase.Add(source, command)
@@ -174,7 +173,7 @@ func (b *Builder) compileFileWithRecipe(
174173

175174
// ...and then return the error
176175
if err != nil {
177-
return nil, errors.WithStack(err)
176+
return nil, err
178177
}
179178
} else if b.logger.Verbose() {
180179
if objIsUpToDate {

0 commit comments

Comments
 (0)