go-tour

command module
v0.0.0-...-7074af3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Go-Tour

The exercises from my Go Language Tour after I first took it in beginning of August, 2014 and then kept refreshing my knowledge whenever necessary.

Most important about Go language

This is a summary of the most important points to consider with Go language when taking the tour and afterwards when using the language.

  • programs are made of packages, programs start running in package main (see Packages);
  • a name is exported from a package and can be refereed to only if it begins with a capital letter (see Exported names);
  • functions could return multiple results, including named return values (see Multiple results, Named return values);
  • variables without initializers are given zero values (see Zero values);
  • type conversions are always explicit (see Type conversions);
  • there is only one looping construct - for (see For, For is Go's "while");
  • switch statement has implicit break after each case (see Switch);
  • defer statement for deferring the execution of a function until the surrounding function returns (see Defer);
  • there are pointers, but no pointer arithmetic (see Pointers);
  • slices are "dynamically-sized, flexible views into the elements of an array" (see Slices);
  • functions are values and may be closures as well (see Function values, Function closures);
  • no classes, but methods on types, which are functions with a special receiver argument (see Methods);
  • interface type is defined as a set of method signatures and a value of such type can hold any value that implements those methods (see Interfaces);
  • error state is expressed with error values (see Errors);
  • type parameters and generic types are the way Go implements generics since version 1.18 (see Type parameters, Generic types);
  • goroutines are a lightweight threads managed by the Go runtime (see Goroutines), which communicate and synchronize through channels (see Channels) as sends and receives on channels block until the other side is ready;

Usage

To build the exercises do the following:

  1. Clone the repository (e.g. in your home directory):
git clone --recurse-submodules https://github.com/gdsotirov/go-tour.git
cd go-tour
  1. Build all exercises:
make --jobs
  1. Run exercises (e.g. ex_mtp_23_wc):
./ex_mtp_23_wc

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL