Go

From Rixort Wiki
Jump to navigation Jump to search

Variables

Variables are defined as:

var name type = value

For example:

var x string = "Hello"

The type can be inferred if an initial value is given, e.g.

var x = "Hello"

or by using the := operator:

x := "Hello"

Constants can be defined by using the const keyword instead of var.

Loops

Go only supports the for loop - unlike other languages it lacks while, do while etc. However, it is possible to emulate other loop constructs using for.

Imports

Standard import notation:

import "fmt"

Multiple imports can be done either one line at a time or as a group:

import (
  "fmt"
  "math"
)

The group format is preferred and used by gofmt.

Names in packages are exported if they begin with a capital letter.

Cross compiling

Cross compiling is easy with Go, using two environment variables:

GOOS: The operating system to target. Options are: windows (Microsoft Windows), darwin (macOS) and linux.

GOARCH: The architecture to target.

GUI programming

Walk

  • Only works on Windows(?)

andlabs UI

  • Cross-platform
  • No commits since June 2020
  • Lots of unresolved issues on GitHub

Qt

  • therecipe/qt on GitHub
  • No commits since September 2020
  • Qt licensing unclear

Shiny

  • Experimental
  • Current state of development unclear

Nuklear

  • No commits since March 2020

Fyne

Dependencies on Ubuntu:

  • libgl1-mesa-dev
  • xorg-dev

GTK

  • Can't cross-compile(?)

Dependencies for GTK on Ubuntu:

  • libglib2.0-dev
  • libgdk-pixbuf-2.0-dev (or libgdk-pixbuf2.0-dev)
  • libpango1.0-dev
  • libgtk2.0-dev

Libraries

  • systray - Place your Go application in the system tray. Cross-platform.

Articles

Talks

Tutorials

Books