Posts Tagged ‘fmt’

PACKAGES

 

Every Go program is made up of packages.

Programs start running in package main.

This program is using the packages with import paths "fmt" and"math".

By convention, the package name is the same as the last element of the import path.

Example:

package main

import (
“fmt”
“math”
)

func main() {
fmt.Println(“Happy”, math.Pi, “Day”)
}

output :

Happy 3.141592653589793 Day

Welcome to a tour of the Go programming language.

The tour is divided into three sections. At the end of each section is a series of exercises for you to complete.

The tour is interactive. Click the Run button now (or type Shift-Enter) to compile and run the program on a remote server. The result is displayed below the code.

These example programs demonstrate different aspects of Go. The programs in the tour are meant to be starting points for your own experimentation.

Edit the program and run it again.

Whenever you’re ready to move on, click the Next button or type the PageDown key.

Example:

package main

import “fmt”

func main() {
fmt.Println(“Hello, 世界”)
}

output :

Hello, 世界