Is there a way to avoid single quotes in go?
Following:
str := "I'm Bob, and I'm 25." str = strings.Replace(str, "'", "\'", -1)
Gives an error: unknown escape sequence: '
I would like str to be
"I\'m Bob, and I\'m 25."
You also need to avoid the slash in the lines. Come on in.
str := "I'm Bob, and I'm 25." str = strings.Replace(str, "'", "\\'", -1)
https://play.golang.org/p/mZaaNU3FHw
+ to @KeylorSanchez answer: you can wrap string replacement in reverse tick:
strings.Replace(str, "'", `\'`, -1)
Source: https://habr.com/ru/post/1611942/More articles:Reduce the collection of lists in one statement - pythonкак я могу выбрать только последний элемент span в div? он не должен выбирать, если только один диапазон в div - javascriptWhy doesn't Cors work after upgrading to beta8 on ASP.NET 5? - c #Assembly * uses *, which has a higher version than the assembly reference - .netRegular expression to filter desired rows from pandas dataframe - pythonLiferay: Create a portlet configuration page. How to provide the correct jsp path? - spring-portlet-mvcAndroid Realm, request objects by attribute child - javaWhat is the post_name field in wp_posts in wordpress? - wordpressСгенерируйте с помощью свойства gulp -spritesmith правила: hover вместо селектора классов - javascriptjobserver is not available when creating external projects using CMake - c ++All Articles