User Tools

Site Tools


public:programming:go:learn-go

Learn Go!

Cheatsheets and help materials

Don't remember how something should look like? Check these materials:

  1. https://gobyexample.com/ - Go by Example, shows examples on many built-in functions
  2. https://pkg.go.dev/std - Docs for Go standard library
  3. https://sourcegraph.com/search - SourceGraph, search public code

Places to test code

Can't install Go locally? Here are some of the online playgrounds available:

  1. https://goplay.tools/ - Online playground, allows to run Go in browser or on their servers. Many examples built-in!
  2. https://go.dev/tour/ - Not really a playground, but allows you to run your own code

Basics

Boot.dev has great course with most aspects of programming in Go. Every lesson is free in guest mode, with exception of running the code in browser. I believe the course itself is worth the money. Also many Youtube'ers have promo codes from time to time.

Free - Go Getting Started Documentation & Go Tour

https://go.dev/doc/ provides free tutorials with basic and more advanced topics like multi-module workspaces and web apps. It also links to https://go.dev/tour/ which teaches basic syntax and standard library.


Advanced

Finished any of the above and want more?

Effective Go

https://go.dev/doc/effective_go talks about writing “clear, idiomatic Go code”.

Understanding Allocations: the Stack and the Heap

https://youtube.com/watch?v=ZMZpH4yT7M0 talks about memory layout in Go code and *when* you should optimize.


Specific Stuff

Profiling and Optimizing Go

https://youtube.com/watch?v=N3PWzBeLX2M shows absurdly good introduction to testing, profiling and optimizing Go code. Uses pprof and flame library.

Go-Torch has been deprecated as of 7 Mar 2019!

As of Go 1.11, flamegraph visualizations are available in go tool pprof directly!

# This will listen on :8081 and open a browser.
# Change :8081 to a port of your choice.
$ go tool pprof -http=":8081" [binary] [profile]

(You may need to install graphviz package on your system. Flame graph is available in Top → View → Flame graph)

Multiplatform GUI

I found https://fyne.io/ to be the easiest to use multiplatform GUI library. It even allows for building Android apps! Check https://docs.fyne.io/started/ for more info. You might also want to check out my quick environment setup guide for Android app development: How to setup environment for Fyne GUI library on Android

If you want somewhat simple Android app example, I would suggest my TODO app (specifically develop branch): https://github.com/mdukat/dukatodo/blob/develop/main.go. Walk through main function, look at how I manage windows (screens) with each one defined in their own function. I have no idea if it's good or bad design for simple app, but it works for me, and allows me to split the code into dedicated blocks of helper functions, windows, and main loop.

Docker Containerization

Check out https://docs.docker.com/guides/golang/, specifically segment about Multi-stage Builds. It allows to build absurdly lightweight docker containers with Go apps.

Go Vulnerability Analysis

Go has dedicated tool for static code and binary analysis - available at https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck. More information is available in security documentation: https://go.dev/doc/security/vuln/.

Libraries, tools and more learning materials

Check out https://awesome-go.com. Website contains categorized links to libraries, tools, talks and learning materials.

public/programming/go/learn-go.txt · Last modified: by mdukat