Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hello Foo - Println

  • Println
  • :=

In go you can use the := operator to declare a variable and assign a value to it at the same time. Then you can use that variable in a Println. As you might notice, (I did not when I first tried this), the ``Printlnfunction inserts a space between the values it prints. For better control about this you can usePrintf`.

package main

import (
	"fmt"
)
func main() {
	name := "Foo"
	fmt.Println("Hello", name)
}
Hello Foo