当 实际打印 时,在xml文件中打印新行

I'm trying to write a .xml file in golang and when I try to write to a newline and use , it literally prints as part of the string.

How can I force a new line to be printed in the file?

Here is what my code looks like so far:

fmt.Fprint(file, "<card>
")
fmt.Fprintf(file, `<title>title</title>
`)

and that is printing <card> <title>title</title>

Actually, it's printing

<card>
<title>title</title>

As you can see here.

The reason is that backslashes are not interpolated in raw strings, i.e. strings that are enclosed with `. If you replace your second line with

fmt.Fprintf("<title>title</title>
")

your program should work as intended.