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
+3.5k Fix Google Analytics Redundant Hostnames problem
+10.2k Golang : Convert IPv4 address to packed 32-bit binary format
+11.7k Golang : package is not in GOROOT during compilation
+19k Golang : Join arrays or slices example
+7.1k Golang : Play .WAV file from command line
+15k Golang : Find IP address from string
+4.1k Linux : Disable and enable IPv4 forwarding
+6k Golang : Error reading timestamp with GORM or SQL driver
+2.7k Detect if Google Analytics and Developer Media are loaded properly or not
+9.4k Golang : Simple client-server HMAC authentication without SSL example
+4.8k Unix/Linux : How to get own IP address ?
+10.9k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message