Merge pull request 'Make regexp global static' (#30) from regexp_static into master
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details

Reviewed-on: #30
This commit is contained in:
Dan Ballard 2022-04-19 23:54:25 +00:00
commit b280f7a1fe
1 changed files with 3 additions and 2 deletions

View File

@ -163,6 +163,9 @@ func (tp *torProvider) GetInfo(onion string) (map[string]string, error) {
return nil, err
}
var progRe = regexp.MustCompile("PROGRESS=([0-9]*)")
var sumRe = regexp.MustCompile("SUMMARY=\"(.*)\"$")
// GetBootstrapStatus returns an int 0-100 on the percent the bootstrapping of the underlying network is at and an optional string message
// returns -1 on network disconnected
// returns -2 on error
@ -191,8 +194,6 @@ func (tp *torProvider) GetBootstrapStatus() (int, string) {
status := ""
if len(kvs) > 0 {
progRe := regexp.MustCompile("PROGRESS=([0-9]*)")
sumRe := regexp.MustCompile("SUMMARY=\"(.*)\"$")
if progMatches := progRe.FindStringSubmatch(kvs[0].Val); len(progMatches) > 1 {
progress, _ = strconv.Atoi(progMatches[1])