Content deleted Content added
→Syntax: not sure this is useful, but give examples of returning both or neither of value+error, and change phrasing from "empty" since an "empty" int is 0 |
added archive-url, added metadata, replaced outdated urls |
||
Line 1:
{{short description|Programming language}}
{{for|the 2003 agent-based programming language|Go! (programming language)}}
{{Use American English|date=August 2022}}
{{Use mdy dates|date=October 2018}}
{{Infobox programming language
| name
| logo = Go Logo
| logo size = 230px
| paradigm = [[Multi-paradigm programming language|Multi-paradigm]]: [[concurrent programming|concurrent]], [[imperative programming|imperative]], [[functional programming|functional]],<ref>{{Cite web |url=https://go.dev/doc/codewalk/functions/ |title=Codewalk: First-Class Functions in Go |quote=Go supports first class functions, higher-order functions, user-defined function types, function literals, closures, and multiple return values. This rich feature set supports a functional programming style in a strongly typed language.}}</ref> [[object-oriented programming|object-oriented]]<ref>{{Cite web |url=https://golang.org/doc/faq#Is_Go_an_object-oriented_language |title=Is Go an object-oriented language? |access-date=April 13, 2019 |quote=Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy.}}</ref><ref>{{Cite web |url=https://talks.golang.org/2012/chat.slide#5 |title=Go: code that grows with grace |access-date=June 24, 2018 |quote=Go is Object Oriented, but not in the usual way.}}</ref>
| year
| designer
| developer = The Go Authors<ref
| latest release version = {{#statements:software version identifier}}
|
| latest_test_version =
| latest_test_date = <!--{{start date and age|2016|08|08}}<ref name="preview_page">{{Cite web |url=https://golang.org/dl/ |title=Release History |website=The Go Programming Language |access-date=August 8, 2016}}</ref>-->
| typing = [[type inference|Inferred]], [[static typing|static]], [[strong typing|strong]],<ref name="go-introduction">{{Cite web |title=The Go Programming Language Specification |url=https://go.dev/ref/spec#Introduction |url-status=live |archive-url=https://web.archive.org/web/20250813094237/https://go.dev/ref/spec#Introduction |archive-date=August 13, 2025 |work=The Go Programming Language }}</ref> [[structural typing|structural]],<ref name="structural_typing">{{Cite web |title=Why doesn't Go have "implements" declarations? |url=https://go.dev/doc/faq#implements_interface |url-status=live |archive-url=https://web.archive.org/web/20250728222723/https://go.dev/doc/faq#implements_interface |archive-date=July 28, 2025 |access-date=October 1, 2015 |website=The Go Programming Language }}</ref><ref name="pike-20141222">{{Cite tweet |first=Rob |last=Pike |number=546973312543227904 |user=rob_pike |title=Go has structural typing, not duck typing. Full interface satisfaction is checked and required. |author-link=Rob Pike |date=December 22, 2014 |access-date=March 13, 2016 |archive-url=https://web.archive.org/web/20220407025913/https://twitter.com/rob_pike/status/546973312543227904 |archive-date=April 7, 2022 |url-status=dead }}</ref> [[nominal typing|nominal]]
| memory management = [[Garbage collection (computer science)|Garbage collection]]
| implementations = gc, gofrontend, [[Elements_Toolchain|gold]]
| programming language = Go, [[Assembly language]] (gc); [[C++]] (gofrontend)
| website = {{url|https://go.dev/}}
| influenced_by = {{#statements:influenced by}}
| influenced = [[Crystal (programming language)|Crystal]], [[V (programming language)|V]]
| operating_system = [[DragonFly BSD]], [[FreeBSD]], [[Linux]], [[macOS]], [[NetBSD]], [[OpenBSD]],<ref name="openbsd">{{Cite web |url=http://ports.su/lang/go |title=lang/go: go-1.4 |date=December 23, 2014 |website=OpenBSD ports |access-date=January 19, 2015}}</ref> [[Plan 9 from Bell Labs|Plan 9]],<ref>{{Cite web |url=http://go-lang.cat-v.org/os-ports |title=Go Porting Efforts |date=January 12, 2010 |website=Go Language Resources |publisher=cat-v |access-date=January 18, 2010}}</ref> [[Solaris (operating system)|Solaris]], [[Windows]]
| license = [[3-clause BSD]]<ref name="license">{{Cite web |title=Text file LICENSE |url=https://go.dev/LICENSE |url-status=live |archive-url=https://web.archive.org/web/20250716050530/https://go.dev/LICENSE |archive-date=July 16, 2025 |access-date=October 5, 2012 |website=The Go Programming Language }}</ref> + [[software patents|patent]] grant<ref name="gopatens">{{Cite web |title=Additional IP Rights Grant |url=https://go.dev/PATENTS |url-status=live |archive-url=https://web.archive.org/web/20250330185005/https://go.dev/PATENTS |archive-date=March 30, 2025 |access-date=October 5, 2012 |website=The Go Programming Language }}</ref>
| file_ext = .go
}}
'''Go''' is a [[high-level programming language|high-level]] [[general purpose programming language]] that is [[static typing|statically typed]] and [[compiled language|compiled]]. It is known for the simplicity of its syntax and the efficiency of development that it enables by the inclusion of a large standard library supplying many needs for common projects.<ref>{{Cite web |title=Go Introduction |url=https://www.w3schools.com/go/go_introduction.php |access-date=2024-11-23 |website=www.w3schools.com |language=en-US}}</ref> It was designed at [[Google]]<ref name="techcrunch">{{Cite news |last=Kincaid |first=Jason |date=November 10, 2009 |title=Google's Go: A New Programming Language That's Python Meets C++ |url=https://techcrunch.com/2009/11/10/google-go-language/ |archive-url= |archive-date= |access-date=January 18, 2010 |work=[[TechCrunch]] }}</ref> in 2007 by [[Robert Griesemer]], [[Rob Pike]], and [[Ken Thompson]], and publicly announced in November of 2009.<ref name="langfaq">{{Cite web |date=January 16, 2010 |title=Language Design FAQ |url=https://go.dev/doc/faq |url-status=live |archive-url=https://web.archive.org/web/20250728222723/https://go.dev/doc/faq |archive-date=July 28, 2025 |access-date=February 27, 2010 |website=The Go Programming Language }}</ref> It is [[syntax (programming languages)|syntactically]] similar to [[C (programming language)|C]], but also has [[garbage collection (computer science)|garbage collection]], [[structural type system|structural typing]],<ref name="structural_typing" /> and [[communicating sequential processes|CSP]]-style [[concurrency (computer science)|concurrency]].<ref name="boldly">{{Cite news |last=Metz |first=Cade |date=May 5, 2011 |title=Google Go boldly goes where no code has gone before |url=https://www.theregister.com/2011/05/05/google_go/ |url-status=live |archive-url=https://web.archive.org/web/20250728222723/https://go.dev/doc/faq |archive-date=July 28, 2025 |work=[[The Register]] }}</ref> It is often referred to as '''Golang''' to avoid ambiguity and because of its former ___domain name, <code>golang.org</code>, but its proper name is Go.<ref>{{Cite web |url=https://go.dev/doc/faq#go_or_golang |title=Is the language called Go or Golang? |access-date=March 16, 2022 |quote=The language is called Go.}}</ref>
There are two major implementations:
* The original, [[Self-hosting (compilers)|self-hosting]]<ref>{{Cite web |url=https://golang.org/doc/go1.5#implementation |title=Go 1.5 Release Notes |access-date=January 28, 2016 |quote=The compiler and runtime are now implemented in Go and assembler, without C.}}</ref> [[compiler]] [[toolchain]], initially developed inside Google;<ref>{{Cite web |url=https://github.com/golang/go |title=The Go programming language |website=[[GitHub]] |access-date=2024-11-01}}</ref>
* A frontend written in [[C++]], called gofrontend,<ref>{{Cite web |url=https://github.com/golang/gofrontend |title=gofrontend |website=[[GitHub]] |access-date=2024-11-01}}</ref> originally a [[GNU Compiler Collection|GCC]] frontend, providing gccgo, a GCC-based Go compiler;<ref>{{Cite web |url=https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gccgo/ |title=gccgo |access-date=2024-11-01 |quote=gccgo, the GNU compiler for the Go programming language}}</ref> later extended to also support [[LLVM]], providing an LLVM-based Go compiler called gollvm.<ref>{{Cite web |url=https://go.googlesource.com/gollvm/ |title=Gollvm |access-date=2024-11-01 |quote=Gollvm is an LLVM-based Go compiler.}}</ref>
A third-party [[source-to-source compiler]], GopherJS,<ref>{{Cite web | url=https://github.com/gopherjs/gopherjs | title=A compiler from Go to JavaScript for running Go code in a browser: Gopherjs/Gopherjs| website=[[GitHub]] |url-status=live |archive-url=https://web.archive.org/web/20231212143621/https://github.com/gopherjs/gopherjs |archive-date= Dec 12, 2023 }}</ref> transpiles Go to [[JavaScript]] for [[front-end web development]].
{{toclimit}}
==History==
Go was designed at [[Google]] in 2007 to improve [[programming productivity]] in an era of [[multi-core processor|multicore]], [[computer network|networked]] [[computer|machines]] and large [[codebase]]s.<ref>{{Cite web |url=https://talks.golang.org/2012/splash.article |title=Go at Google: Language Design in the Service of Software Engineering |access-date=October 8, 2018}}</ref> The designers wanted to address criticisms of other languages in use at Google, but keep their useful characteristics:<ref>{{Cite web |url=http://www.stanford.edu/class/ee380/Abstracts/100428.html |title=Another Go at Language Design |last=Pike |first=Rob |date=April 28, 2010 |website=Stanford EE Computer Systems Colloquium |publisher=[[Stanford University]]}} [https://www.youtube.com/watch?v=7VcArS4Wpqk Video available].</ref>
* [[Static typing]] and [[Run time (program lifecycle phase)|run-time]] efficiency (like [[C (programming language)|C]])
* [[Readability]] and [[usability]] (like [[Python (programming language)|Python]])<ref>{{Cite web |url=https://golang.org/doc/faq#different_syntax |title=Frequently Asked Questions (FAQ) - The Go Programming Language |website=The Go Programming Language |access-date=February 26, 2016}}</ref>
* High-performance [[computer network|networking]] and [[multiprocessing]]
Its designers were primarily motivated by their shared [[Criticism of C++|dislike of C++]].<ref>{{Cite web|archive-url=https://web.archive.org/web/20130105013259/https://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480|archive-date=January 5, 2013 | url=http://www.drdobbs.com/open-source/interview-with-ken-thompson/229502480 |title=Dr. Dobb's: Interview with Ken Thompson |last= Binstock |first=Andrew|work=Dr. Dobb's |date=May 18, 2011 |access-date=February 7, 2014}}</ref><ref>{{Cite web |url=http://commandcenter.blogspot.mx/2012/06/less-is-exponentially-more.html |title=Less is exponentially more |last=Pike |first=Rob |year=2012}}</ref><ref>{{Cite web |url=https://talks.golang.org/2015/gophercon-goevolution.slide#4 |title=The Evolution of Go |last= Griesemer |first=Robert|year=2015}}</ref>
Go was publicly announced in November 2009,<ref>{{Cite web |url=https://opensource.googleblog.com/2009/11/hey-ho-lets-go.html |title=Hey! Ho! Let's Go! |last1=Griesemer |first1=Robert |last2=Pike |first2=Rob |website=Google Open Source |access-date=May 17, 2018 |last3=Thompson |first3=Ken |last4=Taylor |first4=Ian |last5=Cox |first5=Russ |last6=Kim |first6=Jini |last7=Langley |first7=Adam}}</ref> and version 1.0 was released in March 2012.<ref>{{Cite news |last=Shankland |first=Stephen |url=https://www.cnet.com/news/googles-go-language-turns-one-wins-a-spot-at-youtube/ |title=Google's Go language turns one, wins a spot at YouTube: The lower-level programming language has matured enough to sport the 1.0 version number. And it's being used for real work at Google. |date=March 30, 2012 |access-date=August 6, 2017 |publisher=CBS Interactive Inc |department=News |quote=Google has released version 1 of its Go programming language, an ambitious attempt to improve upon giants of the lower-level programming world such as C and C++. |website=CNet}}</ref><ref>{{Cite web|url=https://golang.org/doc/devel/release.html|title=Release History |website=The Go Programming Language}}</ref> Go is widely used in production at Google<ref name="faq">{{Cite news |url=https://golang.org/doc/faq#internal_usage |title=Go FAQ: Is Google using Go internally? |access-date=March 9, 2013}}</ref> and in many other organizations and open-source projects.
In retrospect the Go authors judged Go to be successful due to the overall engineering work around the language, including the runtime support for the language's concurrency feature.
{{Quotation|Although the design of most languages concentrates on innovations in syntax, semantics, or typing, Go is focused on the software development process itself. ... The principal unusual property of the language itself—concurrency—addressed problems that arose with the proliferation of multicore CPUs in the 2010s. But more significant was the early work that established fundamentals for packaging, dependencies, build, test, deployment, and other workaday tasks of the software development world, aspects
that are not usually foremost in language design.<ref>The Go Programming Language and Environment. Communications of the ACM. https://dl.acm.org/doi/pdf/10.1145/3488716</ref>}}
===Branding and styling===
[[File:Golang.png|thumb|Mascot of Go programming language is the [[Gopher]] shown above.]]
The [[Gopher]] [[mascot]] was introduced in 2009 for the [[open source]] launch of the language. The design, by [[Renée French]], borrowed from a c. 2000 [[WFMU]] promotion.<ref>{{cite web |title=The Go Gopher - The Go Programming Language |url=https://go.dev/blog/gopher |website=go.dev |access-date=2023-02-09 |language=en}}</ref>
In November 2016, the Go and Go Mono fonts were released by type designers [[Charles Bigelow (type designer)|Charles Bigelow]] and [[Kris Holmes]] specifically for use by the Go project. Go is a [[humanist sans-serif]] resembling [[Lucida Grande]], and Go Mono is [[monospaced]]. Both fonts adhere to the [[WGL4]] character set and were designed to be legible with a large [[x-height]] and distinct [[letterform]]s. Both Go and Go Mono adhere to the [[DIN]] 1450 standard by having a slashed zero, lowercase <code>l</code> with a tail, and an uppercase <code>I</code> with serifs.<ref>{{Cite web |url=https://blog.golang.org/go-fonts |title=Go fonts |date=16 November 2016 |publisher=Go |access-date=12 March 2019}}</ref><ref>{{Cite web |url=https://github.com/golang/image/tree/master/font/gofont/ttfs |title=Go Font TTFs |website=GitHub |access-date=April 2, 2019}}</ref>
In April 2018, the original logo was redesigned by brand designer Adam Smith. The new logo is a modern, stylized GO slanting right with trailing streamlines. (The Gopher mascot remained the same.<ref>{{Cite web |url=https://blog.golang.org/go-brand |title=Go's New Brand |website=The Go Blog |access-date=2018-11-09}}</ref>)
===Generics===
The lack of support for [[generic programming]] in initial versions of Go drew considerable criticism.<ref>{{cite web | url=https://go.dev/blog/survey2020-results#:~:text=Among%20the%2026%25%20of%20respondents%20who%20said%20Go%20lacks%20language%20features%20they%20need%2C%2088%25%20selected%20generics%20as%20a%20critical%20missing%20feature. | title=Go Developer Survey 2020 Results | last=Merrick | first=Alice | website=Go Programming Language | date=March 9, 2021 | access-date=March 16, 2022}}</ref> The designers expressed an openness to generic programming and noted that built-in functions ''were'' in fact type-generic, but are treated as special cases; Pike called this a weakness that might be changed at some point.<ref name="append">{{cite web |title=Arrays, slices (and strings): The mechanics of 'append' |first=Rob |last=Pike |website=The Go Blog |url=http://blog.golang.org/slices |date=September 26, 2013 |access-date=March 7, 2015}}</ref> The Google team built at least one compiler for an experimental Go dialect with generics, but did not release it.<ref>{{cite web |title=E2E: Erik Meijer and Robert Griesemer |website=Channel 9 |publisher=Microsoft |date=May 7, 2012 |url=http://channel9.msdn.com/Blogs/Charles/Erik-Meijer-and-Robert-Griesemer-Go}}</ref>
In August 2018, the Go principal contributors published draft designs for generic programming and [[exception handling|error handling]] and asked users to submit feedback.<ref>{{Cite web |url=https://go.googlesource.com/proposal/+/master/design/go2draft.md |title=Go 2 Draft Designs |access-date=September 12, 2018}}</ref><ref>{{Cite web |url=https://blog.golang.org/go2draft |title=The Go Blog: Go 2 Draft Designs |date=August 28, 2018}}</ref> However, the error handling proposal was eventually abandoned.<ref>{{cite web |url=https://github.com/golang/go/issues/32437 |title=Proposal: A built-in Go error check function, "try" |website=Go repository on GitHub |access-date=March 16, 2022}}</ref>
In June 2020, a new draft design document<ref>{{cite web |url=https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md |title= Type Parameters — Draft Design |work=go.googlesource.com}}</ref> was published that would add the necessary syntax to Go for declaring generic functions and types. A code translation tool, ''{{mono|go2go}}'', was provided to allow users to try the new syntax, along with a generics-enabled version of the online Go Playground.<ref>{{cite web |url=https://bitfieldconsulting.com/golang/generics |title= Generics in Go |work=bitfieldconsulting.com|date= December 17, 2021 }}</ref>
Generics were finally added to Go in version 1.18 on March 15, 2022.<ref>{{cite web |url=https://go.dev/blog/go1.18 |title=Go 1.18 is released! |website=Go Programming Language |date=March 15, 2022 |access-date=March 16, 2022}}</ref>
===Versioning===
Go 1 guarantees compatibility<ref>{{Cite web|url=https://golang.org/doc/go1compat|title=Go 1 and the Future of Go Programs |website=The Go Programming Language}}</ref> for the language specification and major parts of the standard library. All versions up through the current Go 1.24 release<ref>{{Cite web|title=Go 1.24 Release Notes|url=https://go.dev/doc/go1.24|website=The Go Programming Language}}</ref> have maintained this promise.
Go uses a <code>go1.[major].[patch]</code> versioning format, such as <code>go1.24.0</code> and each major Go release is supported until there are two newer major releases. Unlike most software, Go calls the second number in a version the major, i.e., in <code>go1.24.0</code> the <code>24</code> is the major version.<ref>{{Cite web|url=https://golang.org/doc/devel/release.html#policy|title=Release History|website=The Go Programming Language}}</ref> This is because Go plans to never reach 2.0, prioritizing backwards compatibility over potential breaking changes.<ref>{{Cite web|url=https://go.dev/blog/compat|title=Backward Compatibility, Go 1.21, and Go 2|website=The Go Programming Language}}</ref>
==Design==
[[File:DotGo 2015 - Rob Pike - Simplicity is Complicated.webm|thumb|2015 lecture of Rob Pike (one of the Go creators)]]
Go is influenced by [[C (programming language)|C]] (especially the [[Plan 9 from Bell Labs|Plan 9]] [[Dialect (computing)|dialect]]<ref>{{Cite web|title=A Quick Guide to Go's Assembler |url=https://go.dev/doc/asm|access-date=2021-12-31|website=go.dev}}</ref>{{Failed verification|date=June 2022|talk=Plan 9 C}}), but with an emphasis on greater simplicity and safety. It consists of:
* A syntax and environment adopting patterns more common in [[dynamic programming language|dynamic language]]s:<ref name="go_lang_video_2009">{{Cite web |url=https://www.youtube.com/watch?v=rKnDgT73v8s |title=The Go Programming Language |last=Pike |first=Rob |date=November 10, 2009 |publisher=YouTube |access-date=July 1, 2011}}</ref>
** Optional concise variable declaration and initialization through [[type inference]] (<syntaxhighlight lang="Go" inline>x := 0</syntaxhighlight> instead of <syntaxhighlight lang="Go" inline>var x int = 0;</syntaxhighlight> or <syntaxhighlight lang="Go" inline>var x = 0;</syntaxhighlight>)
** Fast compilation<ref name="techtalk-compiling">{{Cite AV media |url=https://www.youtube.com/watch?v=rKnDgT73v8s#t=8m53 |title=The Go Programming Language |date=November 10, 2009 |last= Pike |first=Rob|publisher=Google |time=8:53 |format=flv |medium=Tech talk}}</ref>
** Remote package management (<code>go get</code>)<ref>{{cite web|url=http://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies|title=Download and install packages and dependencies }} See [http://godoc.org godoc.org] for addresses and documentation of some packages.</ref> and online package documentation<ref>{{Cite web |url=http://godoc.org |title=GoDoc |website=godoc.org}}</ref>
* Distinctive approaches to particular problems:
** Built-in concurrency primitives: [[light-weight process]]es (goroutines), [[channel (programming)|channels]], and the <code>select</code> statement
** An [[protocol (object-oriented programming)|interface]] system in place of [[virtual inheritance]], and type embedding instead of non-virtual inheritance
** A toolchain that, by default, produces [[static library|statically linked]] native binaries without external Go dependencies
* A desire to keep the language specification simple enough to hold in a programmer's head,<ref>{{cite web|last=Pike|first=Rob|url=http://5by5.tv/changelog/100|title=The Changelog|type=Podcast|access-date=October 7, 2013|archive-date=October 20, 2013|archive-url=https://web.archive.org/web/20131020101046/http://5by5.tv/changelog/100|url-status=dead}}</ref> in part by [[#Omissions|omitting features that are common in similar languages]].
* 25 reserved words
===Syntax===
Go's syntax includes changes from [[C (programming language)|C]] aimed at keeping code concise and readable. A combined declaration/initialization operator was introduced that allows the programmer to write <syntaxhighlight lang="Go" inline>i := 3</syntaxhighlight> or <syntaxhighlight lang="Go" inline>s := "Hello, world!"</syntaxhighlight>, [[type inference|without specifying the types]] of variables used. This contrasts with C's <syntaxhighlight lang="C" inline>int i = 3;</syntaxhighlight> and <syntaxhighlight lang="C" inline>const char *s = "Hello, world!";</syntaxhighlight>. Go also removes the requirement to use parentheses in if statement conditions.
Semicolons still terminate statements;{{efn|But "To allow complex statements to occupy a single line, a semicolon may be omitted before a closing ) or }".<ref>{{Cite web |url=https://golang.org/ref/spec#Semicolons |title=Go Programming Language Specification, §Semicolons |website=The Go Programming Language}}</ref>}} but are implicit when the end of a line occurs.{{efn|"if the newline comes after a token that could end a statement, [the lexer will] insert a semicolon".<ref>{{Cite web |url=https://golang.org/doc/effective_go.html#semicolons |title=Effective Go, §Semicolons |website=The Go Programming Language}}</ref>}}
Methods may return multiple values, and returning a <syntaxhighlight lang="Go" inline="">result, err</syntaxhighlight> pair is the conventional way a method indicates an error to its caller in Go.{{efn|Usually, exactly one of the result and error values has a value other than the type's zero value; sometimes both do, as when a read or write can only be partially completed, and sometimes neither, as when a read returns 0 bytes. See [[Semipredicate problem#Multivalued return|Semipredicate problem: Multivalued return]].}} Go adds literal syntaxes for initializing struct parameters by name and for initializing [[Associative array|maps]] and [[Array slicing|slices]]. As an alternative to C's three-statement <code>for</code> loop, Go's <code>range</code> expressions allow concise iteration over arrays, slices, strings, maps, and channels.<ref>{{Cite web|url=https://golang.org/ref/spec#For_statements|title=The Go Programming Language Specification |website=The Go Programming Language}}</ref>
===Types===
Go has a number of built-in types, including numeric ones ({{mono|byte}}, {{mono|int64}}, {{mono|float32}}, etc.), [[Boolean data type|Booleans]], and byte strings ({{mono|string}}). Strings are immutable; built-in operators and keywords (rather than functions) provide concatenation, comparison, and [[UTF-8]] encoding/decoding.<ref>{{cite web|last=Pike|first=Rob|url=http://blog.golang.org/strings|title=Strings, bytes, runes and characters in Go|date=October 23, 2013}}</ref> [[Record (computer science)|Record types]] can be defined with the {{mono|struct}} keyword.<ref>{{Cite web |url=https://www.golang-book.com/books/intro/9 |title=Structs and Interfaces — An Introduction to Programming in Go |last=Doxsey |first=Caleb |website=www.golang-book.com |access-date=15 October 2018}}</ref>
For each type {{mono|''T''}} and each non-negative integer constant {{mono|''n''}}, there is an [[array data type|array type]] denoted {{mono|[''n'']''T''}}; arrays of differing lengths are thus of different types. [[Dynamic array]]s are available as "slices", denoted {{mono|[]''T''}} for some type {{mono|''T''}}. These have a length and a ''capacity'' specifying when new memory needs to be allocated to expand the array. Several slices may share their underlying memory.{{r|append}}<ref>{{cite web|last=Gerrand|first=Andrew|url=http://blog.golang.org/go-slices-usage-and-internals|title=Go Slices: usage and internals}}</ref><ref>{{cite web|author=The Go Authors|url=http://golang.org/doc/effective_go.html#slices|title=Effective Go: Slices}}</ref>
[[Pointer (computer programming)|''Pointers'']] are available for all types, and the pointer-to-{{mono|''T''}} type is denoted {{mono|*''T''}}. Address-taking and indirection use the {{mono|&}} and {{mono|*}} operators, as in C, or happen implicitly through the method call or attribute access syntax.<ref>{{cite web|author=The Go authors|url=https://golang.org/ref/spec#Selectors|title=Selectors }}</ref><ref>{{cite web|author=The Go authors|url=https://golang.org/ref/spec#Calls|title=Calls }}</ref> There is no pointer arithmetic,{{efn|name=noPointerArith}} except via the special {{mono|unsafe.Pointer}} type in the standard library.<ref>{{Cite web |url=https://golang.org/ref/spec#Package_unsafe |title=Go Programming Language Specification, §Package unsafe |website=The Go Programming Language}}</ref>
For a pair of types {{mono|''K''}}, {{mono|''V''}}, the type {{mono|map[''K'']''V''}} is the type mapping type-{{mono|''K''}} keys to type-{{mono|''V''}} values, though Go Programming Language specification does not give any performance guarantees or implementation requirements for map types. Hash tables are built into the language, with special syntax and built-in functions. {{mono|chan '' T''}} is a ''channel'' that allows sending values of type ''T'' between [[#Concurrency|concurrent Go processes]].<ref>{{Cite web|title=The Go Programming Language Specification |url=https://go.dev/ref/spec#Channel_types|access-date=2021-12-31|website=go.dev}}</ref>
Aside from its support for [[#Interfaces|interfaces]], Go's type system is [[nominal type system|nominal]]: the {{mono|type}} keyword can be used to define a new ''named type'', which is distinct from other named types that have the same layout (in the case of a {{mono|struct}}, the same members in the same order). Some conversions between types (e.g., between the various integer types) are pre-defined and adding a new type may define additional conversions, but conversions between named types must always be invoked explicitly.<ref>{{Cite web |url=http://golang.org/ref/spec#Assignability |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref> For example, the {{mono|type}} keyword can be used to define a type for [[IPv4]] addresses, based on 32-bit unsigned integers as follows:
<syntaxhighlight lang="go">
type ipv4addr uint32
</syntaxhighlight>
With this type definition, {{mono|ipv4addr(x)}} interprets the {{mono|uint32}} value {{mono|x}} as an IP address. Simply assigning {{mono|x}} to a variable of type {{mono|ipv4addr}} is a type error.<ref>{{Cite web |url=https://go.dev/tour/basics/13|title=A tour of go |website=go.dev}}</ref>
''Constant expressions'' may be either typed or "untyped"; they are given a type when assigned to a typed variable if the value they represent passes a compile-time check.<ref>{{Cite web |url=http://golang.org/ref/spec#Constants |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref>
''[[Subroutine|Function]] types'' are indicated by the {{mono|func}} keyword; they take zero or more [[parameter (computer programming)|parameters]] and [[return statement|return]] zero or more values, all of which are typed. The parameter and return values determine a function type; thus, {{mono|func(string, int32) (int, error)}} is the type of functions that take a {{mono|string}} and a 32-bit signed integer, and return a signed integer (of default width) and a value of the built-in interface type {{mono|error}}.<ref>{{Cite web|title=The Go Programming Language Specification |url=https://go.dev/ref/spec#Function_types|access-date=2021-12-31|website=go.dev}}</ref>
Any named type has a [[method (computer programming)|method]] set associated with it. The IP address example above can be extended with a method for checking whether its value is a known standard:
<syntaxhighlight lang="go">
// ZeroBroadcast reports whether addr is 255.255.255.255.
func (addr ipv4addr) ZeroBroadcast() bool {
return addr == 0xFFFFFFFF
}
</syntaxhighlight>
Due to nominal typing, this method definition adds a method to {{mono|ipv4addr}}, but not on {{mono|uint32}}. While methods have special definition and call syntax, there is no distinct method type.<ref>{{Cite web |url=http://golang.org/ref/spec#Calls |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref>
===={{anchor|Interfaces}} Interface system====
Go provides two features that replace [[inheritance (object-oriented programming)|class inheritance]].{{citation needed|date=December 2016}}
The first is ''embedding'', which can be viewed as an automated form of [[object composition|composition]].{{r|gohotdraw}}
The second are its ''[[protocol (object-oriented programming)|interface]]s'', which provides [[runtime polymorphism]].<ref name="balbaert">{{Cite book |last=Balbaert |first=Ivo |title=The Way to Go: A Thorough Introduction to the Go Programming Language |publisher=iUniverse |year=2012}}</ref>{{rp|266}} Interfaces are a class of types and provide a limited form of [[structural type system|structural typing]] in the otherwise nominal type system of Go. An object which is of an interface type is also of another type, much like [[C++]] objects being simultaneously of a base and derived class. The design of Go interfaces was inspired by [[protocol (object-oriented programming)|protocol]]s from the Smalltalk programming language.<ref>{{Cite web |url=https://talks.golang.org/2015/gophercon-goevolution.slide#19 |title=The Evolution of Go |website=talks.golang.org |access-date=March 13, 2016}}</ref> Multiple sources use the term [[duck typing]] when describing Go interfaces.<ref>{{Cite web|last=Diggins|first=Christopher|date=November 24, 2009|title=Duck Typing and the Go Programming Language|url=http://www.drdobbs.com/architecture-and-design/duck-typing-and-the-go-programming-langu/228701527|access-date=March 10, 2016|website=Dr. Dobb's, The world of software development}}</ref><ref>{{Cite web |url=https://medium.com/@matryer/golang-advent-calendar-day-one-duck-typing-a513aaed544d#.ebm7j81xu |title=Duck typing in Go |last=Ryer |first=Mat |date=December 1, 2015 |access-date=March 10, 2016}}</ref> Although the term duck typing is not precisely defined and therefore not wrong, it usually implies that type conformance is not statically checked. Because conformance to a Go interface is checked statically by the Go compiler (except when performing a type assertion), the Go authors prefer the term ''structural typing''.<ref>{{Cite web |url=https://golang.org/doc/faq |title=Frequently Asked Questions (FAQ) - The Go Programming Language |website=The Go Programming Language}}</ref>
The definition of an interface type lists required methods by name and type. Any object of type T for which functions exist matching all the required methods of interface type I is an object of type I as well. The definition of type T need not (and cannot) identify type I. For example, if {{mono|Shape}}, {{mono|Square}} {{mono|and Circle}} are defined as
<syntaxhighlight lang="go">
import "math"
type Shape interface {
}
type Square struct { // Note: no "implements" declaration
side float64
}
func (
type Circle struct { // No "implements" declaration here either
}
func (c Circle) Area() float64 { return math.Pi * math.Pow(c.radius, 2) }
</syntaxhighlight>
then both a {{mono|Square}} and a {{mono|Circle}} are implicitly a {{mono|Shape}} and can be assigned to a {{mono|Shape}}-typed variable.{{r|balbaert}}{{rp|263–268}} In formal language, Go's interface system provides [[structural type system|structural]] rather than [[nominal type system|nominal]] typing. Interfaces can embed other interfaces with the effect of creating a combined interface that is satisfied by exactly the types that implement the embedded interface and any methods that the newly defined interface adds.{{r|balbaert}}{{rp|270}}
The Go standard library uses interfaces to provide genericity in several places, including the input/output system that is based on the concepts of {{mono|Reader}} and {{mono|Writer}}.{{r|balbaert}}{{rp|282–283}}
Besides calling methods via interfaces, Go allows converting interface values to other types with a run-time type check. The language constructs to do so are the ''type assertion'',<ref>{{Cite web |url=http://golang.org/ref/spec#Type_assertions |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref> which checks against a single potential type:<syntaxhighlight lang="go">
var shp Shape = Square{5}
square, ok := shp.(Square) // Asserts Square type on shp, should work
if ok {
fmt.Printf("%#v\n", square)
} else {
fmt.Println("Can't print shape as Square")
}
</syntaxhighlight>and the ''type switch'',<ref>{{Cite web |url=http://golang.org/ref/spec#Type_switches |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref> which checks against multiple types:{{citation needed|date=December 2016}}<syntaxhighlight lang="go">
func (sq Square) Diagonal() float64 { return sq.side * math.Sqrt2 }
func (c Circle) Diameter() float64 { return 2 * c.radius }
func LongestContainedLine(shp Shape) float64 {
switch v := shp.(type) {
case Square:
return v.Diagonal() // Or, with type assertion, shp.(Square).Diagonal()
case Circle:
return v.Diameter() // Or, with type assertion, shp.(Circle).Diameter()
default:
return 0 // In practice, this should be handled with errors
}
}
</syntaxhighlight>The ''empty interface'' <syntaxhighlight lang="Go" inline>interface{}</syntaxhighlight> is an important base case because it can refer to an item of ''any'' concrete type. It is similar to the {{mono|Object}} class in [[Java (programming language)|Java]] or [[C Sharp (programming language)|C#]] and is satisfied by any type, including built-in types like {{mono|int}}.{{r|balbaert}}{{rp|284}} Code using the empty interface cannot simply call methods (or built-in operators) on the referred-to object, but it can store the <syntaxhighlight lang="Go" inline>interface{}</syntaxhighlight> value, try to convert it to a more useful type via a type assertion or type switch, or inspect it with Go's <code>reflect</code> package.<ref>{{Cite web|url=https://pkg.go.dev/reflect|title=reflect package |website=pkg.go.dev}}</ref> Because <syntaxhighlight lang="Go" inline>interface{}</syntaxhighlight> can refer to any value, it is a limited way to escape the restrictions of static typing, like <syntaxhighlight lang="C" inline>void*</syntaxhighlight> in C but with additional run-time type checks.{{citation needed|date=December 2016}}
The <syntaxhighlight lang="Go" inline>interface{}</syntaxhighlight> type can be used to model structured data of any arbitrary schema in Go, such as [[JSON]] or [[YAML]] data, by representing it as a <syntaxhighlight lang="Go" inline>map[string]interface{}</syntaxhighlight> (map of string to empty interface). This recursively describes data in the form of a dictionary with string keys and values of any type.<ref>{{cite web |url=https://bitfieldconsulting.com/golang/map-string-interface |title= map[string]interface{} in Go |work=bitfieldconsulting.com|date= June 6, 2020 }}</ref>
Interface values are implemented using pointer to data and a second pointer to run-time type information.<ref>{{Cite web |url=http://research.swtch.com/interfaces |title=Go Data Structures: Interfaces |access-date=November 15, 2012}}</ref> Like some other types implemented using pointers in Go, interface values are <code>nil</code> if uninitialized.<ref>{{Cite web |url=http://golang.org/ref/spec#Interface_types |title=The Go Programming Language Specification |website=The Go Programming Language}}</ref>
====Generic code using parameterized types====
Since version 1.18, Go supports generic code using parameterized types.<ref>{{cite web |url=https://go.dev/doc/go1.18#generics |title=Go 1.18 Release Notes: Generics |website=Go Programming Language |date=March 15, 2022 |access-date=March 16, 2022}}</ref>
Functions and types now have the ability to be generic using type parameters. These type parameters are specified within square brackets, right after the function or type name.<ref>{{Cite web |title=Type Parameters Proposal |url=https://go.googlesource.com/proposal/+/HEAD/design/43651-type-parameters.md |access-date=2023-06-25 |website=go.googlesource.com}}</ref> The compiler transforms the generic function or type into non-generic by substituting ''type arguments'' for the type parameters provided, either explicitly by the user or type inference by the compiler.<ref>{{Cite web |title=The Go Programming Language Specification - The Go Programming Language |url=https://go.dev/ref/spec |access-date=2023-06-25 |website=go.dev |language=en}}</ref> This transformation process is referred to as type instantiation.<ref>{{Cite web |title=An Introduction To Generics - The Go Programming Language |url=https://go.dev/blog/intro-generics |access-date=2023-06-25 |website=go.dev |language=en}}</ref>
Interfaces now can define a set of types (known as type set) using <code>|</code> (Union) operator, as well as a set of methods. These changes were made to support type constraints in generics code. For a generic function or type, a constraint can be thought of as the type of the type argument: a meta-type. This new <code>~T</code> syntax will be the first use of <code>~</code> as a token in Go. <code>~T</code> means the set of all types whose underlying type is <code>T</code>.<ref>{{Cite web |title=Type Parameters Proposal |url=https://go.googlesource.com/proposal/+/HEAD/design/43651-type-parameters.md#using-a-constraint |access-date=2023-06-25 |website=go.googlesource.com}}</ref><syntaxhighlight lang="go">
type Number interface {
~int | ~float64 | ~float32 | ~int32 | ~int64
}
func Add[T Number](nums ...T) T {
var sum T
for _, v := range nums {
sum += v
}
return sum
}
func main() {
add := Add[int] // Type instantiation
println(add(1, 2, 3, 4, 5)) // 15
res := Add(1.1, 2.2, 3.3, 4.4, 5.5) // Type Inference
println(res) // +1.650000e+001
}
</syntaxhighlight>
====Enumerated types====
{{excerpt|Enumerated type|Go|subsections=yes}}
===Package system===
In Go's package system, each package has a path (e.g., <code>"compress/bzip2"</code> or <code>"golang.org/x/net/html"</code>) and a name (e.g., <code>bzip2</code> or <code>html</code>). By default other packages' definitions must ''always'' be prefixed with the other package's name. However the name used can be changed from the package name, and if imported as <code>_</code>, then no package prefix is required. Only the ''capitalized'' names from other packages are accessible: <code>io.Reader</code> is public but <code>bzip2.reader</code> is not.<ref>{{Cite web |url=http://golang.org/doc/go_tutorial.html |title=A Tutorial for the Go Programming Language |website=The Go Programming Language |access-date=March 10, 2013 |quote=In Go the rule about visibility of information is simple: if a name (of a top-level type, function, method, constant or variable, or of a structure field or method) is capitalized, users of the package may see it. Otherwise, the name and hence the thing being named is visible only inside the package in which it is declared.}}</ref> The <code>go get</code> command can retrieve packages stored in a remote repository<ref>{{Cite web |url=http://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies |title=go |website=The Go Programming Language}}</ref> and developers are encouraged to develop packages inside a base path corresponding to a source repository (such as example.com/user_name/package_name) to reduce the likelihood of name collision with future additions to the standard library or other external libraries.<ref>{{Cite web |url=https://golang.org/doc/code.html |title=How to Write Go Code |website=The Go Programming Language |quote=The packages from the standard library are given short import paths such as "fmt" and "net/http". For your own packages, you must choose a base path that is unlikely to collide with future additions to the standard library or other external libraries. If you keep your code in a source repository somewhere, then you should use the root of that source repository as your base path. For instance, if you have an Example account at example.com/user, that should be your base path}}</ref>
==={{anchor|Concurrency}} Concurrency: goroutines and channels===
[[File:DotGo 2015 - Matt Aimonetti - Applied concurrency in Go.webm|thumb|DotGo 2015 - Matt Aimonetti - Applied concurrency in Go]]
The Go language has built-in facilities, as well as library support, for writing [[concurrent programming|concurrent programs]]. The runtime is [[asynchronous I/O|asynchronous]]: program execution that performs, for example, a network read will be suspended until data is available to process, allowing other parts of the program to perform other work. This is built into the runtime and does not require any changes in program code. The go runtime also automatically schedules concurrent operations (goroutines) across multiple CPUs; this can achieve parallelism for a properly written program.<ref name="concurrency-is-not">{{cite web|last=Pike |first=Rob |url=http://vimeo.com/49718712 |title=Concurrency is not Parallelism|date=September 18, 2012 }}</ref>
The primary concurrency construct is the ''goroutine'', a type of [[green thread]].<ref name=":0">{{Cite book |last1=Donovan |first1=Alan A. A. |title=The Go programming language |last2=Kernighan |first2=Brian W. |date=2016 |publisher=Addison-Wesley |isbn=978-0-13-419044-0 |series=Addison-Wesley professional computing series |___location=New York, Munich |pages=}}</ref>{{Rp|pages=280-281}} A function call prefixed with the <code>go</code> keyword starts a function in a new goroutine. The language specification does not specify how goroutines should be implemented, but current implementations multiplex a Go process's goroutines onto a smaller set of [[thread (computer science)|operating-system threads]], similar to the scheduling performed in [[Erlang (programming language)|Erlang]] and [[Haskell (programming language)|Haskell's GHC runtime implementation]].{{r|phrasebook}}{{rp|10}}
While a standard library package featuring most of the classical [[concurrency control]] structures ([[mutex]] locks, etc.) is available,{{r|phrasebook}}{{rp|151–152}} idiomatic concurrent programs instead prefer ''channels'', which [[message passing|send messages]] between goroutines.<ref>{{Cite web |url=http://golang.org/doc/effective_go.html#sharing |title=Effective Go |website=The Go Programming Language}}</ref> Optional buffers store messages in [[FIFO (computing and electronics)|FIFO]] order<ref name="summerfield">{{Cite book |last=Summerfield |first=Mark |title=Programming in Go: Creating Applications for the 21st Century |publisher=Addison-Wesley |year=2012}}</ref>{{rp|43}} and allow sending goroutines to proceed before their messages are received.<ref name=":0" />{{Rp|page=233}}
Channels are typed, so that a channel of type {{mono|chan ''T''}} can only be used to transfer messages of type {{mono|''T''}}. Special syntax is used to operate on them; {{mono|<-ch}} is an expression that causes the executing goroutine to block until a value comes in over the channel {{mono|ch}}, while {{mono|ch <- x}} sends the value {{mono|x}} (possibly blocking until another goroutine receives the value). The built-in {{mono|switch}}-like {{mono|select}} statement can be used to implement non-blocking communication on multiple channels; see [[#Concurrencyexample|below]] for an example. Go has a memory model describing how goroutines must use channels or other operations to safely share data.<ref>{{Cite web |url=http://golang.org/ref/mem |title=The Go Memory Model |access-date=April 10, 2017}}</ref>
The existence of channels does not by itself set Go apart from [[actor model]]-style concurrent languages like Erlang, where messages are addressed directly to actors (corresponding to goroutines). In the actor model, channels are themselves actors, therefore addressing a channel just means to address an actor. The actor style can be simulated in Go by maintaining a one-to-one correspondence between goroutines and channels, but the language allows multiple goroutines to share a channel or a single goroutine to send and receive on multiple channels.{{r|phrasebook}}{{rp|147}}
From these tools one can build concurrent constructs like [[Thread pool|worker pools]], pipelines (in which, say, a file is decompressed and parsed as it downloads), background calls with timeout, "fan-out" parallel calls to a set of services, and others.<ref>{{Cite web |url=http://talks.golang.org/2012/concurrency.slide |title=Go Concurrency Patterns |website=The Go Programming Language}}</ref> Channels have also found uses further from the usual notion of interprocess communication, like serving as a concurrency-safe list of recycled buffers,<ref>{{cite web|last=Graham-Cumming|first=John|url=http://blog.cloudflare.com/recycling-memory-buffers-in-go|title=Recycling Memory Buffers in Go|work=The Cloudflare Blog |date=August 24, 2013}}</ref> implementing [[coroutine]]s (which helped inspire the name ''goroutine''),<ref>{{Cite web|url=http://golang.org/doc/play/tree.go|title=tree.go}}</ref> and implementing [[iterator]]s.<ref>{{cite web|last=Cheslack-Postava |first=Ewen |url=http://ewencp.org/blog/golang-iterators/ |title=Iterators in Go}}</ref>
Concurrency-related structural conventions of Go ([[channel (programming)|channel]]s and alternative channel inputs) are derived from [[C. A. R. Hoare|Tony Hoare's]] [[communicating sequential processes]] model. Unlike previous concurrent programming languages such as [[Occam (programming language)|Occam]] or [[Limbo (programming language)|Limbo]] (a language on which Go co-designer Rob Pike worked),<ref>{{cite web|last=Kernighan|first=Brian W.|url=http://www.vitanuova.com/inferno/papers/descent.html|title=A Descent Into Limbo}}</ref> Go does not provide any built-in notion of safe or verifiable concurrency.<ref name="memmodel">{{cite web |url=http://golang.org/doc/go_mem.html |title=The Go Memory Model |access-date=January 5, 2011}}</ref> While the communicating-processes model is favored in Go, it is not the only one: all goroutines in a program share a single address space. This means that mutable objects and pointers can be shared between goroutines; see {{slink||Lack of data race safety}}, below.
====Suitability for parallel programming====
Although Go's concurrency features are not aimed primarily at [[parallel computing|parallel processing]],{{r|concurrency-is-not}} they can be used to program [[shared-memory architecture|shared-memory]] [[multiprocessing|multi-processor]] machines. Various studies have been done into the effectiveness of this approach.<ref>{{cite conference |last=Tang |first=Peiyi |title=Multi-core parallel programming in Go |conference=Proc. First International Conference on Advanced Computing and Communications |year=2010 |url=http://www.ualr.edu/pxtang/papers/acc10.pdf |access-date=May 14, 2015 |archive-date=September 9, 2016 |archive-url=https://web.archive.org/web/20160909032631/http://www.ualr.edu/pxtang/papers/acc10.pdf |url-status=dead }}</ref> One of these studies compared the size (in [[lines of code]]) and speed of programs written by a seasoned programmer not familiar with the language and corrections to these programs by a Go expert (from Google's development team), doing the same for [[Chapel (programming language)|Chapel]], [[Cilk]] and [[Intel Threading Building Blocks|Intel TBB]]. The study found that the non-expert tended to write [[fork–join model|divide-and-conquer]] algorithms with one {{mono|go}} statement per recursion, while the expert wrote distribute-work-synchronize programs using one goroutine per processor core. The expert's programs were usually faster, but also longer.<ref>{{cite conference |last1=Nanz |first1=Sebastian |first2=Scott |last2=West |first3=Kaue |last3=Soares Da Silveira |title=Examining the expert gap in parallel programming |conference=Euro-Par 2013 |url=http://se.inf.ethz.ch/people/west/expert-gap-europar-2013.pdf |citeseerx=10.1.1.368.6137}}</ref>
====Lack of data race safety====
Go's approach to concurrency can be summarized as "don't communicate by sharing memory; share memory by communicating".<ref>{{cite web|title=Share Memory By Communicating|last=Go Authors|url=https://go.dev/doc/codewalk/sharemem/}}</ref> There are no restrictions on how goroutines access shared data, making [[Data race|data races]] possible. Specifically, unless a program explicitly synchronizes via channels or other means, writes from one goroutine might be partly, entirely, or not at all visible to another, often with no guarantees about ordering of writes.<ref name="memmodel" /> Furthermore, Go's ''internal data structures'' like interface values, slice headers, hash tables, and string headers are not immune to data races, so type and memory safety can be violated in multithreaded programs that modify shared instances of those types without synchronization.<ref>{{cite web|last=Cox|first=Russ|author-link=Russ Cox|url=http://research.swtch.com/gorace|title=Off to the Races}}</ref><ref name="SPLASH2012">{{cite web |last=Pike |first=Rob |author-link=Rob Pike |date=October 25, 2012 |title=Go at Google: Language Design in the Service of Software Engineering |url=http://talks.golang.org/2012/splash.article |publisher=Google, Inc.}} "There is one important caveat: Go is not purely memory safe in the presence of concurrency."</ref> Instead of language support, safe concurrent programming thus relies on conventions; for example, Chisnall recommends an idiom called "aliases [[exclusive or|xor]] mutable", meaning that passing a mutable value (or pointer) over a channel signals a transfer of ownership over the value to its receiver.{{r|phrasebook}}{{rp|155}} The gc toolchain has an optional data race detector that can check for unsynchronized access to shared memory during runtime since version 1.1,<ref>{{cite web |title=Introducing the Go Race Detector |url=https://go.dev/blog/race-detector |access-date=26 June 2013 |website=The Go Blog}}</ref> additionally a best-effort race detector is also included by default since version 1.6 of the gc runtime for access to the <code>map</code> data type.<ref>{{Cite web |title=Go 1.6 Release Notes - The Go Programming Language |url=https://go.dev/doc/go1.6 |access-date=2023-11-17 |website=go.dev |language=en}}</ref>
===Binaries===
The linker in the gc toolchain creates statically linked binaries by default; therefore all Go binaries include the Go runtime.<ref>{{Cite web | url=https://golang.org/doc/faq |title = Frequently Asked Questions (FAQ) - the Go Programming Language}}</ref><ref>{{Cite web | url=https://medium.com/@jondot/a-story-of-a-fat-go-binary-20edc6549b97 | title=A Story of a Fat Go Binary| date=September 21, 2018}}</ref>
===Omissions===
Go deliberately omits certain features common in other languages, including [[inheritance (object-oriented programming)|(implementation) inheritance]], [[Assertion (software development)|assertions]],{{efn|Language FAQ "Why does Go not have assertions? ...our experience has been that programmers use them as a crutch to avoid thinking about proper error handling and reporting...."<ref name="langfaq" />}} [[pointer arithmetic]],{{efn|name=noPointerArith|Language FAQ "Why is there no pointer arithmetic? Safety ... never derive an illegal address that succeeds incorrectly ... using array indices can be as efficient as ... pointer arithmetic ... simplify the implementation of the garbage collector...."<ref name="langfaq" />}} [[type conversion#Implicit type conversion|implicit type conversion]]s, [[union type#Untagged unions|untagged union]]s,{{efn|Language FAQ "Why are there no untagged unions...? [they] would violate Go's memory safety guarantees."<ref name="langfaq" />}} and [[tagged union]]s.{{efn|Language FAQ "Why does Go not have variant types? ... We considered [them but] they overlap in confusing ways with interfaces.... [S]ome of what variant types address is already covered, ... although not as elegantly."<ref name="langfaq" /> (The tag of an interface type<ref>{{cite web |url=https://golang.org/ref/spec#Interface_types |title=Go Programming Language Specification, §Interface types|work=The Go Programming Language}}</ref> is accessed with a type assertion<ref>{{cite web |url=https://golang.org/ref/spec#Type_assertion |title=Go Programming Language Specification, §Type assertions|work=The Go Programming Language}}</ref>).}} The designers added only those facilities that all three agreed on.<ref>{{cite interview |url=http://www.informit.com/articles/article.aspx?p=1623555 |website=informIT |title=All Systems Are Go |date=August 17, 2010 |access-date=June 21, 2018}}</ref>
Of the omitted language features, the designers explicitly argue against assertions and pointer arithmetic, while defending the choice to omit type inheritance as giving a more useful language, encouraging instead the use of [[protocol (object-oriented programming)|interfaces]] to achieve [[dynamic dispatch]]{{efn|Questions "How do I get dynamic dispatch of methods?" and "Why is there no type inheritance?" in the language FAQ.<ref name="langfaq" />}} and [[composition over inheritance|composition]] to reuse code. Composition and [[delegation (programming)|delegation]] are in fact largely automated by {{mono|struct}} embedding; according to researchers Schmager ''et al.'', this feature "has many of the drawbacks of inheritance: it affects the public interface of objects, it is not fine-grained (i.e, no method-level control over embedding), methods of embedded objects cannot be hidden, and it is static", making it "not obvious" whether programmers will overuse it to the extent that programmers in other languages are reputed to overuse inheritance.<ref name="gohotdraw">{{cite conference |last1=Schmager |first1=Frank |first2=Nicholas |last2=Cameron |first3=James |last3=Noble |title=GoHotDraw: evaluating the Go programming language with design patterns |conference=Evaluation and Usability of Programming Languages and Tools |publisher=ACM |year=2010}}</ref>
[[Exception handling]] was initially omitted in Go due to lack of a "design that gives value proportionate to the complexity".<ref>{{cite web |title=Language Design FAQ |url=http://golang.org/doc/go_lang_faq.html#absent_features |website= |date=13 November 2009 |archive-url=https://web.archive.org/web/20091113154906/http://golang.org/doc/go_lang_faq.html#absent_features |archive-date=13 November 2009 |url-status=dead}}</ref> An exception-like {{mono|panic}}/{{mono|recover}} mechanism that avoids the usual <code>try-catch</code> control structure was proposed<ref>{{cite web |url=https://groups.google.com/group/golang-nuts/browse_thread/thread/1ce5cd050bb973e4 |title=Proposal for an exception-like mechanism |date=March 25, 2010 |work=golang-nuts |access-date=March 25, 2010}}</ref> and released in the March 30, 2010 snapshot.<ref>{{cite web |url=http://golang.org/doc/devel/weekly.html#2010-03-30 |title=Weekly Snapshot History|work=The Go Programming Language}}</ref> The Go authors advise using it for unrecoverable errors such as those that should halt an entire program or server request, or as a shortcut to propagate errors up the stack within a package.<ref>{{cite web|url=https://code.google.com/p/go-wiki/wiki/PanicAndRecover|title=Panic And Recover|publisher=Go wiki}}</ref><ref>{{cite web |url=https://golang.org/doc/effective_go.html#panic |title=Effective Go |work=The Go Programming Language}}</ref> Across package boundaries, Go includes a canonical error type, and multi-value returns using this type are the standard idiom.<ref name="langfaq" />
==Style==
The Go authors put substantial effort into influencing the style of Go programs:
* Indentation, spacing, and other surface-level details of code are automatically standardized by the <code>gofmt</code> tool. It uses tabs for indentation and blanks for alignment. Alignment assumes that an editor is using a fixed-width font.<ref>{{Cite web|title=gofmt |url=https://golang.org/cmd/gofmt/|access-date=2021-02-05|website=The Go Programming Language}}</ref> <code>golint</code> does additional style checks automatically, but has been deprecated and archived by the Go maintainers.<ref>{{Cite web|title=golang/lint public archive|url=https://github.com/golang/lint|website=github.com|date=November 30, 2022 }}</ref>
* Tools and libraries distributed with Go suggest standard approaches to things like API documentation (<code>godoc</code>),<ref name="eff">{{cite web |url=http://golang.org/doc/effective_go.html |title=Effective Go |work=The Go Programming Language}}</ref> testing (<code>go test</code>), building (<code>go build</code>), package management (<code>go get</code>), and so on.
* Go enforces rules that are recommendations in other languages, for example banning cyclic dependencies, unused variables<ref>{{Cite web|title=Unused local variables|url=https://yourbasic.org/golang/unused-local-variables/|access-date=2021-02-11|website=yourbasic.org|language=en}}</ref> or imports,<ref>{{Cite web|title=Unused package imports|url=https://yourbasic.org/golang/unused-imports/|access-date=2021-02-11|website=yourbasic.org|language=en}}</ref> and implicit type conversions.
* The ''omission'' of certain features (for example, functional-programming shortcuts like <code>map</code> and Java-style <code>try</code>/<code>finally</code> blocks) tends to encourage a particular explicit, concrete, and imperative programming style.
* On day one the Go team published a collection of Go idioms,<ref name="eff" /> and later also collected code review comments,<ref>{{cite web |title=Code Review Comments |website=[[GitHub]] |url=https://github.com/golang/go/wiki/CodeReviewComments |access-date=July 3, 2018}}</ref> talks,<ref>{{cite web |title=Talks |url=https://talks.golang.org/ |access-date=July 3, 2018}}</ref> and official blog posts<ref>{{cite web |title=Errors Are Values |url=http://blog.golang.org/errors-are-values |access-date=July 3, 2018}}</ref> to teach Go style and coding philosophy.
==
The main Go distribution includes tools for [[build automation|building]], [[unit testing|testing]], and [[static program analysis|analyzing]] code:
* <code>go build</code>, which builds Go binaries using only information in the source files themselves, no separate makefiles
* <code>go test</code>, for unit testing and microbenchmarks as well as fuzzing
* <code>go fmt</code>, for formatting code
* <code>go install</code>, for retrieving and installing remote packages
* <code>go vet</code>, a static analyzer looking for potential errors in code
* <code>go run</code>, a shortcut for building and executing code
* <code>go doc</code>, for displaying documentation
* <code>go generate</code>, a standard way to invoke code generators
* <code>go mod</code>, for creating a new module, adding dependencies, upgrading dependencies, etc.
* <code>go tool</code>, for invoking developer tools (added in Go version 1.24)
It also includes [[profiling (computer programming)|profiling]] and [[debugging]] support, [[fuzzing]] capabilities to detect bugs, [[Run time (program lifecycle phase)|runtime]] instrumentation (for example, to track [[Garbage collection (computer science)|garbage collection]] pauses), and a [[data race]] detector.
Another tool maintained by the Go team but is not included in Go distributions is <code>gopls</code>, a language server that provides [[Integrated development environment|IDE]] features such as [[intelligent code completion]] to [[Language Server Protocol]] compatible editors.<ref>{{Cite web |title=tools/gopls/README.md at master · golang/tools |url=https://github.com/golang/tools/blob/master/gopls/README.md |access-date=2023-11-17 |website=GitHub |language=en}}</ref>
An ecosystem of third-party tools adds to the standard distribution, such as <code>gocode</code>, which enables code autocompletion in many text editors, <code>goimports</code>, which automatically adds/removes package imports as needed, and <code>errcheck</code>, which detects code that might unintentionally ignore errors.
==Examples==
===Hello world===
<syntaxhighlight lang="go">
package main
Line 174 ⟶ 291:
func main() {
fmt.Println("
}
</syntaxhighlight>
where "fmt" is the package for ''formatted [[Input/output|I/O]]'', similar to C's [[C file input/output]].<ref>{{Cite web|url=https://golang.org/pkg/fmt/|title=fmt |website=The Go Programming Language|access-date=2019-04-08}}</ref>
==={{anchor|Concurrencyexample}}Concurrency===
The following simple program demonstrates Go's [[#Concurrency|concurrency feature]]s to implement an asynchronous program. It launches two lightweight threads ("goroutines"): one waits for the user to type some text, while the other implements a timeout. The {{mono|select}} statement waits for either of these goroutines to send a message to the main routine, and acts on the first message to arrive (example adapted from David Chisnall's book).<ref name="phrasebook">{{cite book |title=The Go Programming Language Phrasebook |first=David |last=Chisnall |publisher=Addison-Wesley |year=2012 |isbn=9780132919005 |url=https://books.google.com/books?id=scyH562VXZUC}}</ref>{{rp|152}}
<syntaxhighlight lang="go">
Line 187 ⟶ 304:
import (
"fmt"
"
)
func readword(ch chan string) {
fmt.Println("Type a word, then hit Enter.")
var word string
fmt.Scanf("%s", &word)
ch <- word
}
func timeout(t chan bool) {
time.Sleep(5 * time.Second)
t <- false
}
func main() {
go timeout(t)
case word :=
fmt.Println("Received", word)
case <-t:
fmt.Println("Timeout.")
}
}
</syntaxhighlight>
==
The testing package provides support for automated testing of go packages.<ref>{{Cite web|title=testing |url=https://golang.org/pkg/testing/|access-date=2020-12-27|website=The Go Programming Language}}</ref> Target function example:
<syntaxhighlight lang="go">
func ExtractUsername(email string) string {
at := strings.Index(email, "@")
return email[:at]
}
</syntaxhighlight>
Test code (note that '''assert''' keyword is missing in Go; tests live in <filename>_test.go at the same package):
<syntaxhighlight lang="go">
import (
"testing"
)
func TestExtractUsername(t *testing.T) {
t.Run("withoutDot", func(t *testing.T) {
username := ExtractUsername("r@google.com")
if username != "r" {
t.Fatalf("Got: %v\n", username)
}
})
t.Run("withDot", func(t *testing.T) {
username := ExtractUsername("jonh.smith@example.com")
if username != "jonh.smith" {
t.Fatalf("Got: %v\n", username)
}
})
}
</syntaxhighlight>
It is possible to run tests in parallel.
===Web app===
The [https://pkg.go.dev/net/http net/http]<ref>{{Cite web |title=http package - net/http - Go Packages |url=https://pkg.go.dev/net/http |access-date=2024-11-23 |website=pkg.go.dev}}</ref> package provides support for creating web applications.
This example would show "Hello world!" when localhost:8080 is visited.
<syntaxhighlight lang="go">
package main
import (
"fmt"
"log"
"net/http"
)
func helloFunc(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello world!")
}
func main() {
http.HandleFunc("/", helloFunc)
log.Fatal(http.ListenAndServe(":8080", nil))
}
</syntaxhighlight>
== Applications ==
Go has found widespread adoption in various domains due to its robust standard library and ease of use.<ref name="code-mag-2022-11-24">{{cite magazine|last=Lee|first=Wei-Meng|url=https://www.codemag.com/Article/2011051/Introduction-to-the-Go-Programming-Language|magazine=[[Component Developer Magazine]]|archive-url=https://web.archive.org/web/20230605071554/https://www.codemag.com/Article/2011051/Introduction-to-the-Go-Programming-Language|date=24 November 2022|title=Introduction to the Go Programming Language|archive-date=5 June 2023|access-date=8 September 2023}}</ref>
Popular applications include: [[Caddy (web server)|Caddy]], a web server that automates the process of setting up HTTPS,<ref name="linuxmag-213-2018">{{cite magazine |last1=Hoffmann |first1=Frank |last2=Neumeyer |first2=Mandy |url=https://www.linux-magazine.com/Issues/2018/213/Caddy |title=Simply Secure |magazine=[[Linux Magazine]] |date=August 2018 |issue=213 |archive-url=https://web.archive.org/web/20230528175545/https://www.linux-magazine.com/Issues/2018/213/Caddy |archive-date=2023-05-28 |access-date=8 September 2023}}</ref> [[Docker (software)|Docker]], which provides a platform for containerization, aiming to ease the complexities of software development and deployment,<ref name="codemag-20220831">{{cite magazine |last=Lee |first=Wei-Meng |url=https://www.codemag.com/Article/2103061/Introduction-to-Containerization-Using-Docker |title=Introduction to Containerization Using Docker |magazine=[[Component Developer Magazine|CODE Magazine]] |date=31 August 2022 |archive-url=https://web.archive.org/web/20230530073551/https://www.codemag.com/Article/2103061/Introduction-to-Containerization-Using-Docker |archive-date=30 May 2023 |url-status=live |access-date=8 September 2023}}</ref> [[Kubernetes]], which automates the deployment, scaling, and management of containerized applications,<ref name="codemag-20230224">{{cite magazine |last=Pirker |first=Alexander |url=https://www.codemag.com/Article/2303071/Kubernetes-Security-for-Starters |title=Kubernetes Security for Starters |magazine=[[Component Developer Magazine|CODE Magazine]] |date=24 February 2023 |archive-url=https://web.archive.org/web/20230401212416/https://codemag.com/Article/2303071/Kubernetes-Security-for-Starters |archive-date=1 April 2023 |url-status=live |access-date=8 September 2023}}</ref> [[CockroachDB]], a distributed SQL database engineered for scalability and strong consistency,<ref name="sigmod20-cockroach">{{cite conference |last1=Taft |first1=Rebecca |last2=Sharif |first2=Irfan |last3=Matei |first3=Andrei |last4=Van Benschoten |first4=Nathan |last5=Lewis |first5=Jordan |last6=Grieger |first6=Tobias |last7=Niemi |first7=Kai |last8=Woods |first8= Andy |last9=Birzin |first9=Anne |last10=Poss |first10=Raphael |last11=Bardea |first11=Paul |last12=Ranade |first12=Amruta |last13=Darnell |first13=Ben |last14=Gruneir |first14=Bram |last15=Jaffray |first15=Justin |last16=Zhang |first16=Lucy |last17=Mattis |first17=Peter |doi=10.1145/3318464.3386134 |title=Proceedings of the 2020 ACM SIGMOD International Conference on Management of Data |isbn=978-1-4503-6735-6 |article=CockroachDB: The Resilient Geo-Distributed SQL Database |conference=[[SIGMOD]] '20 |date=11 June 2020 |pages=1493–1509 |doi-access=free }}</ref> and [[Hugo (software)|Hugo]], a static site generator that prioritizes speed and flexibility, allowing developers to create websites efficiently.<ref name="linuxjournal-20220913">{{cite news |last=Hopkins |first=Brandon |url=https://www.linuxjournal.com/content/static-site-generation-hugo |title=Static Site Generation with Hugo |work=Linux Journal |date=13 September 2022 |archive-url=https://web.archive.org/web/20230408065506/https://www.linuxjournal.com/content/static-site-generation-hugo |archive-date=8 April 2023 |url-status=live |access-date=8 September 2023}}</ref>
==Reception==
The interface system, and the deliberate omission of inheritance, were praised by Michele Simionato, who likened these characteristics to those of [[Standard ML]], calling it "a shame that no popular language has followed [this] particular route".<ref>{{cite news |url=http://www.artima.com/weblogs/viewpost.jsp?thread=274019 |title=Interfaces vs Inheritance (or, watch out for Go!) |last= Simionato |first=Michele |date=November 15, 2009 |publisher=artima |access-date=November 15, 2009}}</ref>
Dave Astels at [[Engine Yard]] wrote in 2009:<ref>{{cite news|url=https://www.engineyard.com/blog/ready-set-go|title=Ready, Set, Go!|last=Astels|first=Dave|date=November 9, 2009|access-date=November 9, 2009|publisher=engineyard|archive-date=October 19, 2018|archive-url=https://web.archive.org/web/20181019164102/https://www.engineyard.com/blog/ready-set-go|url-status=dead}}</ref>
{{blockquote |Go is extremely easy to dive into. There are a minimal number of fundamental language concepts and the [[syntax (programming languages)|syntax]] is clean and designed to be clear and unambiguous.
Go ''is'' still experimental and still a little rough around the edges.|sign=|source=}}
Go was named Programming Language of the Year by the [[TIOBE Programming Community Index]] in its first year, 2009, for having a larger 12-month increase in popularity (in only 2 months, after its introduction in November) than any other language that year, and reached 13th place by January 2010,<ref>{{cite web |author=jt |title=Google's Go Wins Programming Language Of The Year Award |date=January 11, 2010 |url=http://jaxenter.com/google-s-go-wins-programming-language-of-the-year-award-10069.html |publisher=jaxenter |access-date=December 5, 2012}}</ref> surpassing established languages like [[Pascal (programming language)|Pascal]]. By June 2015, its ranking had dropped to below 50th in the index, placing it lower than [[COBOL]] and [[Fortran]].<ref>{{cite web |url=http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html |title=TIOBE Programming Community Index for June 2015 |date=June 2015 |publisher=TIOBE Software |access-date=July 5, 2015}}</ref> But as of January 2017, its ranking had surged to 13th, indicating significant growth in popularity and adoption. Go was again awarded TIOBE Programming Language of the Year in 2016.<ref>{{Cite web |title=TIOBE Index |url=https://www.tiobe.com/tiobe-index/ |access-date=2024-07-15 |website=TIOBE |language=en-US}}</ref>
[[Bruce Eckel]] has stated:<ref>{{cite web |url=http://www.artima.com/weblogs/viewpost.jsp?thread=333589 |title=Calling Go from Python via JSON-RPC |date=August 27, 2011 |last=Eckel |first=Bruce |access-date=August 29, 2011}}</ref>
{{blockquote|The complexity of [[C++]] (even more complexity has been added in the new C++), and the resulting impact on productivity, is no longer justified. All the hoops that the C++ programmer had to jump through in order to use a C-compatible language make no sense anymore -- they're just a waste of time and effort. Go makes much more sense for the class of problems that C++ was originally intended to solve.}}
A 2011 evaluation of the language and its {{mono|gc}} implementation in comparison to C++ ([[GNU Compiler Collection|GCC]]), Java and [[Scala (programming language)|Scala]] by a Google engineer found:
{{blockquote|Go offers interesting language features, which also allow for a concise and standardized notation. The compilers for this language are still immature, which reflects in both performance and binary sizes.|R. Hundt<ref>{{cite conference |last=Hundt |first=Robert |title=Loop recognition in C++/Java/Go/Scala |conference=Scala Days |year=2011 |url=https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf}}</ref>}}
The evaluation got a rebuttal from the Go development team. Ian Lance Taylor, who had improved the Go code for Hundt's paper, had not been aware of the intention to publish his code, and says that his version was "never intended to be an example of idiomatic or efficient Go"; Russ Cox then optimized the Go code, as well as the C++ code, and got the Go code to run almost as fast as the C++ version and more than an order of magnitude faster than the code in the paper.<ref>{{cite web |title=Google Go strikes back with C++ bake-off |first=Cade |last=Metz |date=July 1, 2011 |website=[[The Register]] |url=https://www.theregister.co.uk/2011/07/01/go_v_cpluplus_redux/}}</ref>
* Go's ''[[null pointer|nil]]'' combined with the lack of [[algebraic types]] leads to difficulty handling failures and [[Base case (recursion)|base case]]s.<ref name="yager">{{cite web | first = Will | last = Yager | url = http://yager.io/programming/go.html | title = Why Go is not Good | access-date = 4 November 2018}}</ref><ref name="dobronszki">{{cite web | first = Janos | last = Dobronszki | url = https://crufter.com/everyday-hassles-in-go | title = Everyday Hassles in Go | access-date = 4 November 2018}}</ref>
* Go does not allow an opening brace to appear on its own line, which forces all Go programmers to use the same brace style.<ref>{{cite web|title=Why are there braces but no semicolons? And why can't I put the opening brace on the next line?|quote=The advantages of a single, programmatically mandated format for all Go programs greatly outweigh any perceived disadvantages of the particular style.|url=https://golang.org/doc/faq#semicolons|access-date=March 26, 2020}}</ref>
* Go has been criticized for focusing on simplicity of implementation rather than correctness and flexibility; as an example, the language uses [[POSIX]] file semantics on all platforms, and therefore provides incorrect information on platforms such as [[Microsoft Windows|Windows]] (which do not follow the aforementioned standard).<ref>{{cite web|title=I want off Mr. Golang's Wild Ride|url=https://fasterthanli.me/articles/i-want-off-mr-golangs-wild-ride|date=February 28, 2020|access-date=November 17, 2020}}</ref><ref>{{cite web|title=proposal: os: Create/Open/OpenFile() set FILE_SHARE_DELETE on windows #32088|website=[[GitHub]]|url=https://github.com/golang/go/issues/32088|date=May 16, 2019|access-date=November 17, 2020}}</ref>
* A study showed that it is as easy to make concurrency bugs with message passing as with shared memory, sometimes even more.<ref>{{Cite web|last=Tu|first=Tengfei|date=2019|title=Understanding Real-World Concurrency Bugs in Go|url=https://songlh.github.io/paper/go-study.pdf|quote=For example, around 58% of blocking bugs are caused by message passing. In addition to the violation of Go's channel usage rules (e.g., waiting on a channel that no one sends data to or close), many concurrency bugs are caused by the mixed usage of message passing and other new semantics and new libraries in Go, which can easily be overlooked but hard to detect}}</ref>
==Naming dispute==
On November 10, 2009, the day of the general release of the language, Francis McCabe, developer of the [[Go! (programming language)|Go! programming language]] (note the
On October 12, 2010, the filed public issue ticket was closed by Google developer Russ Cox (@rsc) with the custom status "Unfortunate" accompanied by the following comment: <blockquote>"There are many computing products and services named Go. In the 11 months since our release, there has been minimal confusion of the two languages."<ref name="issue9"/></blockquote>
==See also==
{{Portal|Free and open-source software}}
* [[Fat pointer]]
* [[Comparison of programming languages]]
==Notes==
{{
==References==
{{
{{Reflist
==Further reading==
{{Refbegin}}
* {{Cite book
| first1 = Alan
| last1 = Donovan
| first2 = Brian
| last2 = Kernighan
| date = October 2015
| title = The Go Programming Language
| publisher = [[Addison-Wesley Professional]]
| edition = 1st
| pages = 400
| isbn = 978-0-13-419044-0
| url = https://www.informit.com/store/go-programming-language-9780134190440
}}
* {{Cite book
| first1 = Jon
| last1 = Bodner
| date = March 2021
| title = Learning Go
| publisher = [[O'Reilly Media|O'Reilly]]
| edition = 1st
| pages = 352
| isbn = 9781492077213
| url = https://www.oreilly.com/library/view/learning-go/9781492077206/
}}
{{Refend}}
==External links==
{{Commons category|Go (programming language)}}
* {{Official website}}
{{Prone to spam|date=June 2013}}<!-- {{No more links}}
Please be cautious adding more external links.
Line 320 ⟶ 489:
-->
{{Programming languages}}
{{Google FOSS}}
{{Rob Pike navbox}}
{{Ken Thompson navbox}}
{{Authority control}}
[[Category:Go (programming language)| ]]
[[Category:American inventions]]
[[Category:C programming language family]]
[[Category:Concurrent programming languages]]
[[Category:Cross-platform free software]]
[[Category:Cross-platform software]]
[[Category:Free and open source compilers]]
[[Category:Google software]]
[[Category:High-level programming languages]]
[[Category:Procedural programming languages]]
[[Category:
[[Category:Programming languages created in 2009]]
[[Category:Software using the BSD license]]
[[Category:
[[Category:Systems programming languages]]
|