chatGPT答: |
8v6.cn |
00:46:36 go: downloading gopkg.in/yaml.v2 v2.2.2
00:46:36 go: found gopkg.in/yaml.v2 v2.2.2 in gopkg.in/yaml.v2 v2.2.2
00:46:36 go: downloading github.com/go-sql-driver/mysql v1.4.1
00:46:37 go: found github.com/go-sql-driver/mysql v1.4.1 in github.com/go-sql-driver/mysql v1.4.1
00:46:37 go: downloading github.com/Microsoft/go-winio v0.6.0
00:46:38 go: found github.com/Microsoft/go-winio v0.6.0 in github.com/Microsoft/go-winio v0.6.0
`
endTime := time.Now()
startTime := endTime.Add(-2 * time.Minute)
regex := regexp.MustCompile(`^(?P<time>\d\d:\d\d:\d\d)\sgo:\s+downloading\s(?P<package>.*)\sv(?P<version>.*)$`)
captures := regexHeaders(logs, regex, startTime, endTime)
if len(captures) != 3 {
t.Errorf("Expected 3 headers, got %d", len(captures))
}
if captures[0]["package"] != "gopkg.in/yaml.v2" {
t.Errorf("Incorrect package for first capture, got %s", captures[0]["package"])
}
if captures[0]["version"] != "v2.2.2" {
t.Errorf("Incorrect version for first capture, got %s", captures[0]["version"])
}
if captures[1]["package"] != "github.com/go-sql-driver/mysql" {
t.Errorf("Incorrect package for second capture, got %s", captures[1]["package"])
}
if captures[1]["version"] != "v1.4.1" {
t.Errorf("Incorrect version for second capture, got %s", captures[1]["version"])
}
if captures[2]["package"] != "github.com/Microsoft/go-winio" {
t.Errorf("Incorrect package for third capture, got %s", captures[2]["package"])
}
if captures[2]["version"] != "v0.6.0" {
t.Errorf("Incorrect version for third capture, got %s", captures[2]["version"])
}
}
|