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
+19.9k Golang : How to get struct tag and use field name to retrieve data?
+62.4k Golang : Convert HTTP Response body to string
+4.5k Linux/MacOSX : How to symlink a file?
+12.3k Golang : Forwarding a local port to a remote server example
+19k Mac OSX : Homebrew and Golang
+31.2k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+5.8k Golang : Compound interest over time example
+12.4k Android Studio : Highlight ImageButton when pressed on example
+5.2k Golang : What is StructTag and how to get StructTag's value?
+8.6k Golang : Gorilla web tool kit schema example
+7.1k Golang : File system scanning
+5.4k Golang : Frobnicate or tweaking a string example