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.3k Golang : Map within a map example
+7.9k Golang : How to get username from email address
+6.3k Android Studio : How to detect camera, activate and capture example
+10.1k Golang : Find age or leap age from date of birth example
+5.3k PHP : Proper way to get UTF-8 character or string length
+7k Golang : HttpRouter multiplexer routing example
+32.3k Golang : All update packages with go get command
+10k Golang : How to pipe input data to executing child process?
+9.1k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+4.9k Golang : Launching your executable inside a console under Linux
+9.1k Golang : Convert file content to Hex
+11.3k Elastic Search : Return all records (higher than default 10)