From cf59bd878df0eabcfbfe1c091bd5556289d7fdf7 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 12 May 2021 18:38:24 +0300 Subject: [PATCH] native: simplify escaping in regexp.MustCompile() gosimple: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice --- pkg/core/native/name_service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/native/name_service.go b/pkg/core/native/name_service.go index d39d8e3c4..b2a950699 100644 --- a/pkg/core/native/name_service.go +++ b/pkg/core/native/name_service.go @@ -64,8 +64,8 @@ const ( var ( // Lookahead is not supported by Go, but it is simple `(?=.{3,255}$)`, // so we check name length explicitly. - nameRegex = regexp.MustCompile("^([a-z0-9]{1,62}\\.)+[a-z][a-z0-9]{0,15}$") - ipv4Regex = regexp.MustCompile("^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])$") + nameRegex = regexp.MustCompile(`^([a-z0-9]{1,62}\.)+[a-z][a-z0-9]{0,15}$`) + ipv4Regex = regexp.MustCompile(`^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])$`) ipv6Regex = regexp.MustCompile("(?:^)(([0-9a-f]{1,4}:){7,7}[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,7}:|([0-9a-f]{1,4}:){1,6}:[0-9a-f]{1,4}|([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|[0-9a-f]{1,4}:((:[0-9a-f]{1,4}){1,6})|:((:[0-9a-f]{1,4}){1,7}|:))$") rootRegex = regexp.MustCompile("^[a-z][a-z0-9]{0,15}$") )