英文:
line break or simplify or make long payload data line by line without error
问题
我有一个变量 payload
,这里只显示了一部分。
payload := strings.NewReader("json=%7B%22rent_content_layout%22%3A%22Original%22%2C%22start_verylargetext_enabled%22%3Afalse%2C%22auto_large_mode")
有没有办法使用 Golang 将这一行的变量数据拆分成多行或者使其更易读?在 Bash 或者 Shell 中,我们可以使用 \n
进行换行,有没有类似的技巧可以在 Golang 中实现换行?
英文:
I had a variable payload
, it is too long here just a part.
payload := strings.NewReader("json=%7B%22rent_content_layout%22%3A%22Original%22%2C%22start_verylargetext_enabled%22%3Afalse%2C%22auto_large_mode")
is any way to make the one line var data to multi line or make it human readable using golang, for bash or shell we use \n
, is any trick to line break it using golang
答案1
得分: 1
只需使用+
运算符进行字符串连接,并将字符串分解为小部分。
payload := strings.NewReader(
"json=%7B%22" +
"rent_content_layout%22%3A%22" +
"Original%22%2C%22" +
"start_verylargetext_enabled%22%3A" +
"false%2C%22auto_large_mode")
英文:
Simply do the string concatenation with the +
operator and break the string into small parts.
payload := strings.NewReader(
"json=%7B%22" +
"rent_content_layout%22%3A%22" +
"Original%22%2C%22" +
"start_verylargetext_enabled%22%3A" +
"false%2C%22auto_large_mode")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论