52
52
requiredToolsAPILevel = "v1"
53
53
)
54
54
55
+ // the important folders of the agent
56
+ var (
57
+ src , _ = os .Executable ()
58
+ srcPath = paths .New (src ) // The path of the agent's binary
59
+ srcDir = srcPath .Parent () // The directory of the agent's binary
60
+ usr , _ = user .Current ()
61
+ usrDir = paths .New (usr .HomeDir ) // The user folder, on linux/macos /home/<usr>/
62
+ agentDir = usrDir .Join (".arduino-create" )
63
+ )
64
+
55
65
// regular flags
56
66
var (
57
67
hibernate = flag .Bool ("hibernate" , false , "start hibernated" )
@@ -149,15 +159,10 @@ func main() {
149
159
AdditionalConfig : * additionalConfig ,
150
160
}
151
161
152
- path , err := os .Executable ()
153
- if err != nil {
154
- panic (err )
155
- }
156
-
157
162
// If the executable is temporary, copy it to the full path, then restart
158
- if strings .Contains (path , "-temp" ) {
159
- newPath := updater .BinPath (path )
160
- err := copyExe (path , newPath )
163
+ if strings .Contains (srcPath . String () , "-temp" ) {
164
+ newPath := updater .BinPath (srcPath . String () )
165
+ err := copyExe (srcPath . String () , newPath )
161
166
if err != nil {
162
167
log .Println ("Copy error: " , err )
163
168
panic (err )
@@ -166,7 +171,7 @@ func main() {
166
171
Systray .Update (newPath )
167
172
} else {
168
173
// Otherwise copy to a path with -temp suffix
169
- err := copyExe (path , updater .TempPath (path ))
174
+ err := copyExe (srcPath . String () , updater .TempPath (srcPath . String () ))
170
175
if err != nil {
171
176
panic (err )
172
177
}
@@ -196,14 +201,6 @@ func loop() {
196
201
log .SetLevel (log .InfoLevel )
197
202
log .SetOutput (os .Stdout )
198
203
199
- // the important folders of the agent
200
- src , _ := os .Executable ()
201
- srcPath := paths .New (src ) // The path of the agent's binary
202
- srcDir := srcPath .Parent () // The directory of the agent's binary
203
- usr , _ := user .Current ()
204
- usrDir := paths .New (usr .HomeDir ) // The user folder, on linux/macos /home/<usr>/
205
- agentDir := usrDir .Join (".arduino-create" )
206
-
207
204
// Instantiate Tools
208
205
Tools = tools.Tools {
209
206
Directory : agentDir .String (),
0 commit comments