ABSTRACT

Go is “an open source programming language that makes it easy to build simple, reliable, and efficient software". It was conceived, designed, and first implemented at Google to help address Google-sized problems. This chapter focuses on several of Go’s interesting features: pointers, arrays and slices, its approach to interfaces, and panics. Go has eight kinds of composite types: arrays, functions, structures, maps, pointers, slices, interfaces, and channels. These complex types depend on constituent types. The chapter discusses the Go way of specifying types of “objects that know how to do x and y", namely, the interface. Interfaces are types, so programmers can declare variables and parameters with interface types. Interfaces are ubiquitous in the Go libraries. A panic stops the current function, run any deferred operations, then returns. In the caller, the panic process is repeated, until some deferred operation is able to recover, or the entire chain of calls has been “unwound” and the program crashes.