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
+4.4k Golang : Issue HTTP commands to server and port example
+8.7k Golang : Turn string or text file into slice example
+7k Golang : Gomobile init produce "iphoneos" cannot be located error
+11.4k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+27.9k Golang : Get first few and last few characters from string
+7.5k Golang : Count leading or ending zeros(any item of interest) example
+8k Golang : Find the length of big.Int variable example
+8.8k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+8.9k Golang : Check a web page existence with HEAD request example
+8.5k Golang : Qt get screen resolution and display on center example
+6k Golang : How to call function inside template with template.FuncMap