atmosphere 2014: go, go, go - the one language to try in 2014. (or: "write only an eight of the...
DESCRIPTION
You live and breathe http. Most of the things you do with a computer involve it. How many tiny little http-related utils have you already created? Is it time to stop? By no means, we all do it. I'd just like to encourage you to write the next one in Go. It's a fun little language, which feels like a cross-breed between C (pointers!) and ruby (concise, powerful syntax). But how much? Why, yet another language, but my perl/python/.. does all the things? Well, it does. But go has a few things that make it super sweet, is web-scale and real fun to use! Or at least come and listen how did we get rid of 87% of our codebase in a day :-) Andrzej Grzesik - I like programming. I do it a lot, mostly on the JVM, usually writing fancy backends for big, distributed systems. I also display a particular affection to continuous delivery.. UI, unless quickly hacked, is not my play ;-) I believe that most problems we deal with are people problems, so I mix and match tools with technologies to achieve my goals, make people happy and achieve world peace :-) I believe in software quality, and organize GeeCON, Polish JUG, Krakow Software Craftsmanship, Cracow Hadoop User Group. In my free time, I read paper books and cycle, a lot!TRANSCRIPT
![Page 1: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/1.jpg)
golangthe one language you have to try in 2014
![Page 2: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/2.jpg)
golangthe one language you have to try in 2014
![Page 4: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/4.jpg)
about:me
![Page 5: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/5.jpg)
dev going deeper
![Page 6: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/6.jpg)
disclaimers
![Page 7: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/7.jpg)
my opinions are my own
![Page 8: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/8.jpg)
I hate computers
![Page 9: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/9.jpg)
questions?shoot!
![Page 10: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/10.jpg)
golang
![Page 11: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/11.jpg)
gopher
![Page 12: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/12.jpg)
free and open source
![Page 13: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/13.jpg)
BSD licensed
![Page 14: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/14.jpg)
comes from G
![Page 15: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/15.jpg)
FASTand I mean FAST
![Page 16: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/16.jpg)
tl;dr;C++ and ruby had a wild time
![Page 17: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/17.jpg)
play with it tonight
![Page 18: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/18.jpg)
so, why do I like go?
![Page 19: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/19.jpg)
no runtime dependencies!
![Page 20: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/20.jpg)
more pleasant than C
![Page 21: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/21.jpg)
go toolchain
![Page 22: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/22.jpg)
go command
![Page 23: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/23.jpg)
most important thing
![Page 24: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/24.jpg)
there is only one formatting
![Page 25: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/25.jpg)
package main!!
import "fmt"!!
func main() {!!fmt.Println("Hello world")!}!
![Page 26: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/26.jpg)
types
![Page 27: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/27.jpg)
types• uint8, uint16, uint32, uint64
• int8, int16, int32, int64
• float32, float64
• complex64, complex128
• byte alias for uint8
• rune alias for int32
• string
![Page 28: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/28.jpg)
func program() {! var text! text = “zomg"! more := "zomg"!!
fmt.Println(len(text));!}!
![Page 29: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/29.jpg)
maps
![Page 30: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/30.jpg)
func main() {! attendees := map[string]bool{! "Phil": true,! "Marcin": true,! }!!
fmt.Println(attendees["Phil"]) // true! fmt.Println(attendees["ags"]) // false! partygoers["ags"] = true! fmt.Println(attendees["ags"]) // true!}!
![Page 31: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/31.jpg)
structs
![Page 32: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/32.jpg)
type Rectangle struct {! a, b int32!}!!
func main() {! var rect Rectangle! rect = Rectangle{5, 10}! rect = Rectangle{a: 10, b: 5}!!
HasArea(s).Area()!}
![Page 33: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/33.jpg)
type Square struct {! side int32!}!!
func (sq Square) Area() int32 {! return sq.side * sq.side!}!!
func main() {! s := Square{16}! area := s.Area()!}
![Page 34: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/34.jpg)
interfaces
![Page 35: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/35.jpg)
type Square struct {! side int32!}!!
func (sq Square) Area() int32 {! return sq.side * sq.side!}!!
type HasArea interface {! Area() int32!}!!
func main() {! s := Square{16}! HasArea(s).Area()!}
![Page 36: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/36.jpg)
goroutineslightweight threads
![Page 37: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/37.jpg)
func f(i int) {! amt := rand.Intn(1000)! time.Sleep(time.Duration(amt) * time.Millisecond)! fmt.Println(i)!}!!
func main() {! for i := 0; i < 3; i++ {! go f(i)! }! var input string! fmt.Scanln(&input)!}
![Page 38: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/38.jpg)
how many will run? runtime.GOMAXPROCS(4)
![Page 39: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/39.jpg)
channels
![Page 40: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/40.jpg)
channels
• communicate between funcs
• typed
• thread-safe
![Page 41: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/41.jpg)
channelschannel := make(chan int)!
![Page 42: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/42.jpg)
unbuffered channels
• sync
• will wait when empty
![Page 43: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/43.jpg)
buffered channelschannel := make(chan int, size)!
![Page 44: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/44.jpg)
buffered channels
• async
• return 0 element when empty
• will only wait when full
![Page 45: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/45.jpg)
basicschannel := make(chan int)!c <- a!!
<- c!!
a = <- c!!
a, ok = <- c!
![Page 46: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/46.jpg)
func program() {! channel := make(chan int) !}!!
func from(connection chan int) {! connection <- rand.Intn(255)!}!!
func to(connection chan int) {! i := <- connection! fmt.Println(“much received", i)!}!
![Page 47: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/47.jpg)
but that’s not cool yet
![Page 48: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/48.jpg)
coordinate routines
![Page 49: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/49.jpg)
func program() {! channel := make(chan int) !!
go func() {! close(channel)! // or! channel <- anything! }()!!
<- channel!}!
![Page 50: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/50.jpg)
func program() {! latch := make(chan int) !!
go worker()! close(latch)!}!!
func worker() {! <- latch !}!
![Page 51: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/51.jpg)
generators
![Page 52: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/52.jpg)
id := make(chan int64)! go func() {! var counter int64 = 0! for {! id <- counter! counter += 1! } !}()
![Page 53: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/53.jpg)
multiple channels at once!
![Page 54: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/54.jpg)
func program() {! select {! case a := <- channel!!
case b, mkay := other!!
case output <- z!!
default:! }!}!
![Page 55: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/55.jpg)
ranges
![Page 56: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/56.jpg)
func fillIn(channel chan int) {! channel <- 1! channel <- 2! channel <- 4! close(channel)!}!!
func main() {! channel := make(chan int)! go fillIn(channel)!!
for s := range channel {! fmt.Printf("%d \n", s)! }!}
![Page 57: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/57.jpg)
packages
![Page 58: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/58.jpg)
[18:48][agrzesik@melmac:~/vcs/talks/go/hello]!$ find .!.!./bin!./bin/main!./pkg!./pkg/darwin_amd64!./pkg/darwin_amd64/hello.a!./src!./src/hello!./src/hello/hello.go!./src/main!./src/main/.main.go.swp!./src/main/main.go!
![Page 59: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/59.jpg)
import (! "code.google.com/p/go.net/websocket"! "fmt"! "net/http"!)!
![Page 60: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/60.jpg)
go get
![Page 61: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/61.jpg)
net
![Page 62: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/62.jpg)
echo server
![Page 63: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/63.jpg)
const listenAddr = "localhost:4000"!!
func main() {! l, err := net.Listen("tcp", listenAddr)! if err != nil {! log.Fatal(err)! }! for {! c, err := l.Accept()! if err != nil {! log.Fatal(err)! }! io.Copy(c, c)! }!}
![Page 64: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/64.jpg)
concurrent echo server
![Page 65: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/65.jpg)
const listenAddr = "localhost:4000"!!
func main() {! l, err := net.Listen("tcp", listenAddr)! if err != nil {! log.Fatal(err)! }! for {! c, err := l.Accept()! if err != nil {! log.Fatal(err)! }! go io.Copy(c, c)! }!}
![Page 66: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/66.jpg)
const listenAddr = "localhost:4000"!!
func main() {! l, err := net.Listen("tcp", listenAddr)! if err != nil {! log.Fatal(err)! }! for {! c, err := l.Accept()! if err != nil {! log.Fatal(err)! }! io.Copy(c, c)! }!}
![Page 67: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/67.jpg)
websockets?
![Page 68: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/68.jpg)
func main() {! http.Handle("/", websocket.Handler(handler))! http.ListenAndServe("localhost:1984", nil)!}!!
func handler(c *websocket.Conn) {! var s string! fmt.Fscan(c, &s)! fmt.Println("Received:", s)! fmt.Fprint(c, “hey!”)!}!
![Page 69: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/69.jpg)
so, what looks bad?
![Page 70: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/70.jpg)
type AssetMetas struct {!!Metas []AssetMeta `json:"assetMetas"`! }!!
type AssetMeta struct {!!ResourceName string `json:"resource_name"`! !Md5 string `json:"md5"`! !Urls []string `json:"urls"`! }!
![Page 71: Atmosphere 2014: Go, go, go - the one language to try in 2014. (or: "write only an eight of the code" ;-)) - Andrzej Grzesik](https://reader033.vdocuments.site/reader033/viewer/2022060107/5549cb0eb4c9051c778b4733/html5/thumbnails/71.jpg)
so, go code!