Jump to content

Go (programming language)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by TXiKiBoT (talk | contribs) at 00:22, 13 November 2009 (robot Modifying: pt:Go (linguagem de programação)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Go
Paradigmcompiled, concurrent, imperative, structured
Designed byRobert Griesemer, Rob Pike, and Ken Thompson
DeveloperGoogle
First appeared2009
OSLinux, Mac OS X
LicenseBSD
Websitehttp://golang.org/
Major implementations
gc, gccgo
Influenced by
C, Oberon, Limbo[1]

Go is a compiled, concurrent programming language developed by Google[2] with work that carried over from the Inferno operating system.[3] The initial design of Go was started in September 2007 by Robert Griesemer, Rob Pike and Ken Thompson[1] and it was officially announced in November 2009. Go implementations are currently only available on Linux and Mac OS X.[4]

Since the launch of Google's programming language, Go and Go! have become the subject of a naming controversy that is still to be resolved.[5][6]

Description

The syntax of Go is close to that of C except for the type declarations; other syntactical differences are the missing parentheses around for and if expressions. The language supports garbage collection. The concurrency model of Go is modeled after Tony Hoare's CSP, like previous concurrent programming languages such as occam or Limbo,[1] but also has features of the Pi calculus such as channel passing.

Features not included in Go are exception handling, type inheritance, generic programming, assert, and method overriding.[1] Of these, the Go authors express an openness to generic programming, explicitly argue against assertions, while defending the choice to omit type inheritance on efficiency grounds.[1] Unlike Java, maps (also known as hashes or dictionaries) are an intrinsic part of the language, as are strings.

Implementations

There are currently two Go compilers. 6g (and its supporting tools, collectively known as gc) are in C, using yacc/Bison for the parser. Gccgo is a Go compiler with a C++ front-end with a recursive descent parser coupled to the standard GCC back end.[7]

Examples

The following is a hello world program in Go.

package main

import "fmt"

func main() {
	fmt.Printf("Hello, World\n")
}

Example of the Unix echo command:[8]

package main

import (
	"os";
	"flag"; // command line option parser
)

var omitNewline = flag.Bool("n", false, "don't print final newline")

const (
	Space = " ";
	Newline = "\n";
)

func main()  {
	flag.Parse(); // Scans the arg list and sets up flags
	var s string = "";
	for i := 0; i < flag.NArg(); i++ {
		if i > 0 {
			s += Space
		}
		s += flag.Arg(i)
	}
	if !*omitNewline {
		s += Newline
	}
	os.Stdout.WriteString(s);
}

Naming Dispute

A few days after the announcement of the language Francis McCabe, developer of the Go! language requested a name change of Google's language to prevent confusion with his language. McCabe created Go! in 2003 but has not trademarked the name.[9]

References

This article incorporates material from the official Go tutorial Let's Go, which is licensed under the Creative Commons Attribution 3.0 license.