Channels ▼
RSS

JVM Languages

Introduction to Go


Getting Going with Go

The first installment in our five-week tutorial on Google's new native language explains how to set up Go and build programs. It then walks through code examples that highlight some of the language's interesting features.

In this installment, Go expert Mark Summerfield explains how to set up Go, and then he provides two examples of Go programs that are explained in depth. The programs provide a partial overview of Go's key features and some of its key packages. The following weeks' installments will show the remaining key features and dig into many aspects that make Go a uniquely interesting language, especially for C, C++, and Java programmers.

As explained in the editorial Why Not Go?, Go has many unique features and might be described as C for the 21st century. Given that one of the language's designers is Ken Thompson, the languages do indeed share a common ancestor. [read on]

Go Tutorial: Object Orientation and Go's Special Data Types

In this second installment of our five-week course on the Go language, we explore Go's unusual approach to object orientation, its special built-in object types, the syntax for multiple return values, and how Go handles exceptions.

Although Go supports object-oriented programming, it provides neither classes nor inheritance (is-a relationships). Go does support the creation of custom types, and Go makes aggregation (has-a relationships) extremely easy. Go also allows for the complete separation of a type's data from its behavior, and supports duck typing. Duck typing is a powerful abstraction mechanism that allows values to be handled (for example, passed to functions) based on the methods they provide, regardless of their actual types. The terminology is derived from the phrase, "If it walks like a duck, and quacks like a duck, it's a duck." This produces a flexible and powerful alternative to the traditional classes and inheritance approach — but it requires those of us used to the more traditional approach to make some significant conceptual adjustments to really benefit from Go's object orientation. [read on]

Go Introduction: How Go Handles Objects

Go's unique approach to OO steps around many problems found in other languages by preferring composition to inheritance.

TTo an object-oriented purist, neither C++ nor Java are object-oriented because those languages use method calls rather than message passing. Pragmatists equally might question whether Go is object-oriented, since in addition to using methods rather than messages, it doesn't support inheritance. This apparent lack is a deliberate design choice — which reflects a growing discontent with deep, complex object hierarchies that can be very inflexible to use and expensive to change. Many programmers are switching to using aggregation wherever possible, and Go provides particular support for this approach. [read on]

RESTful Web Service in Go Powered by Google App Engine

In this installment of our Go tutorial, Go's support for REST-based Web services and cloud computing make quick work of useful document analysis project.

Here, I have developed a Web service in Go that does useful data retrieval and exposes the results via a RESTful API, and I've rolled it out on the Google App Engine cloud. If your volumes (traffic and data) are less than a certain limit, you can use GAE for free. [read on]

A Brief Tour of the Go Standard Library

In this final installment of our five-week tutorial series on Go, we examine the language's extensive standard library.

The Go standard library includes a large number of packages that provide a wide range of functionality. The overview provided here is highly selective and very brief. The contents of the library are likely to continue to grow after this article is published, so it is best to look at the library APIs online or locally using godoc (in the Go distribution) to get the most up-to-date information and get a comprehensive overview of what is available in each package.

The exp (experimental) package is where packages that might potentially be added to the standard library begin life, so these packages should not be used unless you want to participate in their development (by testing, commenting, or submitting patches). The exp package is normally available when pulling Go from Google's Go source tree, but it may not be included in prebuilt packages. The other packages are OK to use, although at the time of this writing, some are still incomplete. [read on]


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video