@@ -31,7 +31,6 @@ const (
31
31
func startCmd (config * Config ) {
32
32
dir , err := os .Getwd ()
33
33
if err != nil {
34
- log .Println (err )
35
34
config .logToTextarea (err .Error ())
36
35
return
37
36
}
@@ -41,10 +40,11 @@ func startCmd(config *Config) {
41
40
binPath := ""
42
41
if binPath , err = getBinPath (dir ); err != nil {
43
42
log .Println ("get local binary file failed, " , err )
43
+ config .logToTextarea ("try to download from github.com" )
44
44
45
45
binPath , err = download (config )
46
46
if err != nil {
47
- log . Println (err )
47
+ config . logToTextarea (err . Error () )
48
48
return
49
49
}
50
50
}
@@ -115,7 +115,7 @@ func runCmd(bin string, config *Config) {
115
115
}
116
116
117
117
func download (config * Config ) (string , error ) {
118
- log . Println ("[fetch] fetching latest binary..." )
118
+ config . logToTextarea ("[fetch] fetching latest binary..." )
119
119
resp , err := http .Get (latestReleaseUrl )
120
120
if err != nil {
121
121
return "" , err
@@ -136,7 +136,9 @@ func download(config *Config) (string, error) {
136
136
break
137
137
}
138
138
}
139
- log .Printf ("[fetch] got latest version %s" , result .TagName )
139
+
140
+ config .logToTextarea ("[fetch] got latest version " + result .TagName )
141
+
140
142
r , err := http .Get (obj .BrowserDownloadURL )
141
143
if err != nil {
142
144
return "" , err
@@ -157,14 +159,15 @@ func download(config *Config) (string, error) {
157
159
if _ , err = io .Copy (out , r .Body ); err != nil {
158
160
return "" , err
159
161
}
160
- log . Printf ("[fetch] downloaded: %s" , obj .Name )
162
+ config . logToTextarea ("[fetch] downloaded: " + obj .Name )
161
163
162
164
file , err := os .Open (p )
163
165
if err != nil {
164
166
return "" , err
165
167
}
166
168
167
- log .Printf ("[fetch] prepare to decompress %s" , obj .Name )
169
+ config .logToTextarea ("[fetch] prepare to decompress " + obj .Name )
170
+
168
171
p , err = extractTar (file , config )
169
172
defer file .Close ()
170
173
if err != nil {
@@ -177,7 +180,7 @@ func download(config *Config) (string, error) {
177
180
}
178
181
}
179
182
180
- log . Printf ("[fetch] decompressed" )
183
+ config . logToTextarea ("[fetch] decompressed" )
181
184
return p , nil
182
185
}
183
186
0 commit comments