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
+18.1k Golang : Defer function inside init()
+9.4k Golang : How to get ECDSA curve and parameters data?
+14.5k Golang : How to filter a map's elements for faster lookup
+11.7k Golang : Surveillance with web camera and OpenCV
+25.8k Golang : How to write CSV data to file
+14k Golang : unknown escape sequence error
+5.5k Golang : Return multiple values from function
+18.2k Golang : How to log each HTTP request to your web server?
+5.3k Golang : The Tao of importing package
+23.9k Find and replace a character in a string in Go
+11k Golang : How to transmit update file to client by HTTP request example