@@ -98,7 +98,7 @@ func launchSelfLater() {
98
98
}
99
99
100
100
func main () {
101
- // prevents bad errors in OSX, such as [NS...] is only safe to invoke on the main thread.
101
+ // prevents bad errors in OSX, such as ' [NS...] is only safe to invoke on the main thread' .
102
102
runtime .LockOSThread ()
103
103
104
104
// Parse regular flags
@@ -131,11 +131,7 @@ func main() {
131
131
// If the executable is temporary, copy it to the full path, then restart
132
132
if strings .Contains (path , "-temp" ) {
133
133
correctPath := strings .Replace (path , "-temp" , "" , - 1 )
134
- data , err := ioutil .ReadFile (path )
135
- if err != nil {
136
- panic (err )
137
- }
138
- err = ioutil .WriteFile (correctPath , data , 0755 )
134
+ err := copyExe (path , correctPath )
139
135
if err != nil {
140
136
panic (err )
141
137
}
@@ -149,11 +145,7 @@ func main() {
149
145
} else {
150
146
path = path + "-temp"
151
147
}
152
- data , err := ioutil .ReadFile (correctPath )
153
- if err != nil {
154
- panic (err )
155
- }
156
- err = ioutil .WriteFile (path , data , 0755 )
148
+ err := copyExe (path , correctPath )
157
149
if err != nil {
158
150
panic (err )
159
151
}
@@ -162,6 +154,18 @@ func main() {
162
154
Systray .Start ()
163
155
}
164
156
157
+ func copyExe (from , to string ) error {
158
+ data , err := ioutil .ReadFile (from )
159
+ if err != nil {
160
+ return err
161
+ }
162
+ err = ioutil .WriteFile (to , data , 0755 )
163
+ if err != nil {
164
+ return err
165
+ }
166
+ return nil
167
+ }
168
+
165
169
func loop () {
166
170
if * hibernate {
167
171
return
0 commit comments