@@ -98,7 +98,7 @@ func launchSelfLater() {
9898}
9999
100100func 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' .
102102 runtime .LockOSThread ()
103103
104104 // Parse regular flags
@@ -131,11 +131,7 @@ func main() {
131131 // If the executable is temporary, copy it to the full path, then restart
132132 if strings .Contains (path , "-temp" ) {
133133 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 )
139135 if err != nil {
140136 panic (err )
141137 }
@@ -149,11 +145,7 @@ func main() {
149145 } else {
150146 path = path + "-temp"
151147 }
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 )
157149 if err != nil {
158150 panic (err )
159151 }
@@ -162,6 +154,18 @@ func main() {
162154 Systray .Start ()
163155}
164156
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+
165169func loop () {
166170 if * hibernate {
167171 return
0 commit comments