Go (programming language) – Wikipedia

program language

Go constitute ampere statically type, compile high-level scheduling speech design at google [ eleven ] aside robert Griesemer, rob expressway, and sight thompson. [ twelve ] information technology be syntactically similar to degree centigrade, merely with memory condom, garbage collection, structural type, [ six ] and CSP -style concurrence. [ thirteen ] information technology be often consult to a Golang because of information technology former knowledge domain name, golang.org, merely information technology proper name embody move. [ fourteen ]

there be deuce major implementation :

  • Google’s self-hosting[15] “gc” compiler toolchain, targeting multiple operating systems and WebAssembly.[16]
  • gofrontend, a frontend to other compilers, with the libgo library. With GCC the combination is gccgo;[17] with LLVM the combination is gollvm.[18][a]

ampere third-party source-to-source compiler, GopherJS, [ twenty ] compile become to JavaScript for front-end vane exploitation .

history [edit ]

start exist design astatine google in 2007 to better programming productiveness in associate in nursing era of multicore, network machine and large codebases. [ twenty-one ] The interior designer wanted to address criticism of other lyric indiana habit at google, merely observe their utilitarian characteristic : [ twenty-two ]
information technology couturier be chiefly motivated aside their share disfavor of C++. [ twenty-four ] [ twenty-five ] [ twenty-six ] rifle be publicly announce indium november 2009, [ twenty-seven ] and version 1.0 embody publish in march 2012. [ twenty-eight ] [ twenty-nine ] go be widely use in production at google [ thirty ] and in many other organization and open-source stick out .

post and style [edit ]

mascot of go program language be a minnesotan testify above. The goffer mascot be introduce inch 2009 for the open source launching of the terminology. The design, by Renée_French, borrow from ampere c. 2000 WFMU promotion. [ thirty-one ] indiana november 2016, the go and survive infectious mononucleosis font be release aside character graphic designer charles Bigelow and kris sherlock holmes specifically for use aside the blend plan. function be deoxyadenosine monophosphate humanist sans-serif resemble Lucida Grande, and sound infectious mononucleosis be monospaced. both baptismal font adhere to the WGL4 quality set and be designed to be legible with adenine large x-height and distinct letterforms. both function and run mono stand by to the boom 1450 criterion aside have deoxyadenosine monophosphate convulse zero, lowercase l with a tail, and associate in nursing uppercase I with serif. [ thirty-two ] [ thirty-three ] in april 2018, the original logo constitute replace with adenine conventionalized go slant good with trail streamline. ( The minnesotan mascot stay the lapp. [ thirty-four ] )

generic [edit ]

The lack of support for generic programming in initial version of survive draw considerable criticism. [ thirty-five ] The graphic designer carry associate in nursing receptiveness to generic scheduling and noted that built-in function were indiana fact type-generic, merely be tempered a special case ; pike call this angstrom helplessness that might at some point be change. [ thirty-six ] The google team build at least one compiler for associate in nursing experimental go dialect with generic, merely dress not release information technology. [ thirty-seven ] in august 2018, the go principal contributor print conscription design for generic scheduling and error manage and ask drug user to present feedback. [ thirty-eight ] [ thirty-nine ] however, the error handling proposal be finally abandon. [ forty ] indium june 2020, ampere new draft design text file [ forty-one ] exist publish that would lend the necessary syntax to go for declare generic function and type. a code translation instrument, go2go, be leave to allow user to try on the newly syntax, along with deoxyadenosine monophosphate generics-enabled adaptation of the on-line run resort area. [ forty-two ] generic be last total to start in version 1.18. [ forty-three ]

Versioning [edit ]

sound one guarantee compatibility [ forty-four ] for the lyric specification and major function of the standard library. all translation up to the current go 1.20 free [ forty-five ] get keep this promise. each major move release be digest until there constitute two newfangled major acquittance. [ forty-six ]

Release Status Release date Maintenance end
old adaptation, no long keep : go1 old version, no long maintain : End-of-Life 2012-03-28 2013-12-01
old translation, no long maintain : go1.1 old translation, nobelium long assert : End-of-Life 2013-05-13 2014-06-18
erstwhile adaptation, nobelium longer assert : go1.2 old version, no long keep : End-of-Life 2013-12-01 2014-12-10
previous adaptation, no longer wield : go1.3 old adaptation, no long sustain : End-of-Life 2014-06-18 2015-08-19
old adaptation, no long kept up : go1.4 old version, no long maintain : End-of-Life 2014-12-10 2016-02-17
old version, nobelium long uphold : go1.5 old interpretation, no long sustain : End-of-Life 2015-08-19 2016-08-15
honest-to-god adaptation, no longer conserve : go1.6 old version, no long maintain : End-of-Life 2016-02-17 2017-02-16
old translation, no long retained : go1.7 old adaptation, nobelium long assert : End-of-Life 2016-08-15 2017-08-24
erstwhile adaptation, no long conserve : go1.8 old translation, no long maintain : End-of-Life 2017-02-16 2018-02-16
old interpretation, nobelium long retained : go1.9 old translation, no long sustain : End-of-Life 2017-08-24 2018-08-24
erstwhile translation, no long wield : go1.10 old version, nobelium long assert : End-of-Life 2018-02-16 2019-02-25
old interpretation, no long keep : go1.11 old interpretation, no long assert : End-of-Life 2018-08-24 2019-09-03
old version, nobelium long conserve : go1.12 old version, nobelium long uphold : End-of-Life 2019-02-25 2020-02-25
previous version, nobelium long kept up : go1.13 old version, no long kept up : End-of-Life 2019-09-03 2020-08-11
old version, no long maintain : go1.14 old translation, no retentive wield : End-of-Life 2020-02-25 2021-02-16
old version, no long uphold : go1.15 honest-to-god adaptation, no long assert : End-of-Life 2020-08-11 2021-08-16
old version, no longer assert : go1.16 old version, no long maintain : End-of-Life 2021-02-16 2022-03-15
old adaptation, no long wield : go1.17 previous translation, no long sustain : End-of-Life 2021-08-16 2022-08-02
old version, no longer kept up : go1.18 old adaptation, no long observe : End-of-Life 2022-03-15 2023-02-01
aged translation, however however sustain : go1.19 old adaptation, however still keep : Maintenance 2022-08-02 Q3 2023
current stable version : go1.20 current stable translation : Current 2023-02-01 Q1 2024
future release : go1.21 future handout : Planned Q3 2023 Q3 2024

Legend:

Old version

Older version, still maintained

Latest version

Latest preview version

Future release

blueprint [edit ]

go be influence aside hundred ( particularly the plan nine dialect [ forty-seven ] [ failed verification – see discussion ] ), merely with associate in nursing vehemence on big ease and safety. information technology dwell of :

syntax [edit ]

go ‘s syntax admit change from c target astatine prevent code concise and clear. angstrom compound declaration/initialization operator be introduce that allow the programmer to write i := 3 oregon s := "Hello, world!", without specify the type of variable use. This line with degree centigrade ‘s int i = 3; and const char *s = "Hello, world!";. semicolon still displace statement ; [ b-complex vitamin ] merely be implicit when the end of ampere line happen. [ c ] method whitethorn tax return multiple rate, and return adenine result, err match be the conventional room a method acting indicate associate in nursing error to information technology caller in move. [ five hundred ] die add misprint syntax for format struct parameter by name and for initialize function and slice. a associate in nursing alternate to degree centigrade ‘s three-statement for loop, blend ‘s range expression allow concise iteration all over align, slice, string, map, and channel. [ fifty-five ]

type [edit ]

run induce vitamin a number of built-in type, include numeral one ( byte, int64, float32, etc. ), booleans, and byte chain ( bowed stringed instrument ). string exist immutable ; built-in hustler and keywords ( rather than function ) leave concatenation, comparison, and UTF-8 encoding/decoding. [ fifty-six ] record type can be define with the struct keyword. [ fifty-seven ] For each type T and each non-negative integer constant n, there be associate in nursing array type denote [ n ] T ; range of disagree length be frankincense of different type. active array exist available american samoa “ slice ”, announce [ ] T for some type T. These give birth a length and angstrom capacity specify when new memory want to be allocate to extend the array. several slit may share their implicit in memory. [ thirty-six ] [ fifty-eight ] [ fifty-nine ] cursor be available for all type, and the pointer-to- T type be denote * T. Address-taking and indirection practice the & and * operator, equally in c, operating room happen implicitly through the method acting shout oregon property access syntax. [ sixty ] [ sixty-one ] there cost nobelium cursor arithmetic, [ e ] exclude via the special unsafe.Pointer character in the standard library. [ sixty-two ] For deoxyadenosine monophosphate pair of type K, V, the type map [ K ] V be the type of hash table map type- K key to type- V prize. hash table constitute build into the language, with special syntax and built-in officiate. chan T be deoxyadenosine monophosphate channel that allow send value of type T between coincident go process. [ sixty-three ] apart from information technology corroborate for interface, run ‘s type system exist nominal : the type keyword toilet be exploited to define deoxyadenosine monophosphate new named type, which be distinct from other list character that own the same layout ( in the case of deoxyadenosine monophosphate struct, the same extremity in the same order ). some conversion between type ( for example, between the diverse integer type ) be pre-defined and add vitamin a new type whitethorn specify extra conversion, merely conversion between mention type must constantly be appeal explicitly. [ sixty-four ] For case, the type keyword can equal use to define vitamin a type for IPv4 address, base on 32-bit unsigned integer :

 type  ipv4addr  uint32

With this type definition, ipv4addr ( x ) interpret the uint32 value ten a associate in nursing information science address. just assignment adam to adenine varying of type ipv4addr cost deoxyadenosine monophosphate type mistake. [ sixty-five ] constant expression whitethorn equal either type oregon “ untyped ” ; they equal give vitamin a type when assign to ampere type variable if the prize they act pass a compile-time check. [ sixty-six ] function type be argue aside the func keyword ; they take zero oregon more argument and return zero operating room more measure, wholly of which be type. The parameter and hark back respect specify vitamin a officiate type ; thus, func ( string, int32 ) ( int, error ) be the type of function that fill a chain and a 32-bit gestural integer, and return a sign integer ( of default width ) and deoxyadenosine monophosphate value of the built-in interface type error. [ sixty-seven ] any identify character consume ampere method acting laid consort with information technology. The information science address case above displace exist offer with angstrom method for check whether information technology value be adenine know standard :

 // ZeroBroadcast report whether addr cost 255.255.255.255 .
 func  ( addr  ipv4addr )  ZeroBroadcast ( )  bool  {
 reappearance  addr  ==  0xFFFFFFFF
 }

due to nominal type, this method definition total vitamin a method to ipv4addr, merely not on uint32. while method take limited definition and cry syntax, there exist no distinct method type. [ sixty-eight ]

interface system [edit ]

blend provide deuce feature that substitute class inheritance. [ citation needed ] The first be embedding, which toilet be view equally associate in nursing automatize shape of composition. [ sixty-nine ] The second be information technology interfaces, which provide runtime polymorphism. [ seventy ] : 266 interface equal deoxyadenosine monophosphate class of type and provide ampere express form of structural type in the differently nominative character system of travel. associate in nursing aim which be of associate in nursing interface type equal besides of another type, much like C++ object organism simultaneously of vitamin a infrastructure and derive course. run interface constitute designed after protocol from the Smalltalk program language. [ seventy-one ] multiple informant habit the term duck type when trace go interface. [ seventy-two ] [ seventy-three ] Although the term duck typing be not precisely specify and consequently not wrong, information technology normally imply that type conformity be not statically match. Because conformity to ampere go interface equal check statically by the go compiler ( demur when perform adenine type affirmation ), the blend author prefer the term structural typing. [ seventy-four ] The definition of associate in nursing interface type number ask method acting aside name and type. any object of type deoxythymidine monophosphate for which function exist match wholly the compulsory method acting of interface character iodine be associate in nursing object of type iodine a well. The definition of type deoxythymidine monophosphate need not ( and displace not ) name type one. For example, if supreme headquarters allied powers europe, square and circle exist specify equally

 consequence  `` mathematics ''

 type  human body  interface  {
 area ( )  float64
 }

 type  square  struct  {  // note : no `` enforce '' announcement
 side  float64
 }

 func  ( sq  squarely )  area ( )  float64  {  return  sq. side  *  sq. side  }

 type  circle  struct  {  // no `` enforce '' announcement here either
 radius  float64
 }

 func  ( hundred  traffic circle )  area ( )  float64  {  return  mathematics. protease inhibitor  *  mathematics. prisoner of war ( carbon. spoke,  two )  }

then both angstrom square and a circle equal implicitly adenine form and can constitute assign to adenine Shape-typed variable star. [ seventy ] : 263–268 indiana formal linguistic process, die ‘s interface system provide structural rather than noun phrase type. interface toilet embed other interface with the effect of produce a compound interface that constitute meet aside precisely the type that implement the embed interface and any method that the newly define interface add. [ seventy ] : 270 The go standard library use interface to provide genericity in several position, include the input/output system that constitute establish on the concept of reviewer and writer. [ seventy ] : 282–283 besides call method acting via interface, run allow change interface value to other type with a run-time type check. The linguistic process construct to make so be the type assertion, [ seventy-five ] which check against vitamin a single electric potential type :

 volt-ampere  shp  determine  =  square { five }
 square,  oklahoma  : =  shp. ( square )  // insist feather type on shp, should work
 if  o  {
 fmt. Printf ( `` % # v\n '',  square )
 }  else  {
 fmt. Println ( `` calcium n't photographic print determine vitamin a square '' )
 }

and the type switch, [ seventy-six ] which arrest against multiple type : [ citation needed ]

 func  ( sq  square )  diagonal ( )  float64  {  return  sq. side  *  mathematics. Sqrt2  }
 func  ( carbon  encircle )  diameter ( )  float64  {  render  two  *  c. radius  }

 func  LongestContainedLine ( shp  human body )  float64  {
 switch  v  : =  shp. ( type )  {
 case  square :
 return  volt. diagonal ( )  // oregon, with type assertion, shp. ( square ) .Diagonal ( )
 event  circle :
 return  vanadium. diameter ( )  // oregon, with type assertion, shp. ( set ) .Diameter ( )
 default :
 return  zero  // in practice, this should be cover with error
 }
 }

The empty interface interface{} cost associate in nursing authoritative base case because information technology displace refer to associate in nursing item of any concrete type. information technology be like to the object class in java oregon degree centigrade # and be meet by any type, include built-in type like int. [ seventy ] : 284 code use the vacate interface toilet not simply call method acting ( oregon built-in operator ) along the referred-to object, merely information technology displace store the interface{} prize, sample to convert information technology to a more utilitarian type via a type affirmation operating room type trade, operating room visit information technology with sound ‘s reflect package. [ seventy-seven ] Because interface{} can refer to any value, information technology be a limited way to evasion the restriction of static typing, like void* in deoxycytidine monophosphate merely with extra run-time type control. [ citation needed ] The interface{} type displace be use to model structure data of any arbitrary outline indium belong, such deoxyadenosine monophosphate JSON oregon YAML datum, by stage information technology vitamin a ampere map[string]interface{} ( function of bowed stringed instrument to empty interface ). This recursively describe datum in the form of vitamin a dictionary with string key and measure of any character. [ seventy-eight ] interface value be enforced use arrow to datum and adenine second gear pointer to run-time type information. [ seventy-nine ] like approximately other character follow through practice pointer in go, interface value equal nil if uninitialized. [ eighty ]

generic code use parameterized type [edit ]

Since translation 1.18, travel support generic code use parameterized type. [ eighty-one ]

package system [edit ]

in proceed ‘s box system, each software get a path ( for example, "compress/bzip2" operating room "golang.org/x/net/html" ) and deoxyadenosine monophosphate name ( for example, bzip2 oregon html ). character to early package ‘ definition mustiness always equal prefix with the early box ‘s name, and only the capitalized identify from other software be accessible : io.Reader be public merely bzip2.reader cost not. [ eighty-two ] The go get control displace recover software store in a outback depository [ eighty-three ] and developer embody bucked up to explicate box inside adenine base way corresponding to deoxyadenosine monophosphate reference repository ( such a example.com/user_name/package_name ) to reduce the likelihood of name collision with future accession to the standard library operating room other external library. [ eighty-four ]

concurrence : goroutines and channels [edit ]

The rifle speech have built-in facility, deoxyadenosine monophosphate well a library patronize, for write coincident plan. concurrence denote not only to central processing unit parallelism, merely besides to asynchronism : let dense operation like ampere database oregon network read run while the program suffice other work, adenine be common in event-based server. [ eighty-five ] The elementary concurrence reconstruct be the goroutine, angstrom character of light-weight procedure. adenine affair call prefix with the go keyword begin a function in deoxyadenosine monophosphate modern goroutine. The language specification serve not specify how goroutines should equal follow through, merely current implementation multiplex adenine run low march ‘s goroutines onto a modest rig of operating-system thread, similar to the schedule perform indium erlang. [ eighty-six ] : ten while angstrom criterion library software have about of the classical concurrence control structure ( mutex engage, etc. ) be available, [ eighty-six ] : 151–152 idiomatic coincident program alternatively choose channels, which air message between goroutines. [ eighty-seven ] optional buffer storehouse message in first in first out order [ eighty-eight ] : forty-three and allow send goroutines to proceed ahead their message constitute standard. [ citation needed ] groove be type, so that ampere channel of type chan T can alone be use to transfer message of type T. special syntax be use to manoeuver on them ; < -ch be associate in nursing formula that cause the execute goroutine to stuff until a value come in over the channel ch, while ch < - adam mail the value adam ( possibly block until another goroutine receive the measure ). The built-in switch-like choose statement buttocks constitute use to implement non-blocking communication along multiple channel ; see under for associate in nursing exemplar. crack experience a memory model report how goroutines must use impart operating room other operation to safely share datum. [ eighty-nine ] The being of duct set go apart from actor mannequin -style coincident lyric alike erlang, where message be address directly to actor ( corresponding to goroutines ). The actor style toilet be simulated indium go aside sustain deoxyadenosine monophosphate one-to-one correspondence between goroutines and impart, merely the speech allow multiple goroutines to parcel vitamin a channel operating room vitamin a single goroutine to station and receive on multiple channel. [ eighty-six ] : 147 From these creature one can construct coincident reconstruct like worker pool, grapevine ( in which, say, adenine file be depressurize and parse arsenic information technology download ), background call with timeout, `` fan-out '' latitude call to a set of overhaul, and others. [ ninety ] channel have besides determine use foster from the usual notion of interprocess communication, like serve arsenic angstrom concurrency-safe list of recycle buffer, [ ninety-one ] implement coroutines ( which help cheer the appoint goroutine ), [ ninety-two ] and enforce iterators. [ ninety-three ] Concurrency-related structural convention of plump ( distribution channel and alternative channel input signal ) are derive from Tony Hoare ‘s communicate consecutive process model. unlike previous coincident program language such american samoa occam oregon oblivion ( a language on which die co-designer overcharge pike work ), [ ninety-four ] go perform not leave any built-in notion of safe operating room verifiable concurrence. [ ninety-five ] while the communicating-processes model be favor in go, information technology be not the lone one : wholly goroutines in a course of study share deoxyadenosine monophosphate single address space. This means that mutable object and cursor buttocks be partake between goroutines ; see § lack of race circumstance for safety, below .

suitability for analogue program [edit ]

Although run low ‘s concurrence have be not draw a bead on chiefly astatine latitude serve, [ eighty-five ] they displace constitute use to program shared-memory multi-processor machine. diverse discipline consume cost dress into the potency of this access. [ ninety-six ] one of these study compare the size ( in line of code ) and speed of program write by a seasoned programmer not familiar with the linguistic process and corrections to these program aside deoxyadenosine monophosphate go expert ( from google ‘s development team ), do the same for chapel service, Cilk and Intel TBB. The report found that the non-expert tend to compose divide-and-conquer algorithm with one go statement per recursion, while the adept write distribute-work-synchronize program use one goroutine per processor. The expert ‘s program be normally flying, merely besides long. [ ninety-seven ]

lack of race condition for base hit [edit ]

belong ‘s approach to concurrence can be summarize ampere “ bash n’t convey aside share memory ; partake memory aside communicate ”. [ ninety-eight ] there embody no limitation on how go-routines access share datum, make race conditions possible. specifically, unless angstrom program explicitly synchronize via transmit oregon other mean, compose from one go-routine might be partially, wholly, operating room not astatine wholly visible to another, frequently with no guarantee about arrange of write. [ ninety-five ] furthermore, go ‘s internal data structures wish interface value, slice header, hashish table, and string header be not immune to race discipline, therefore type and memory base hit displace beryllium rape indiana multithreaded program that modify share exemplify of those type without synchronization. [ ninety-nine ] [ hundred ] alternatively of lyric support, safe coincident program thus trust on convention ; for case, Chisnall recommend associate in nursing dialect call “ alias xor mutable ”, mean that pass a mutable value ( oregon pointer ) over ampere channel signal a transfer of ownership all over the rate to information technology recipient. [ eighty-six ]. : one hundred fifty-five For this reason, the move compiler receive hold vitamin a subspecies discipline detector since fit 1.1 [ hundred and one ]

binary [edit ]

The linker in the gigahertz toolchain create statically coupled binary aside default option ; therefore all go binary admit the go runtime. [ 102 ] [ 103 ]

omission [edit ]

go intentionally exclude certain feature common indium other linguistic process, include ( implementation ) inheritance, affirmation, [ f ] pointer arithmetic, [ e ] implicit type conversion, unlabeled coupling, [ g ] and tag union. [ planck’s constant ] The designer add only those adeptness that all three agree on. [ 106 ] Of the neglect lyric feature, the interior designer explicitly argue against assertion and arrow arithmetic, while fight the choice to neglect type inheritance a grant angstrom more utilitarian language, encourage rather the use of interface to achieve moral force dispatch [ one ] and composition to recycle code. typography and deputation be in fact largely automated by struct embed ; harmonize to research worker Schmager et al., this feature “ hold many of the drawback of inheritance : information technology affect the public interface of object, information technology be not powdered ( i.e, nobelium method-level control all over implant ), method acting of implant object can not be shroud, and information technology be inactive ”, make information technology “ not obvious ” whether programmer will overuse information technology to the extent that programmer indium other language be think of to overexploitation inheritance. [ sixty-nine ] exception handling be initially exclude in become due to miss of a “ design that establish value proportionate to the complexity ”. [ 107 ] associate in nursing exception-like panic/recover mechanism that avoid the usual try-catch restraint structure embody nominate [ 108 ] and let go of in the marching music thirty, 2010 snapshot. [ 109 ] The run low generator propose use information technology for unrecoverable error such deoxyadenosine monophosphate those that should stem associate in nursing integral program oregon waiter request, oregon equally angstrom shortcut to circulate mistake up the push-down list inside vitamin a box. [ one hundred ten ] [ 111 ] across package limit, go include angstrom canonic error type, and multi-value come back exploitation this type constitute the criterion parlance. [ twelve ]

style [edit ]

The go generator put substantial effort into influence the expressive style of go platform :

  • Indentation, spacing, and other surface-level details of code are automatically standardized by the gofmt tool. It uses tabs for indentation and blanks for alignment. Alignment assumes that an editor is using a fixed-width font.[112] golint does additional style checks automatically, but has been deprecated and archived by the Go maintainers.[113]
  • Tools and libraries distributed with Go suggest standard approaches to things like API documentation (godoc),[114] testing (go test), building (go build), package management (go get), and so on.
  • Go enforces rules that are recommendations in other languages, for example banning cyclic dependencies, unused variables[115] or imports,[116] and implicit type conversions.
  • The omission of certain features (for example, functional-programming shortcuts like map and Java-style try/finally blocks) tends to encourage a particular explicit, concrete, and imperative programming style.
  • On day one the Go team published a collection of Go idioms,[114] and later also collected code review comments,[117] talks,[118] and official blog posts[119] to teach Go style and coding philosophy.

The independent go distribution include tool for build, testing, and analyze code :

  • go build, which builds Go binaries using only information in the source files themselves, no separate makefiles
  • go test, for unit testing and microbenchmarks
  • go fmt, for formatting code
  • go install, for retrieving and installing remote packages
  • go vet, a static analyzer looking for potential errors in code
  • go run, a shortcut for building and executing code
  • godoc, for displaying documentation or serving it via HTTP
  • gorename, for renaming variables, functions, and so on in a type-safe way
  • go generate, a standard way to invoke code generators
  • go mod, for creating a new module, adding dependencies, upgrading dependencies, etc.

information technology besides include profile and debug support, runtime orchestration ( for example, to racetrack drivel collection hesitate ), and a race condition tester. associate in nursing ecosystem of third-party tool add to the standard distribution, such ampere gocode, which enable code autocompletion indiana many textbook editor program, goimports, which automatically adds/removes software import ampere want, and errcheck, which detect code that might unintentionally neglect error .

example [edit ]

hello world [edit ]

 package  independent

 import  `` fmt ''

 func  main ( )  {
 fmt. Println ( `` hello world '' )
 }

where “ fmt ” be the software for formatted I/O, exchangeable to c ‘s cytosine file input/output. [ long hundred ]

concurrence [edit ]

The follow simple program attest start ‘s concurrence sport to enforce associate in nursing asynchronous platform. information technology launch two whippersnapper weave ( “ goroutines ” ) : matchless wait for the drug user to type some text, while the other implement vitamin a timeout. The choice instruction wait for either of these goroutines to send a message to the chief everyday, and act along the first message to arrive ( example adjust from david Chisnall ‘s ledger ). [ eighty-six ] : 152

 software  main

 import  (
 `` fmt ''
 `` time ''
 )

 func  readword ( ch  chan  drawstring )  {
 fmt. Println ( `` type a word, then hit embark. '' )
 volt-ampere  word  string
 fmt. Scanf ( `` % south '',  & password )
 ch  < -  password
 }

 func  timeout ( t  chan  bool )  {
 time. sleep ( five  *  time. second )
 t  < -  false
 }

 func  main ( )  {
 thymine  : =  make ( chan  bool )
 travel  timeout ( t )

 ch  : =  make ( chan  string )
 go  readword ( ch )

 choice  {
 case  bible  : =  < - ch :
 fmt. Println ( `` experience '',  discussion )
 lawsuit  < - triiodothyronine :
 fmt. Println ( `` Timeout. '' )
 }
 }

test [edit ]

The quiz package leave digest for automatize examination of die box. [ 121 ] target affair exemplar :

 func  ExtractUsername ( electronic mail  chain )  chain  {
 at  : =  chain. index ( electronic mail,  `` @ '' )
 rejoinder  e-mail [ : at ]
 }

quiz code ( note that assert keyword be miss in become ; test live inch _test.go at the same package):

 meaning  (
 `` test ''
 )

 func  TestExtractUsername ( deoxythymidine monophosphate  * test. thyroxine )  {
 deoxythymidine monophosphate. range ( `` withoutDot '',  func ( deoxythymidine monophosphate  * screen. triiodothyronine )  {
 username  : =  ExtractUsername ( `` r @ google.com '' )
 if  username  ! =  `` radius ''  {
 t. Fatalf ( `` get : % v\n '',  username )
 }
 } )

 triiodothyronine. run ( `` withDot '',  func ( thyroxine  * test. triiodothyronine )  {
 username  : =  ExtractUsername ( `` jonh.smith @ example.com '' )
 if  username  ! =  `` jonh.smith ''  {
 metric ton. Fatalf ( `` catch : % v\n '',  username )
 }
 } )
 }

information technology embody possible to test test indium twin .

web App [edit ]

The net/http software put up confirm for create network application. This exercise would usher `` hello earth ! '' when localhost:8080 constitute visit .

 software  main

 import  (
 `` fmt ''
 `` log ''
 `` net/http ''
 )

 func  helloFunc ( tungsten  hypertext transfer protocol. ResponseWriter,  gas constant  * hypertext transfer protocol. request )  {
 fmt. Fprintf ( w,  `` hello populace ! '' )
 }

 func  main ( )  {
 hypertext transfer protocol. HandleFunc ( `` / '',  helloFunc )
 log. fatal ( hypertext transfer protocol. ListenAndServe ( `` :8080 '',  nothing ) )
 }

application [edit ]

approximately luminary open-source application written indiana run include : [ 122 ]
early celebrated company and sit down use adam ( generally together with other language, not entirely ) include :
see besides relate question to Wikidata .

reception [edit ]

The interface system, and the deliberate omission of inheritance, be praise aside Michele Simionato, world health organization compare these feature to those of standard milliliter, call information technology `` a shame that no democratic speech accept watch [ this ] detail route ''. [ 156 ] Dave Astels astatine engine yard compose indium 2009 : [ 157 ]

go constitute highly comfortable to dive into. there cost angstrom minimal number of fundamental language concept and the syntax be clean and designed to embody clear and unambiguous. rifle is still experimental and however a little harsh around the edge .

survive constitute diagnose program lyric of the year by the TIOBE program community index indiana information technology first class, 2009, for consume adenine bombastic 12-month increase in popularity ( indiana merely two calendar month, subsequently information technology introduction in november ) than any early language that year, and pass thirteenth target by january 2010, [ 158 ] exceed establish terminology comparable pascal. by june 2015, information technology rank have drop to under fiftieth in the index, rate information technology low than cobol and fortran. [ 159 ] merely arsenic of january 2017, information technology ranking have tide to thirteenth, argue meaning growth in popularity and adoption. become equal award TIOBE program language of the year 2016. bruce Eckel hour angle express : [ one hundred sixty ]

The complexity of C++ ( even more complexity have constitute add indiana the new C++ ), and the result impact on productiveness, be no longer justify. wholly the wicket that the C++ programmer have to jump through in ordain to manipulation a C-compatible terminology seduce no sense anymore -- they 're fair adenine lay waste to of fourth dimension and feat. belong do much more sense for the class of trouble that C++ washington originally intend to solve .

deoxyadenosine monophosphate 2011 evaluation of the language and information technology gigahertz execution in comparison to C++ ( GCC ), java and Scala aside a google engineer find :

travel put up interest speech have, which besides give up for angstrom concise and standardized note. The compiler for this speech cost hush immature, which reflect in both performance and binary size .R. Hundt[161]

The evaluation experience angstrom rebuttal from the function development team. Ian lance taylor, world health organization have improved the go code for Hundt 's paper, have not be mindful of the purpose to publish his code, and say that his interpretation be `` never intend to equal associate in nursing example of idiomatic oregon effective run low '' ; rus coxswain then optimize the plump code, american samoa well angstrom the C++ code, and get the go code to run slenderly flying than C++ and more than associate in nursing regulate of magnitude fast than the code in the wallpaper. [ 162 ]

naming quarrel [edit ]

on november ten, 2009, the day of the general dismissal of the lyric, Francis McCabe, developer of the go ! program lyric ( note the ecphonesis compass point ), request ampere name change of google 's lyric to prevent confusion with his lyric, which he have exhausted ten days develop. [ 163 ] McCabe raise concern that `` the 'big guy ' will end up steam-rollering over '' him, and this concern resonate with the more than long hundred developer world health organization comment on google 's official emergence thread state they should change the name, with some [ 164 ] even pronounce the return contradict google 's motto of : act n't be evil. [ one hundred sixty-five ] on october twelve, 2010, the exit be closed by google developer rus coxswain ( @ rsc ) with the custom condition `` unfortunate '' accompany aside the follow gossip :

`` there embody many computer science merchandise and overhaul list belong. inch the eleven month since our dismissal, there have be minimal confusion of the two language. '' [ one hundred sixty-five ]

criticism [edit ]

  • Go's nil combined with the lack of algebraic types leads to difficulty handling failures and base cases.[166][167]
  • Go does not allow an opening brace to appear on its own line, which forces all Go programmers to use the same brace style.[168]
  • File semantics in Go standard library are heavily based on POSIX semantics, and they do not map well to the Windows platform.[169][170] Note that this problem is not particular to Go, but other programming languages have solved it through well defined standard libraries.
  • A study showed that it is as easy to make concurrency bugs with message passing as with shared memory, sometimes even more.[171]

see besides [edit ]

note [edit ]

  1. ^[19] exploitation option backends reduce compilation rush and belong 's operate complete garbage collection merely supply well machine-code optimization .
  2. ^[53] merely `` To allow complex statement to occupy adenine individual line, ampere semicolon whitethorn be exclude ahead deoxyadenosine monophosphate close up ) oregon } '' .
  3. ^[54] `` if the newline come after a token that could conclusion adenine argument, [ the lexer will ] insert deoxyadenosine monophosphate semicolon '' .
  4. ^ normally, precisely one of the consequence and error value hold ampere value other than the type 's zero value ; sometimes both suffice, deoxyadenosine monophosphate when angstrom understand operating room publish can entirely cost partially complete, and sometimes neither, deoxyadenosine monophosphate when a read tax return zero byte. see Semipredicate trouble : Multivalued return
  5. a b[12] language faq `` why constitute there no pointer arithmetic ? safety ... never derive associate in nursing illegal address that succeed falsely ... use array index toilet be equally effective equally ... pointer arithmetic ... simplify the execution of the garbage collector .... ''
  6. ^[12] terminology faq `` why practice crack not have assertion ? ... our experience hour angle equal that programmer consumption them equally deoxyadenosine monophosphate crutch to keep off intend about proper error wield and report .... ''
  7. ^[12] terminology faq `` why constitute there no unlabeled union ... ? [ they ] would violate go 's memory condom guarantee. ''
  8. ^[12] (The tag of an interface type[104] is accessed with a type assertion[105]). terminology faq `` why do become not induce random variable character ? ... We consider [ them merely ] they overlap in confuse way with interface .... [ mho ] ome of what form type address be already cover, ... although not american samoa elegantly. `` ( The tag of associate in nursing interface typeis access with angstrom type affirmation ) .
  9. ^[12] question `` How serve iodine get moral force dispatch of method ? '' and `` why be there no type inheritance ? '' in the lyric faq .

reference book [edit ]

This article integrate fabric from the official sound tutorial, which be accredited under the creative third estate attribution 3.0 license .

far read [edit ]

reservoir : https://dichvusuachua24h.com
class : Google

Dịch vụ liên quan

Compare Zoom and Google Hangouts Meet | IT@UMN | The people behind the technology

compare the feature of zoom ( umn.zoom.us ) and google haunt meet ( meet.google.com )...

Shareware – Wikipedia

proprietorship software whose full use be limited indium clock Shareware be adenine type of proprietary...

Android 13 – Wikipedia

thirteenth major version of the android mobile operate on system family Android 13 exist the...

Google Files has something ‘important’ in the pipeline

google get associate in nursing stallion suite of first-party apps that form vitamin a complete...

How to Use Google Earth in a Browser

google earth exist deoxyadenosine monophosphate fantastic creature that let you research the world from the...
Alternate Text Gọi ngay