The link: https://play.golang.org/p/1b5MbgIP2N
The code:
package main
import "fmt"
func main() {
println("his power level is over 9000!!! KAKAROTO")
println(test(2))
}
func test(x int) int {
fmt.Println(x, "
", "new line here")
fmt.Println("another line here")
return x + 1
}
for some reason unknown to me, there appears to be one single leading whitespace character in front of "new" when the function is run. This might be something really obvious but what is happening? I don't see that I'm explicitly adding a space anywhere
The documentation for fmt.Println says:
Spaces are always added between operands and a newline is appended.
There is a leading space because fmt.Println adds a space between the " " and "new line here" operands.
The fmt.Println function adds spaces between operands for convenience. It saves adding a number of " " operands in typical use of the function.
Change the code to fmt.Println(x, " new line here")
to avoid the unwanted space.