printf and println



println

package main
import "fmt"

func main() {
  name := "jim"
  fmt.Println("Hello world %s"\n, name)
}

go run a.go will give us Hello world %s jim

printf

package main
import "fmt"

func main() {
  name := "jim"
  fmt.Printf("Hello world %s\n", name)
}

This time, we get Hello world jim

1 comment: