Go: Difference between revisions
No edit summary |
|||
(17 intermediate revisions by the same user not shown) | |||
Line 35: | Line 35: | ||
"math" | "math" | ||
) | ) | ||
The group format is preferred and used by gofmt. | |||
Names in packages are exported if they begin with a capital letter. | Names in packages are exported if they begin with a capital letter. | ||
== Cross compiling == | |||
Cross compiling is easy with Go, using two environment variables: | |||
<code>GOOS</code>: The operating system to target. Options are: <code>windows</code> (Microsoft Windows), <code>darwin</code> (macOS) and <code>linux</code>. | |||
<code>GOARCH</code>: 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 == | |||
* [https://github.com/getlantern/systray systray] - Place your Go application in the system tray. Cross-platform. | |||
== Articles == | == Articles == | ||
Line 42: | Line 101: | ||
* [https://github.com/enocom/gopher-reading-list A Gopher's Reading List] | * [https://github.com/enocom/gopher-reading-list A Gopher's Reading List] | ||
* [https://medium.com/@IndianGuru/best-practices-for-a-new-go-developer-8660384302fc Best practices for a new Go developer] | * [https://medium.com/@IndianGuru/best-practices-for-a-new-go-developer-8660384302fc Best practices for a new Go developer] | ||
* [https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5 Packaging a Go application for macOS] | |||
* [https://words.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/ Shrink your Go binaries with this one weird trick] | |||
* [https://blog.felixge.de/go-arm64-function-call-assembly/ Go arm64 Function Call Assembly] | |||
* [https://freshman.tech/web-development-with-go/ How to Build Your First Web Application with Go] | |||
* [https://www.madhur.co.in/blog/2023/06/10/processing-huge-log-files.html Process huge log files] | |||
* [https://trinitroglycerin.github.io/2023/06/10/Go-Using-pointers-to-reduce-copies-is-premature-optimization/ Go: Using pointers to reduce copies is premature optimization] | |||
* [https://technology.blog.gov.uk/2013/12/05/building-a-new-router-for-gov-uk/ Building a new router for GOV.UK] | |||
* [https://lemire.me/blog/2023/02/07/bit-hacking-with-go-code/ Bit Hacking with Go code] | |||
* [https://stephenn.com/2023/06/gopher-wrangling.-effective-error-handling-in-go/ Gopher Wrangling. Effective error handling in Go] | |||
== Talks == | == Talks == | ||
Line 54: | Line 122: | ||
* [http://tour.golang.org/welcome/1 A tour of Go] | * [http://tour.golang.org/welcome/1 A tour of Go] | ||
* [http://golang.org/doc/effective_go.html Effective Go] | * [http://golang.org/doc/effective_go.html Effective Go] | ||
* [https://dave.cheney.net/high-performance-go-workshop/gophercon-2019.html High Performance Go Workshop] | |||
== Books == | == Books == | ||
Line 59: | Line 128: | ||
* [https://miek.nl/go/ Learning Go] | * [https://miek.nl/go/ Learning Go] | ||
[[Category:Programming]] | [[Category:Programming]] |
Latest revision as of 16:09, 20 June 2023
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
- A Gopher's Reading List
- Best practices for a new Go developer
- Packaging a Go application for macOS
- Shrink your Go binaries with this one weird trick
- Go arm64 Function Call Assembly
- How to Build Your First Web Application with Go
- Process huge log files
- Go: Using pointers to reduce copies is premature optimization
- Building a new router for GOV.UK
- Bit Hacking with Go code
- Gopher Wrangling. Effective error handling in Go