Golang : unknown escape sequence error
Encountered a funky error message unknown escape sequence while working this the tutorial on how to find IP address from a string. Apparently, Go doesn't like this statement :
regexPattern := numBlock + "\." + numBlock + "\." + numBlock + "\." + numBlock
and to fix the error, I've to escape the backslash.
regexPattern := numBlock + "\\." + numBlock + "\\." + numBlock + "\\." + numBlock
alternatively, backtick ` can be used to fix the error as well.
regexPattern := numBlock + `\.` + numBlock + `\.` + numBlock + `\.` + numBlock
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+9.9k Golang : Random Rune generator
+6.2k Golang : Calculate diameter, circumference, area, sphere surface and volume
+7.7k Findstr command the Grep equivalent for Windows
+10.7k Golang : Create S3 bucket with official aws-sdk-go package
+14k Golang : Send email with attachment(RFC2822) using Gmail API example
+6.7k Golang : How to call function inside template with template.FuncMap
+40.9k Golang : How do I convert int to uint8?
+10k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+25.9k Golang : Calculate future date with time.Add() function
+12.1k Elastic Search : Return all records (higher than default 10)
+13.6k Golang : Compress and decompress file with compress/flate example
+33.5k Golang : Create x509 certificate, private and public keys