Go - constant variables and const keyword

Brief Programming languages have the notion of constants which means “variables that can not be mutated once declared and initialized”. Go also has almost the same meaning, but in a different context. To initialize a variable as a constant with a value of 10, we can do something like this: const DISCOUNT = 10 In Go, constants mean “storing a literal to a variable”, this can be seen as a version of pattern matching in Erlang....

May 12, 2024 · 2 min · Aleem Isiaka

Running Go programs with a specific version

Brief Although Go releases are incremental and follow the Go compatibility promise: unless the change is required for a bug or security fix, the version starting with 1 won’t experience any backward-breaking change to the language or standard library, you can have a reason to use an old version of the language. Is there a clean way to do this? Recommendation I recommend a tool like go version manager that helps to manage a systemwide version of the language....

May 10, 2024 · 2 min · Aleem Isiaka

Autocompile Go

First, install CompileDaemon: $ go get github.com/githubnemo/CompileDaemon && go install github.com/githubnemo/CompileDaemon Then, from the root of the project, create a Make file: $ touch Makefile And add the below content: GOCMD ?= go GOBUILD = $(GOCMD) build GOCLEAN = $(GOCMD) clean GOTEST = $(GOCMD) test GOGET = $(GOCMD) get BINARY_NAME = project_name BINARY_UNIX = $(BINARY_NAME)_unix default: all all: test build build: $(GOBUILD) -o ../$(BINARY_NAME) -v -ldflags="-X main.VERSION=$(TAG)" test: $(GOTEST) -v ....

August 21, 2021 · 1 min · Aleem Isiaka