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
+12.5k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+24.2k Golang : Upload to S3 with official aws-sdk-go package
+6.3k Golang : Get missing location after unmarshal binary and gob decode time.
+14.1k Golang : concatenate(combine) strings
+26.6k Golang : Convert(cast) string to uint8 type and back to string
+5.8k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+28.2k Golang : Move file to another directory
+5.2k Golang : Display packages names during compilation
+4.8k Javascript : Access JSON data example
+27.9k PHP : Count number of JSON items/objects
+14.5k Golang : How to shuffle elements in array or slice?
+5k HTTP common errors and their meaning explained