Avito at GopherCon Russia 2018

    Hello! In March, a conference was held in Moscow's Technopolis on the Go programming language, GopherCon Russia 2018 . She delivered speeches from the core-team - it was cool to hear firsthand about how to do it right. And of course, there were reports on microservices, open trading, working with a network in Go, creating client libraries and cool tools.
    We want to say “thanks” to the speakers - for the reports and to the organizers - for the opportunity to chat with lively Brad Fitzpatrick and the real Ashley McNamara . Under the cut, we talk about reports, workshops and a competition from Avito, and also play some Go souvenirs.
    UPD, 12.04, 10:13 Moscow time: reception of competitive comments is stopped, later update post and we will write to all the winners.
    UPD, 13.04, 13:40 Moscow time: the answers are posted at the end of the post under the spoiler, all commentators who wrote before 04/12/2018 will receive prizes.



    We took most of the photos from the report posted on the GopherCon Russia 2018 Facebook page.


    Papers & Sections by Avito


    Building a search ecosystem on Go


    In his report, Andrei Drozdov talked about the structure of search engines using live examples, about what has already been done in the Go community on this topic, and compared the performance of a “self-made” search engine on Go and solutions on the riot framework. During the report, they discussed how to build a search infrastructure in the company and quickly put into operation new search algorithms. Slides with many useful links are here . And here is a video of this speech:



    Search for a million


    In continuation of his report, Andrey Drozdov held a master class where he could practice creating search engines.
    Here's what he says about the meeting:


    Despite minor problems with connecting a computer, there were a lot of people at the master class. Most of them were able to write their search on the riot framework, load a million news headlines into it and receive stickers from Avito as a gift). In addition to the main task, the three most active ones solved several additional ones: they held their benchmark and implemented a custom ranker. I will be glad if as a result more people learn riot and, possibly, copy it into it, so that it develops faster.

    Centrifugo 2


    As part of the section inside the Avito-room, Alexander Emelin talked about plans for the further development of the Centrifugo project . Over the past few months, he has been working on the second version of the server, which allows serving thousands of simultaneous connections from application users and sending them messages in real time (Websocket and SockJS). An important feature of the server is that it allows you to integrate with the backend written in any programming language.


    In the second version, quite complex tasks were implemented - for example, the server core was allocated to a separate library that Go developers can use. Implemented support for the transfer of binary data via Websocket (Protobuf) in addition to the existing JSON protocol, and also implemented support for GRPC as an alternative transport.


    Here is what Alexander said after the master class:


    Quite a lot of people came to the Avito-room, among whom were current Centrifugo users. It turned out to get a valuable feedback, which is extremely important at this stage of development. After an oral talk about the features of the second version, we looked at a small real-time example using this library - a very simple chat with an interesting feature: the server allowed clients to use not only the Websocket protocol as a transport, but also GRPC.

    Golang, or There and Back


    At our stand, of course, it was also crowded all day. Already at ∞ in the morning we were waiting for the earliest participants in the conference. You could take a picture with Gopher ...



    ... Or a brave employee of our techno-PR department Gosha Immortal, who was recently hired by a junior specialist (though, so far only as an inventory number) ...



    Well, and perhaps the most interesting activity - all day at our booth there was a competition "Golang, or There and Back", where you can win a T-shirt, mittens or sticker pack with Go symbols. It was necessary to match the snippets of code written in Golang and other programming languages. If you take a closer look, you can see how about half of the conference participants captured in this picture match snippets with might and main:



    But bigger plans:



    And a little bit - in the halls of reports:



    It seems that the game "went" to all the participants: those who participated in the competition gladly stretched their brains before the reports and in between, and we enjoyed talking with each of the approximately 350 participants in this game.


    Drawing of sticker packs and Go-mittens on Habré


    We still have some Go-mittens and sticker packs left - we want to play them here on Habré. What's inside the label set? Nine “basic” gophers ...



    ... and a set of sticker accessories for them so that you can put together your own gopher. For example, like this:



    To do this, we suggest you look at and compare snippets of code written in Golang and other programming languages. And write in the comments the pairs on the principle of 1 - A, 2 - B and so on. Hide answers under a spoiler not to spoil other fans!


    We will send the first five commentators by Go-stickerpack and a pair of mittens by mail or courier. We distribute five more of the same sets between the remaining participants using a randomizer. Enjoy!


    Expand Code Samples

    1


    2


    3


    4


    5


    6


    7


    8


    9


    10


    A


    type vertex struct {
            X, Y int
    }
    func f(v *vertex) {
            v.X = 3
            v.Y = 4
    }
    func main() {
            v1 := vertex{1, 8}
            f(&v1)
    }

    B


    package main
    import "fmt"
    import "math"
    func main() {
            fmt.Printf("%f", 1.0/math.Sqrt(49))
    }

    C


    package main
    import (
        "fmt"
        "unicode/utf8"
    )
    func main() {
        b := []byte{80, 72, 80, 32, 114, 117, 108, 101, 115}
        for len(b) > 0 {
            r, size := utf8.DecodeRune(b)
            fmt.Printf("%c", r)
            b = b[size:]
        }
    }

    D


    func f(x, y int64) int64 {
       return x + y
    }

    E


    package main
    import (
            "fmt"
    )
    func f(a int) func(b int) int {
            return func(b int) int {
                    return a*b
            }
    }
    func main() {
            list := []int{2, 2, 2, 2}
            g := f(3)
            for i, value := range list {
                    list[i] = g(value)
            }
            fmt.Println(list)
    }

    F


    type vt struct {
            X, Y int
    }
    func f(v vt) {
            v.X = 3
            v.Y = 4
    }
    func main() {
            v1 := vt{1, 8}
            f(v1)
    }

    G


    package main
    import (
            "io"
            "log"
            "net/http"
    )
    func h(w http.ResponseWriter, r *http.Request) {
            io.WriteString(w, "hello, world!\n")
    }
    func main() {
            http.HandleFunc("/", h)
            log.Fatal(http.ListenAndServe(":8080", nil))
    } 

    H


    type filter func(string) bool
    func bf(list []string, fn filter) [][]string {
            valid, invalid := []string{}, []string{}
            for _, s := range list {
                    if fn(s) {
                            valid = append(valid, s)
                    } else {
                            invalid = append(invalid, s)
                    }
            }
            return [][]string{valid, invalid}
    }
    func main() {
            l := []string{"gl", "hf", "ht", "tt"}
            res := bf(l, func(s string) bool {
                    return s[0] == 'h'
            })
    }

    I


    package main
    import "fmt"
    func main() {
            a, b := 5, 10
            fmt.Println(map[bool]int{true: a, false: a-1}[a > b])
    }

    J


    package main
    import (
            "fmt"
    )
    func f(a, b int) int {
            if a > b {
                    return a
            }
            return b
    }
    func main() {
            ints := []int{1, 8, 3, 4, 5}
            res := ints[0]
            for _, v := range ints {
                    res = f(res, v)
            }
            fmt.Println(res)
    }

    We are waiting for your comments!


    Update: Answers

    1 - G, 2 - J, 3 - A, 4 - F, 5 - H, 6 - C, 7 - E, 8 - B, 9 - I, 10 - D.


    But Gopher is resting after the conference and is gaining strength before the next.



    See you soon!


    Also popular now: