Hello World (Go)

From LiteratePrograms
Jump to: navigation, search
Other implementations: Alice ML | Amiga E | AspectJ | Assembly Intel x86 Linux | Assembly Intel x86 NetBSD | AWK | bash | BASIC | Batch files | C | C, Cairo | C, Xlib | Candle | C++ | C# | Dylan | E | Forth | FORTRAN | Fortress | Go | Groovy | Haskell | Hume | IBM PC bootstrap | Inform 7 | Java | Java, Swing | JavaScript | LaTeX | Lisp | Logo | Lua | Maple | MATLAB | Mercury | OCaml/F Sharp | occam | Oz | Pascal | Perl | Perl6 | PHP | Pic | PIR | PLI | PostScript | Prolog | Python | Rexx | Ruby | Scala | Scheme | Seed7 | sh | Smalltalk | SQL | Standard ML | SVG | Tcl | Tcl Tk | Visual Basic | Visual Basic .NET | XSL

This is a simple Go program that prints "Hello World!" to the console.

<<hello.go>>=
package main
import "fmt"

func main() {
  fmt.Println("Hello World!")
}

The starting point of a Go program is a "main" function in package "main", which takes no arguments, and returns nothing. We import the "fmt" module, which provides formatted output functions. We call the fmt.Println() function, which prints a string, along with a newline.

Download code
hijacker
hijacker
hijacker
hijacker