Bazel build Go

• Package Management • Code Management (Multi languages) • Bazel build //:Go • Demo

1.Bazel build //:Go

2.Help everyone become a global citizen! github/lingochamp

3.何源 2014 年年底加⼊入流利利说, ⽬目前主要负责 Platform Team 来流利利说之前在 ThePlant 杭州⼯工作

4.Agenda • Package Management • Code Management (Multi languages) • Bazel build //:Go • Demo •Q&A

5. Let's talk about Package Management


7.Go 1.5 vendor introduced experimental support for a " " directory, enabled by the GO15VENDOREXPERIMENT environment variable. Go 1.6 enabled this behavior by default , and in Go 1.7 , this switch has been removed and the "vendor" behavior is ALWAYS enabled.

8.vendor 很棒! 棒? @2015 - 2016?

9.$ cd $GOPATH/src/ && tree vendor/ 🤔 🤔 🤥


11.Russ Cox 有话要讲

12.A Proposal for Package Versioning in Go - Russ Cox

13.Russ Cox 说: • Rust 的 Cargo 做的不不错,于是我们做了了 Dep • ⼋八年年的 go install 和 go get ⾟辛苦⼤大家了了, go module 了了解⼀一下 • go module 会⼲干掉⼤大部分的 vendor ⽬目录 🤔

14.Russ Cox 说: "the new concept of a Go module, which is a collection of packages versioned as a unit; verifiable and verified builds; and version-awareness throughout the go command, enabling work outside $GOPATH and the elimination of (most) vendor directories.



17.1. Packages Versioned 2. Verifiable and verified builds 3. Work outside $GOPATH


19.Google 这么多年年怎么 build Go 的?

20.Code Management :)

21.Why should I care? scaling up, fast


24.$ kubectl get pods --all-namespaces | awk '{print $2}' | awk -F '-' '{print $1"-"$2}' | uniq | wc -l 213*

25.Why should I care? • New product lines, features (D***n, Ba**ta, IELTS, etc.) • Increasingly sophisticated systems(E.g., adaptive learning system) • Ever tighter integration • Algorithm, backend, data, all part of one system • We are in the process of becoming a big data company • Data exchange between heterogeneous components • Multi languages, Go, C++, Python, Java • Evolving independently, at varied pace

26.At scale, managing code becomes highly non-trivial!

27.Code Management Challenges

28.How to propagate changes?

29.• Has the server / client got the new proto field? • Trivial if you just have one proto file • How about a.proto imports b.proto who imports c.proto? • How about a.proto imports b.proto and c.proto both of which import d.proto? • I have marked this field deprecated for a month, can I delete? Or someone is still using it… • Even worse, somebody might have re-purposed it...