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
+3.8k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+10.7k Golang : Clean formatting/indenting or pretty print JSON result
+50.3k Golang : How to get struct field and value by name
+7.8k Golang : Get final balance from bit coin address example
+8.9k Golang : Channels and buffered channels examples
+5.5k Unix/Linux : Use netstat to find out IP addresses served by your website server
+16.7k Golang : Get command line arguments
+24.8k Golang : Convert(cast) string to uint8 type and back to string
+15k Golang : How to extract links from web page ?
+8.9k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+10.7k Golang : md5 hash of a string