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
+11k Golang : Removes punctuation or defined delimiter from the user's input
+13.2k Golang : Convert(cast) uintptr to string example
+11.3k CodeIgniter : How to check if a session exist in PHP?
+16.8k Golang : Get own process identifier
+6.2k Golang : Grab news article text and use NLP to get each paragraph's sentences
+13.9k Golang : Gin framework accept query string by post request example
+41.5k Golang : Convert string to array/slice
+15.3k Golang : Get timezone offset from date or timestamp
+19.4k Golang : Display list of time zones with GMT
+14.2k Golang : syscall.Socket example
+23k Golang : Gorilla mux routing example