Using the Go Programming Language in Practice - Parent Directory

May 23, 2014 - slow builds, uncontrolled dependencies, hard to read code, poor documenta- ..... executable is that the disk usage becomes smaller as many programs ..... aData int. 22. B. // Unnamed type = struct emedding. 23 }. This is the ...
583KB Sizes 11 Downloads 316 Views
Using the Go Programming Language in Practice

Erik Westrup

Fredrik Pettersson





<[email protected]>



May 23, 2014

Master’s thesis work carried out at Axis Communications AB for the Department of Computer Science, Lund University.

Supervisors: Jonas Skeppstedt <[email protected]> Mathias Bruce <[email protected]> Robert Rosengren Examiner Jonas Skeppstedt

Abstract When developing software today, we still use old tools and ideas. Maybe it is time to start from scratch and try tools and languages that are more in line with how we actually want to develop software. The Go Programming Language was created at Google by a rather famous trio: Rob Pike, Ken Thompson and Robert Griesemer. Before introducing Go, the company suffered from their development process not scaling well due to slow builds, uncontrolled dependencies, hard to read code, poor documentation and so on. Go is set out to provide a solution for these issues. The purpose of this master’s thesis was to review the current state of the language. This is not only a study of the language itself but an investigation of the whole software development process using Go. The study was carried out from an embedded development perspective which includes an investigation of compilers and cross-compilation. We found that Go is exciting, fun to use and fulfills what is promised in many cases. However, we think the tools need some more time to mature.

Keywords: Go, golang, language review, cross-compilation, developer tools, embedded

2

Acknowledgements

We want to give a special thanks to our supervisors at Axis Communications, Matthias Bruce and Robert Rosengren, for giving guidance and support throughout the thesis and for the many plain fun discussions about nonsense. We are grateful for our academic supervisor Jonas Skeppstedt at the Department of Computer Science at Lund University for discussions about the outline of our thesis and for giving feedback on our progress. We want to express our gratitude to the whole New Business department at Axis for welcoming us to the team, lending us hardware to play with and for sharing their expertise. We want to thank the Go community for answering our questions and yielding discussions. Finally we are thankful for CSN’s investment in our future.

3

4

Contents

1

2

Introduction 1.1 Outline . . . . . . . . . . . . . . . . . . . . . . . 1.2 Background . . . . . . . . . . . . . . . . . . . . . 1.2.1 Introduction . . . . . . . . . . . . . . . . . 1.2.2 The Go Programming Language . . . . . . 1.2.3 Building & Compiling . . . . . . . . . . . 1.3 Purpose & Goals . . . . . . . . . . . . . . . . . . 1.4 Problem Formulation . . . . . . . . . . . . . . . . 1.4.1 The Go Programming Language . . . . . . 1.4.2 Building & Compiling . . . . . . . . . . . 1.4.3 Development Tools . . . . . . . . . . . . . 1.4.4 Software Product & Development Qualities 1.5 Previous Research . . . . . . . . . . . . . . . . . . 1.6 Distribution of Work . . . . . . . . . . . . . . . . Approach 2.1 The Go Programming Language 2.1.1 Syntax & types . . . . . 2.1.2 Object-orientation . . . 2.1.3 Goroutines & Channels . 2.1.4 Standard library . . . . . 2.1.5 Missing features . . . . 2.1.6 Legal . . . . . . . . . . 2.2 Building & Compiling . . . . . 2.2.1 The Environment . . . . 2.2.2 Building . . . . . . . . 2.2.3 gc & gccgo . . . . . . . 2.2.4 Cross-Compilation . . . 2.2.5 C-Integration . . . . . . 2.3 Development Tools . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .