From cc924a476ec194fb081dacd9d25950b3aae765c1 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 19 Apr 2022 16:42:23 -0700 Subject: [PATCH] Make regexp global static --- tor/torProvider.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tor/torProvider.go b/tor/torProvider.go index 4792219..35dbc24 100644 --- a/tor/torProvider.go +++ b/tor/torProvider.go @@ -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])