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
+5.8k How to let Facebook Login button redirect to a particular URL ?
+5.6k Golang : How to validate ISBN?
+28k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+12k Golang : List objects in AWS S3 bucket
+11.6k Golang : Transform comma separated string to slice example
+22.7k Golang : Upload to S3 with official aws-sdk-go package
+8.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+5k Golang : Generate multiplication table from an integer example
+9.1k Golang : Embed secret text string into binary(executable) file
+7.9k Golang : Build and compile multiple source files
+6.5k Golang : Detect sample rate, channels or latency with PortAudio
+18.3k Golang : Close channel after ticker stopped example