' t t h i n k l a r g e a p p s , b u t l a r g e t e a m s Distributed systems A n y a p p i s d i s t r i b u t e d t o d a y , m a k i n g r e q u e s t t o r e m o t e A P I ? Y O U R a p p i s d i s t r i b u t e d ! Multicore hardware M o o r ' s l a w i s n o t w o r k i n g a n y m o r e , p r o c e s s o r s a r e n o t b e t t e r , t h e y a r e p a r a l l e l Speed of compilation P r o b l e m a t G o o g l e , s o m e b i n a r i e s t a k e s e v e r a l h o u r s t o b u i l d
m a i n i m p o r t ( " f m t " " l o g " " n e t / h t t p " ) f u n c m a i n ( ) { h t t p . H a n d l e F u n c ( " / " , f u n c ( w h t t p . R e s p o n s e W r i t e r , r * h t t p . R e q u e s t ) { l o g . P r i n t l n ( " C o n n e c t i o n c o m i n g f r o m " , r . R e m o t e A d d r ) f m t . F p r i n t f ( w , " H e l l o W o r l d " ) } ) l o g . P r i n t l n ( " L i s t e n i n g o n p o r t 5 0 0 0 " ) h t t p . L i s t e n A n d S e r v e ( " : 5 0 0 0 " , n i l ) } Run
) f u n c n e x t I D ( ) i n t { i + = 1 r e t u r n i } f u n c m a i n ( ) { g o f u n c ( ) { f m t . P r i n t l n ( n e x t I D ( ) ) } ( ) f m t . P r i n t l n ( n e x t I D ( ) ) t i m e . S l e e p ( t i m e . S e c o n d ) } Question? What does it display?
) f u n c n e x t I D ( ) i n t { i + = 1 r e t u r n i } f u n c m a i n ( ) { g o f u n c ( ) { f m t . P r i n t l n ( n e x t I D ( ) ) } ( ) f m t . P r i n t l n ( n e x t I D ( ) ) t i m e . S l e e p ( t i m e . S e c o n d ) } Answer: unknown
v a r ( i = 0 m I D = s y n c . M u t e x { } ) f u n c n e x t I D ( ) i n t { m I D . L o c k ( ) i + = 1 m I D . U n l o c k ( ) r e t u r n i } f u n c m a i n ( ) { g o f u n c ( ) { f m t . P r i n t l n ( n e x t I D ( ) ) } ( ) f m t . P r i n t l n ( n e x t I D ( ) ) t i m e . S l e e p ( t i m e . S e c o n d ) }
= m a k e ( c h a n i n t ) ) f u n c i n i t ( ) { f o r i : = 0 ; ; i + + { g e n < - i } } f u n c m a i n ( ) { g o f u n c ( ) { f m t . P r i n t l n ( < - g e n ) } ( ) f m t . P r i n t l n ( < - g e n ) t i m e . S l e e p ( t i m e . S e c o n d ) }
= m a k e ( c h a n i n t ) ) f u n c i n i t ( ) { f o r i : = 0 ; ; i + + { g e n < - i } } f u n c m a i n ( ) { g o f u n c ( ) { f m t . P r i n t l n ( < - g e n ) } ( ) f m t . P r i n t l n ( < - g e n ) t i m e . S l e e p ( t i m e . S e c o n d ) }
l s t r u c t { / / . . . } f u n c ( a A n i m a l ) W a l k ( ) { / / D o s o m e t h i n g } f u n c m a i n ( ) { a : = A n i m a l { } a . W a l k ( ) }
a i n i m p o r t ( " f m t " " i o " " o s " ) f u n c w r i t e T o F i l e ( c o n t e n t s t r i n g ) e r r o r { f d , e r r : = o s . O p e n ( " / t m p / t o t o " ) i f e r r ! = n i l { r e t u r n e r r } n , e r r : = f d . W r i t e ( [ ] b y t e ( c o n t e n t ) ) } f u n c m a i n ( ) { w r i t e T o F i l e ( " t o t o " ) } Run
A T H / b i n / p r o g r a m 1 p k g / l i n u x _ a m d 6 4 / g i t h u b . c o m / S o u l o u p a c k a g e 1 . a s r c / g i t h u b . c o m / S o u l o u / p a c k a g e 1 / l i b . g o p r o g r a m 1 / m a i n . g o s p o t d . g o
remote package and install it locally g o r u n Build and run a go program (scriptlike) g o b u i l d Build the package/program g o i n s t a l l Build the program and put it in $GOPATH/bin g o t e s t Run the tests of your project
t Format your code to respect go conventions p a c k a g e m a i n i m p o r t ( " f m t " ) f u n c m a i n ( ) { f m t . P r i n t l n ( " H e l l o " ) } Becomes p a c k a g e m a i n i m p o r t ( " f m t " ) f u n c m a i n ( ) { f m t . P r i n t l n ( " H e l l o " ) }
$ G O P A T H s r c / g i t h u b . c o m / S o u l o u / p a c k a g e 1 In the gocode requiring this package: i m p o r t ( " g i t h u b . c o m / S o u l o u / p a c k a g e 1 " ) f u n c m a i n ( ) { p a c k a g e 1 . M y F u n c t i o n ( ) }
m p o r t " g o l a n g . o r g / x / n e t / w e b s o c k e t " Fetching, building and installing a package is one command away $ g o g e t g o l a n g . o r g / x / n e t / w e b s o c k e t That's it your system is read
system L e t m e r e m i n d y o u t h i s b e f o r e a n y t r o l l i n g : * R u b y g e m s i s e x t e r n a l t o t h e c o r e R u b y p r o j e c t * N P M i s e x t e r n a l t o t h e c o r e N o d e J S p r o j e c t * M a v e n i s e x t e r n a l t o t h e c o r e J a v a p r o j e c t Let the community build tools, and we'll see. Stop repeating “They have learnt nothing”
the following packages: $ G O P A T H / s r c / g i t h u b . c o m / S o u l o u / p r o g r a m 1 / v e n d o r / g o l a n g . o r g / x / n e t / w e b s o c k e t g o l a n g . o r g / x / n e t / w e b s o c k e t And you require r e q u i r e " g o l a n g . o r g / x / n e t / w e b s o c k e t " The one in the directory vendor of your project will be used.
Vendor all the dependencies in Godeps/_workspace Don't update any, remove unused, add new g o d e p u p d a t e < p a c k a g e n a m e > Update a precise package by upding project version by global g o d e p g o b u i l d / t e s t / r u n / i n s t a l l Wrapper around the Go tools which adds Godeps/_workspace in $GOPATH (will be deprecated when Go official vendoring will be considered stable)
m p o r t " g o k p g . i o / n s q i o / n s q . v 0 " Different from i m p o r t " g o k p g . i o / n s q i o / n s q . v 1 " Want to update on your branch g o g e t - u g o p k g . i o / n s q i o / n s q . v 0 g o d e p u p d a t e g o p k g . i n / n s q i o / n s q . v 0
n u x G O A R C H = a r m G O A R M = 7 g o b u i l d p r o g r a m 1 $ f i l e p r o g r a m 1 p r o g r a m 1 : E L F 3 2 - b i t L S B e x e c u t a b l e , A R M , E A B I 5 v e r s i o n 1 ( S Y S V ) , s t a t i c a l l y l i n k e d , n o t s t r i p p e d GOOS l i n u x d a r w i n w i n d o w s f r e e b s d s o l a r i s a n d r o i d i o s . . . GOARCH 3 8 6 a m d 6 4 a r m a r m 6 4 p p c 6 4 golang.org/doc/install/source (https://golang.org/doc/install/source)
a c k a g e m a i n / / # i n c l u d e < s t d i o . h > i m p o r t " C " f u n c m a i n ( ) { s : = C . C S t r i n g ( " H e l l o w o r l d " ) C . p u t s ( s ) } golang.org/cmd/cgo/ (https://golang.org/cmd/cgo/)
jobs.apple.com/us/search (https://jobs.apple.com/us/search) And many, many, many more. Every big vendor is using Go today. Twitter, Docker, Facebook, Amazon, IBM, Uber, Tumblr, Mozilla, MongoDB, Dropbox, etc. github.com/golang/go/wiki/GoUsers (https://github.com/golang/go/wiki/GoUsers) Look at their Github account
website] (http://tour.golang.org) Concurrency is not Parallelism [slides] (https://talks.golang.org/2012/waza.slide) Go Concurrency Patterns [slides] (https://talks.golang.org/2012/concurrency.slide) Advanced Go Concurrency Patterns [slides] (https://talks.golang.org/2013/advconc.slide) The official go blog [website] (https://blog.golang.org) Godoc: documentation of all the public packages [website] (https://godoc.org)