R
R
Roman Rakzin2016-01-04 13:03:25
go
Roman Rakzin, 2016-01-04 13:03:25

How to escape special characters in golang?

I have a string
{"function":"TrainingQuestionInfo","values":{"Question":"text with special characters / \ etc."}}
I need to escape them.
How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
uvelichitel, 2016-01-04
@uvelichitel

https://golang.org/ref/spec#String_literals In 'single quotes' characters are interpreted in 'double quotes' the string is not interpreted.

O
OlegFX, 2016-01-05
@OlegFX

https://golang.org/pkg/strconv/#Quote
"{\"function\":\"TrainingQuestionInfo\",\"values\":{\"Question\":\"text with special characters / \\ etc.\"}}"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question