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
+27.8k Golang : Save map/struct to JSON or XML file
+11.5k Golang : How to calculate the distance between two coordinates using Haversine formula
+16.1k Golang : Multi threading or run two processes or more example
+5.1k Golang : Debug with Godebug
+15.1k Golang : Check if a string contains multiple sub-strings in []string?
+12.4k Golang : Query string with space symbol %20 in between
+6.1k Golang : Squaring elements in array
+7.6k Golang : Convert(cast) []byte to io.Reader type
+19.7k Curl usage examples with Golang
+13.6k Golang : Accurate and reliable decimal calculations
+14.4k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+22.7k Golang : Upload to S3 with official aws-sdk-go package