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
+13.8k Golang : Get user input until a command or receive a word to stop
+4.4k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+11.8k Golang : Simple file scaning and remove virus example
+16.1k Golang : How to login and logout with JWT example
+6.6k PHP : Shuffle to display different content or advertisement
+7.7k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+17.8k Golang : [json: cannot unmarshal object into Go value of type]
+5.9k Get website traffic ranking with Similar Web or Alexa
+6.2k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+8.3k Golang : Reverse text lines or flip line order example
+8.1k Golang : Ways to recover memory during run time.