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
+5.8k PageSpeed : Clear or flush cache on web server
+5.9k Golang : Debug with Godebug
+7.9k Golang : Configure Apache and NGINX to access your Go service example
+20.8k Golang : Sort and reverse sort a slice of strings
+10.1k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+7.2k Golang : Dealing with struct's private part
+15.2k Golang : How to convert(cast) IP address to string?
+10.5k Golang : Get UDP client IP address and differentiate clients by port number
+7.3k Golang : Convert(cast) io.Reader type to string
+11.5k Golang : convert(cast) float to string
+10.5k Golang : Removes punctuation or defined delimiter from the user's input