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.7k Golang : interface - when and where to use examples
+18.8k Golang : How to make function callback or pass value from function as parameter?
+7.5k Golang : How to handle file size larger than available memory panic issue
+7k Restart Apache or Nginx web server without password prompt
+18.9k Golang : Padding data for encryption and un-padding data for decryption
+5.6k Golang : Frobnicate or tweaking a string example
+15.4k Golang : invalid character ',' looking for beginning of value
+6.7k Golang : Get expvar(export variables) to work with multiplexer
+8.6k Golang : Progress bar with ∎ character
+8.3k Your page has meta tags in the body instead of the head
+14.3k Golang : How to pass map to html template and access the map's elements
+31k Golang : Calculate percentage change of two values