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
+6.3k Golang : How to determine if request or crawl is from Google robots
+12.5k Swift : Convert (cast) Int or int32 value to CGFloat
+18.1k Golang : Read binary file into memory
+9.7k Golang : Convert octal value to string to deal with leading zero problem
+16.6k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+5.9k Golang : Debug with Godebug
+19.9k Swift : Convert (cast) Int to int32 or Uint32
+8.6k Golang : Gorilla web tool kit schema example
+5.5k Unix/Linux/MacOSx : Get local IP address
+47.3k Golang : Convert int to byte array([]byte)
+5.5k Swift : Get substring with rangeOfString() function example
+8.2k Golang : How to check variable or object type during runtime?