...
) with regexp.MustCompile to avoid having to escape twice426 scanner := bufio.NewScanner(bytes.NewBuffer(sess.Out.Contents()))
427 var match []string
428 for scanner.Scan() {
429 re := regexp.MustCompile("fly_port=(\\d+)")430 match = re.FindStringSubmatch(scanner.Text())
431 if len(match) > 0 {
432 break
Raw string literals use backticks (`) instead of quotes (") and thus, do not support any escape sequences. This means that the backslash (\) can be used freely, without escaping.
Since regular expressions have their escape sequences, raw strings can improve their readability.
regexp.Compile("\\A(\\w+) profile: total \\d+\\n\\z")
regexp.Compile(`\A(\w+) profile: total \d+
\z`)