@@ -28,18 +28,18 @@ var library string
2828var retry int
2929var timeout int
3030var chunkSize int
31- var noSql bool
31+ var noSQL bool
3232var noRedirect bool
3333var dest string
34- var destSql string
34+ var destSQL string
3535var configPath string
3636var verbose bool
3737var ranges bool
3838
3939var reNumbers * regexp.Regexp
4040var reMerge * regexp.Regexp
4141var lastBook int
42- var proxyUrl * url.URL
42+ var proxyURL * url.URL
4343
4444// LastGitCommit is used during build to inject git sha
4545var LastGitCommit string
@@ -53,12 +53,12 @@ func init() {
5353 flag .IntVar (& retry , "retry" , 3 , "number of re-tries" )
5454 flag .IntVar (& timeout , "timeout" , 20 , "communication timeout in seconds" )
5555 flag .IntVar (& chunkSize , "chunksize" , 10 , "Size of the chunk (megabytes) to be received in timeout time" )
56- flag .BoolVar (& noSql , "nosql" , false , "do not download database" )
56+ flag .BoolVar (& noSQL , "nosql" , false , "do not download database" )
5757 flag .BoolVar (& noRedirect , "sticky" , false , "(hack) ignore http redirects, stick with original host address" )
5858 flag .BoolVar (& verbose , "verbose" , false , "print detailed information" )
5959 flag .BoolVar (& ranges , "continue" , false , "continue getting a partially-downloaded file (until retry limit is reached)" )
6060 flag .StringVar (& dest , "to" , pwd , "destination directory for archives" )
61- flag .StringVar (& destSql , "tosql" , emptyString , "destination directory for database files" )
61+ flag .StringVar (& destSQL , "tosql" , emptyString , "destination directory for database files" )
6262 flag .StringVar (& configPath , "config" , filepath .Join (pwd , "libget2.conf" ), "configuration file" )
6363 if reNumbers , err = regexp .Compile ("(?i)\\ s*([0-9]+)-([0-9]+).zip" ); err != nil {
6464 log .Fatal (err )
@@ -113,7 +113,7 @@ func getLastBook(path string) (int, error) {
113113
114114func httpReq (hostAddr , verb string , start int64 ) (* http.Response , * time.Timer , error ) {
115115
116- hostUrl , err := url .Parse (hostAddr )
116+ hostURL , err := url .Parse (hostAddr )
117117 if err != nil {
118118 return nil , nil , errors .Wrap (err , "httpReq" )
119119 }
@@ -124,13 +124,13 @@ func httpReq(hostAddr, verb string, start int64) (*http.Response, *time.Timer, e
124124 return errors .New ("httpReq: stopped after 10 redirects" )
125125 }
126126 if verbose {
127- fmt .Printf ("Detected redirect from \" %s\" to \" %s\" " , hostUrl .Host , req .URL .Host )
127+ fmt .Printf ("Detected redirect from \" %s\" to \" %s\" " , hostURL .Host , req .URL .Host )
128128 }
129129 if noRedirect {
130130 if verbose {
131131 fmt .Printf ("\t ...Ignoring" )
132132 }
133- req .URL .Host = hostUrl .Host
133+ req .URL .Host = hostURL .Host
134134 }
135135 if verbose {
136136 fmt .Println ()
@@ -140,23 +140,23 @@ func httpReq(hostAddr, verb string, start int64) (*http.Response, *time.Timer, e
140140
141141 var transport * http.Transport
142142
143- if proxyUrl != nil {
144- switch proxyUrl .Scheme {
143+ if proxyURL != nil {
144+ switch proxyURL .Scheme {
145145 case "socks5" :
146146 var a * proxy.Auth
147- if proxyUrl .User != nil && len (proxyUrl .User .Username ()) > 0 {
148- p , _ := proxyUrl .User .Password ()
149- a = & proxy.Auth {User : proxyUrl .User .Username (), Password : p }
147+ if proxyURL .User != nil && len (proxyURL .User .Username ()) > 0 {
148+ p , _ := proxyURL .User .Password ()
149+ a = & proxy.Auth {User : proxyURL .User .Username (), Password : p }
150150 }
151- p , err := proxy .SOCKS5 ("tcp4" , proxyUrl .Host , a , proxy .Direct )
151+ p , err := proxy .SOCKS5 ("tcp4" , proxyURL .Host , a , proxy .Direct )
152152 if err != nil {
153153 return nil , nil , errors .Wrap (err , "httpReq" )
154154 }
155155 transport = & http.Transport {Dial : p .Dial , DisableKeepAlives : true }
156156 case "http" :
157157 transport = & http.Transport {DisableKeepAlives : true }
158158 default :
159- return nil , nil , errors .New ("httpReq: Unsupported proxy scheme: " + proxyUrl .Scheme )
159+ return nil , nil , errors .New ("httpReq: Unsupported proxy scheme: " + proxyURL .Scheme )
160160 }
161161 } else {
162162 transport = & http.Transport {DisableKeepAlives : true }
@@ -264,7 +264,7 @@ func getLinks(url, pattern string) ([]string, error) {
264264 return links , err
265265}
266266
267- func getSqlLinks (url , pattern string ) ([]string , error ) {
267+ func getSQLLinks (url , pattern string ) ([]string , error ) {
268268
269269 var err error
270270 var links []string
@@ -285,7 +285,7 @@ func getSqlLinks(url, pattern string) ([]string, error) {
285285
286286 var re * regexp.Regexp
287287 if re , err = regexp .Compile (pattern ); err != nil {
288- return nil , errors .Wrap (err , "getSqlLinks " )
288+ return nil , errors .Wrap (err , "getSQLLinks " )
289289 }
290290
291291 if m := re .FindAllStringSubmatch (body , - 1 ); m != nil {
@@ -294,7 +294,7 @@ func getSqlLinks(url, pattern string) ([]string, error) {
294294 links [ni ] = v [1 ]
295295 }
296296 } else {
297- err = errors .New ("getSqlLinks : No sutable links found for SQL tables" )
297+ err = errors .New ("getSQLLinks : No sutable links found for SQL tables" )
298298 }
299299
300300 return links , err
@@ -393,15 +393,15 @@ func getFiles(files []string, url, dest string) error {
393393
394394 var start int64
395395 var tmp string
396- var with_ranges bool
396+ var withRanges bool
397397
398398 for ni := 1 ; ni <= retry ; ni ++ {
399399 if ranges && start > 0 {
400400 for nj := 1 ; nj <= retry ; nj ++ {
401- with_ranges , err = acceptsRanges (joinUrl (url , f ))
401+ withRanges , err = acceptsRanges (joinUrl (url , f ))
402402 if err == nil {
403403 if verbose {
404- if with_ranges {
404+ if withRanges {
405405 fmt .Print (" ...Server supports ranges" )
406406 } else {
407407 fmt .Print (" ...Server does not support ranges" )
@@ -411,7 +411,7 @@ func getFiles(files []string, url, dest string) error {
411411 }
412412 }
413413 }
414- if ! with_ranges {
414+ if ! withRanges {
415415 start = 0
416416 }
417417 fmt .Printf ("\n Downloading file %-35.35s (%-3d:%012d) " , f , ni , start )
@@ -470,10 +470,10 @@ func main() {
470470 if dest , err = filepath .Abs (dest ); err != nil {
471471 log .Fatal (err )
472472 }
473- if len (destSql ) == 0 {
474- destSql = libName + "_" + time .Now ().UTC ().Format ("20060102_150405" )
473+ if len (destSQL ) == 0 {
474+ destSQL = libName + "_" + time .Now ().UTC ().Format ("20060102_150405" )
475475 }
476- if destSql , err = filepath .Abs (destSql ); err != nil {
476+ if destSQL , err = filepath .Abs (destSQL ); err != nil {
477477 log .Fatal (err )
478478 }
479479
@@ -485,12 +485,12 @@ func main() {
485485 }
486486
487487 if len (lib .Proxy ) > 0 {
488- if proxyUrl , err = url .Parse (lib .Proxy ); err != nil {
488+ if proxyURL , err = url .Parse (lib .Proxy ); err != nil {
489489 log .Fatal (err )
490490 }
491491 if verbose {
492492 // Hide user:password if any
493- u := & url.URL {Scheme : proxyUrl .Scheme , Host : proxyUrl .Host }
493+ u := & url.URL {Scheme : proxyURL .Scheme , Host : proxyURL .Host }
494494 fmt .Printf ("Using proxy: \" %s\" \n " , u .String ())
495495 }
496496 }
@@ -515,18 +515,18 @@ func main() {
515515 } else {
516516 fmt .Printf ("\n Processed no new archive(s)\n " )
517517 }
518- if noSql {
518+ if noSQL {
519519 fmt .Println ("\n Done..." )
520520 os .Exit (code )
521521 }
522522
523- if links , err = getSqlLinks (lib .UrlSQL , lib .PatternSQL ); err != nil {
523+ if links , err = getSQLLinks (lib .UrlSQL , lib .PatternSQL ); err != nil {
524524 log .Fatal (err )
525525 }
526- if err = os .MkdirAll (destSql , 0777 ); err != nil {
526+ if err = os .MkdirAll (destSQL , 0777 ); err != nil {
527527 log .Fatal (err )
528528 }
529- if err = getFiles (links , lib .UrlSQL , destSql ); err != nil {
529+ if err = getFiles (links , lib .UrlSQL , destSQL ); err != nil {
530530 log .Fatal (err )
531531 }
532532 if len (links ) > 0 {
0 commit comments