@@ -16,7 +16,6 @@ import (
16
16
17
17
"github.com/PuerkitoBio/goquery"
18
18
"github.com/google/go-github/v52/github"
19
- "github.com/pkg/errors"
20
19
"golang.org/x/mod/modfile"
21
20
"golang.org/x/mod/semver"
22
21
"golang.org/x/oauth2"
@@ -31,7 +30,7 @@ import (
31
30
func Run (githubToken string , limit int , test bool ) error {
32
31
f , err := mod .GetModFile ("." )
33
32
if err != nil {
34
- return errors . Wrap ( err , "could not get mod file" )
33
+ return fmt . Errorf ( "could not get mod file: %w" , err )
35
34
}
36
35
ts := oauth2 .StaticTokenSource (& oauth2.Token {AccessToken : githubToken })
37
36
tc := oauth2 .NewClient (oauth2 .NoContext , ts )
@@ -77,34 +76,34 @@ func migrate(path string, gc *github.Client, test bool) error {
77
76
fmt .Printf ("git clone %v\n " , path )
78
77
tempdir , err := os .MkdirTemp ("" , strings .Replace (path , "/" , "_" , - 1 ))
79
78
if err != nil {
80
- return errors . Wrap ( err , "tempdir err" )
79
+ return fmt . Errorf ( "tempdir err: %w" , err )
81
80
}
82
81
defer os .RemoveAll (tempdir )
83
82
red , err := deduceVanity (path )
84
83
if err != nil {
85
- return errors . Wrap ( err , "error deducing vanity" )
84
+ return fmt . Errorf ( "error deducing vanity: %w" , err )
86
85
}
87
86
dir , err := gitclone (red .gitURL , tempdir )
88
87
if err != nil {
89
- return errors . Wrap ( err , "error running git clone" )
88
+ return fmt . Errorf ( "error running git clone: %w" , err )
90
89
}
91
90
if checkMod (dir ) {
92
91
fmt .Printf ("%v already migrated to modules\n " , path )
93
92
return nil
94
93
}
95
94
err = modinit (dir , path )
96
95
if err != nil {
97
- return errors . Wrap ( err , "err running go mod init" )
96
+ return fmt . Errorf ( "err running go mod init: %w" , err )
98
97
}
99
98
fmt .Printf ("downloading dependencies for %v\n " , path )
100
99
err = getdeps (dir )
101
100
if err != nil {
102
- return errors . Wrap ( err , "err running go get ./..." )
101
+ return fmt . Errorf ( "err running go get ./...: %w" , err )
103
102
}
104
103
t := getTag (dir )
105
104
fmt .Printf ("upgrading %v to v%v\n " , path , t )
106
105
if err := major .Run (dir , "upgrade" , "" , t ); err != nil {
107
- return errors . Wrap ( err , "err upgrading import paths" )
106
+ return fmt . Errorf ( "err upgrading import paths: %w" , err )
108
107
}
109
108
110
109
err = rewriteGitIgnore (dir )
@@ -121,33 +120,33 @@ func migrate(path string, gc *github.Client, test bool) error {
121
120
owner , repo := ss [1 ], ss [2 ]
122
121
r , _ , err := gc .Repositories .CreateFork (context .Background (), owner , repo , & github.RepositoryCreateForkOptions {})
123
122
if _ , ok := err .(* github.AcceptedError ); ! ok {
124
- return errors . Wrap ( err , "error creating a fork" )
123
+ return fmt . Errorf ( "error creating a fork: %w" , err )
125
124
}
126
125
time .Sleep (time .Second * 2 )
127
126
remote := r .GetCloneURL ()
128
127
err = addRemote (dir , remote )
129
128
if err != nil {
130
- return errors . Wrap ( err , "error adding remote" )
129
+ return fmt . Errorf ( "error adding remote: %w" , err )
131
130
}
132
131
133
132
err = checkout (dir )
134
133
if err != nil {
135
- return errors . Wrap ( err , "error checking out new branch" )
134
+ return fmt . Errorf ( "error checking out new branch: %w" , err )
136
135
}
137
136
138
137
err = add (dir )
139
138
if err != nil {
140
- errors . Wrap ( err , "error tracking files" )
139
+ return fmt . Errorf ( "error tracking files: %w" , err )
141
140
}
142
141
143
142
err = commit (dir )
144
143
if err != nil {
145
- errors . Wrap ( err , "error committing changes" )
144
+ return fmt . Errorf ( "error committing changes: %w" , err )
146
145
}
147
146
148
147
err = push (dir )
149
148
if err != nil {
150
- errors . Wrap ( err , "error pushing to github" )
149
+ return fmt . Errorf ( "error pushing to github: %w" , err )
151
150
}
152
151
153
152
if test {
@@ -344,7 +343,7 @@ func rewriteGitIgnore(dir string) error {
344
343
return nil
345
344
}
346
345
if err != nil {
347
- return errors . Wrap ( err , "could not open gitignore" )
346
+ return fmt . Errorf ( "could not open gitignore: %w" , err )
348
347
}
349
348
lines := []string {}
350
349
scnr := bufio .NewScanner (f )
@@ -356,7 +355,7 @@ func rewriteGitIgnore(dir string) error {
356
355
}
357
356
if scnr .Err () != nil {
358
357
f .Close ()
359
- return errors . Wrap ( err , "error while scanning" )
358
+ return fmt . Errorf ( "error while scanning: %w" , err )
360
359
}
361
360
f .Close ()
362
361
return os .WriteFile (p , []byte (strings .Join (lines , "\n " )+ "\n " ), 0o666 )
0 commit comments