Go Programming with GoLand

Learn Go in GoLand, JetBrains' IDE for Go: types, slices, maps and structs, interfaces and errors, goroutines and channels, tests and a small web service.

Beginner · Software Development · about 13 hours · 5 modules · certificate on completion

Taught by Luís Ferreiràs, Nikolàs Petrovicì, AI Learning Companions.

About this course

Go is a small, fast language for building dependable software: command-line tools, network services and the infrastructure much of the cloud runs on. In this course you learn Go the way professionals work with it, in GoLand, JetBrains' IDE for Go. Every lesson teaches part of the language and then shows it in GoLand step by step, with the keyboard shortcuts for macOS, Windows and Linux: creating modules, running and debugging, navigating the standard library, refactoring, quick-fixes, the test runner and the HTTP Client.

You start with types, functions and control flow, then model data with slices, maps and structs, and write flexible code with interfaces and careful error handling. The fourth module covers what Go is famous for: goroutines and channels, select, worker pools, contexts for cancellation, and the race detector. The last module organises code into packages, tests it with table-driven tests, examples and benchmarks, and builds a small JSON web service with net/http. Every module ends with a lab you do in GoLand, and the capstone is a URL shortener service, built to pass a provided test suite under the race detector.

What you'll learn

  • Set up Go projects with modules in GoLand, and write, run, format and debug programs
  • Model data with Go's types, slices, maps, structs and methods
  • Design with small interfaces, and handle errors explicitly with wrapping, errors.Is and errors.As
  • Write concurrent code with goroutines, channels, select, WaitGroups, mutexes and contexts, and check it with the race detector
  • Organise code in packages and modules, and test it with table-driven tests, examples and benchmarks
  • Build and test a small JSON web service with net/http

Skills you'll gain

Go, GoLand, Goroutines and channels, Error handling, Interfaces, Unit testing with go test, HTTP services, Go modules, Debugging

Tools

GoLand, Go, go test, net/http

Before you start

No Go experience needed, though some programming in any language helps (Python Programming with PyCharm or Java Programming with IntelliJ IDEA is plenty). You need Go 1.24 or later (go.dev/dl) and GoLand on Windows, macOS or Linux: GoLand has a free trial, and JetBrains offers free licences in some cases, such as for students. The race detector needs a C compiler on Linux and Windows.

Modules

  1. Go basics in GoLand

    Set up Go and GoLand, write and run your first programs, and learn Go's types, constants, control flow and functions, with GoLand formatting, checking and debugging your code as you go.

    • Go, GoLand and your first program (12 min)
    • Variables, types and constants (13 min)
    • Control flow and functions (14 min)
    • Hands-on lab: Build a temperature table
  2. Slices, maps and structs

    Store and organise data the Go way: slices and the arrays behind them, maps and the comma-ok idiom, and structs with methods, pointer receivers and embedding.

    • Arrays and slices (14 min)
    • Maps (12 min)
    • Structs and methods (14 min)
    • Hands-on lab: Model a shop's stock
  3. Interfaces and errors

    Write flexible code with small interfaces that types satisfy implicitly, and handle failure the Go way: errors as values, wrapped with context and inspected with errors.Is and errors.As.

    • Interfaces (14 min)
    • Errors (15 min)
    • Hands-on lab: Send alerts through an interface
  4. Goroutines and channels

    Run work concurrently with goroutines, coordinate it with WaitGroups, mutexes and channels, choose between channels with select, cancel work with contexts, and catch data races with the race detector.

    • Goroutines, WaitGroups and mutexes (14 min)
    • Channels (14 min)
    • select, worker pools and context (15 min)
    • Hands-on lab: Check websites concurrently
  5. Packages, testing and a web service

    Organise code in packages and modules, test it with go test (table-driven tests, examples, coverage and benchmarks), and build and test a small JSON web service with net/http.

    • Packages and modules (13 min)
    • Testing with go test (15 min)
    • A small web service with net/http (15 min)
    • Hands-on lab: Build and test a tasks API

Project: Build a URL shortener service

Build a small URL shortener in Go: a JSON web service that turns long links into short codes, redirects visitors and counts their visits. The provided shortener_test.go describes the service: write NewHandler() http.Handler so that every test passes, including under the race detector. POST /links with {"url": "https://go.dev/doc/"} replies 201 Created with the new code and the URL; only absolute http and https URLs are accepted, and anything else gets 400 with a JSON error. GET /{code} redirects with 302 Found to the stored URL and counts the visit, and unknown codes get 404. GET /links/{code} replies with the code, the URL and the number of visits. Structure the module like a professional project: keep storage in its own package behind a small interface (so a database could replace the in-memory map later), use a mutex wherever goroutines share data, wrap errors with context, and add table-driven tests of your own, an example and a benchmark. Run the service and try every endpoint from GoLand's HTTP Client.

Part of

GoLand is a trademark of JetBrains s.r.o. This course is independent: JetBrains hasn't made or endorsed it.

Start the course free