Golang, also known as Go, is an open-source programming language developed by Google in 2007. It is designed to be a fast, efficient, and modern language for building large-scale software projects. Golang is a statically-typed language, which means that the type of a variable is known at compile time. This feature helps reduce errors and improve the reliability of code. Golang is often used for developing network and web applications, distributed systems, and cloud services.
Golang (AlmaLinux 8)
- OS: almalinux 8
Description
Software included
Package | Version |
---|---|
Golang | 1.20 |
Docker | 3.20.10 |
Docker compose | 2.12.2 |
containerd.io | 1.6.10 |
Initial start of the service
This application uses Docker to provide faster startup of the underlying software (Golang) and direct use. This eliminates the need to familiarize yourself with its specifics in terms of configuration and installation. This app only provides CLI for Golang. To start working with it directly, you can use the docker exec -ti docker-golang-golang-1 go <COMMAND>
command, replacing <COMMAND>
with the command to pass to the Golang CLI.
Quick settings and frequently asked questions
- Logging into the cloud service is done using an SSH key or password that you have specified.
- Docker is installed as recommended by the official docker documentation.
- The standard
docker
anddocker compose
commands are now available in this application. - When the virtual machine is first started, it takes a few minutes before a Docker container containing Golang is started.
Additional helpful tips
- If you want to use the Golang CLI, you can do it with the quick command
docker exec -ti docker-golang-golang-1 go <COMMAND>
. - If you often use the Golang CLI, you can also make a quick shortcut by adding an alias as follows:
echo "alias go='docker exec -ti docker-golang-golang-1 go'" >> ~/.bashrc
Working with Docker
The organization of this application is entirely done using Docker. In this way, we can provide you with ready-made applications faster. In addition, their configuration is more flexible and quite controllable. To be able to control this application, however, you need to know some basic Docker functionalities and features.
Restarting all services
Restarting the database and the Docker container that contains Golang itself, along with the rest of the software, can be done in two ways:
- By restarting the entire virtual machine
- Restarting the Docker containers, which is the faster option. To do this, access your machine via SSH, and run the following commands:
sudo su -
cd /opt/docker-golang
docker compose restart
Recreating Docker containers
Recreation of a docker container may be necessary if you've changed the configuration inside the docker-compose.yml
file. If there are changes, please follow these steps:
cd /opt/docker-golang/
docker compose stop
docker compose up -d
Checking the status of the Docker application
To check, you need to run the following commands:
sudo su -
docker ps -a
Please pay attention to the STATUS
column. It should show how long the service has been running, for example Up X minutes
. If the status is Restarting
then you need to check what is wrong with the application. In such a case, you can check by following the application logs as follows:
- Get the application name that you can see in the
NAMES
column from the output of thedocker ps -a
command. View the logs with thedocker logs <NAME>
command, whereis the name of the container.