Make regexp global static
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Sarah Jamie Lewis 2022-04-19 16:42:23 -07:00
parent 8d0ed17e7f
commit cc924a476e
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])