Skip to content

Development Environment Configuration

dscabral edited this page Nov 19, 2021 · 3 revisions

Development Environment Configuration

Golang

The installation process is quite simple. The first step it's to choose the go version that you wanna install. Just access the official site, and choose the desired version ( https://golang.org/dl/go1.16.5.linux-amd64.tar.gz). The recommendation it's always to download the most updated version.

To download on Linux, execute the command below on the terminal:

# select the version that you would like to install
VERSAO_GO=1.16.5
cd ~
curl -O "[https://golang.org/dl/go${VERSAO_GO}.linux-amd64.tar.gz](https://golang.org/dl/go1.16.5.linux-amd64.tar.gz)"

Now unpack the files with the following command:

tar xvf "go${VERSAO_GO}.linux-amd64.tar.gz"

Next, move the files to the bin directory of your Linux user:

sudo mv go /usr/local

Now test your go installation:

go version

In case of error, try to export the go path with the command below:

PATH=$PATH:/usr/local/go/bin

Development IDE

IntelliJ IDEA

Visual Studio Code

You can install using the following link:

https://code.visualstudio.com/download

Confirm that the VS Code was successful installed executing the command:

code .

Install the

For VS Code, you need to install some extensions. Install Luke Hoban. with the command below:

code --install-extension ms-vscode.go

When opening a Go file for the first time on VS Code, it will indicate which analysis tools are missing. Click on the button to install. You can check the complete list of tools here.

Go Debugger

A good option to debug your programs in Go is Delve. It can be installed by using the go get command:

go get -u github.com/go-delve/delve/cmd/dlv

Database tools

GIT Client

Or can use the command line, and in case of mistakes, OhShitGit! may help, it mentions strategies for getting out of git messes, tangles and other problems.

https://ohshitgit.com/

API Client

Bash

It's a script to help you to see your branch directly on your bash

  1. Step

    1. Put this script at the end of your bashrc (~/.bashrc)
    force_color_prompt=yes
    color_prompt=yes
    parse_git_branch() {
        git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
    }
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
    fi
    unset color_prompt force_color_prompt
  2. Step

    Execute this command:

    source ~/.bashrc

Starship

The minimal, blazing-fast, and infinitely customizable prompt for any shell!

https://starship.rs/demo.webm

https://starship.rs/

Yakuake

Yakuake is a top-down terminal for KDE in the style of Guake for GNOME, Tilda, or the terminal used in Quake

https://www.youtube.com/watch?v=FPT1nJP8ogw&ab_channel=StefanoBiancorosso

sudo apt install yakuake

Docker

The official installation link is:

https://docs.docker.com/engine/install/ubuntu/

Config the repositories

  1. Update and install the packages:

    sudo apt-get update
    
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg \
        lsb-release
  2. Add the official docker GPG key:

    curl -fsSL [https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg) | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  3. Add a stable Docker repository:

    echo \
      "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

  1. Update and install the docker packages:

    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io
  2. Check the Docker installation with the hello-world image:

    sudo docker run hello-world

Follow this Linux postinstall tutorial, to use Docker without sudo command (Linux postinstall)

Troubleshooting

If at the end of the installation you get the message below:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

Try to start the Docker service using:

systemctl start docker

or

sudo service docker start

Docker compose

  1. Run this command to download the current stable release of Docker Compose:

    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

To install a different version of Compose, substitute 1.29.2 with the version of Compose you want to use.

  1. Apply executable permissions to the binary:

    sudo chmod +x /usr/local/bin/docker-compose

Note: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path.

For example:

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  1. Test the installation.

    docker-compose --version
    docker-compose version 1.29.2, build 1110ad01

gRPC CLI Tool

We recommend the grpclient to consume the gRPC server as a client. grpcurl is a command-line tool that lets you interact with gRPC servers. It's basically curl for gRPC servers.

The main purpose for this tool is to invoke RPC methods on a gRPC server from the command-line. gRPC servers use a binary encoding on the wire (protocol buffers, or "protobufs" for short). So they are basically impossible to interact with using regular curl (and older versions of curl that do not support HTTP/2 are of course non-starters). This program accepts messages using JSON encoding, which is much more friendly for both humans and scripts.

  1. Install grpcurl To install grpcurl, use the command below:
go get github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
go install github.com/fullstorydev/grpcurl/cmd/grpcurl
  1. Usage To use the grpcurl, it's quite simple, like a curl, you just need to point to the url, port server and function that you want to call. e.g.
grpcurl -plaintext -d '{"policyID": "44363f4f-9d5e-4d6a-9a2c-74ed781ee368", "ownerID":"dea2aefd-0480-43da-aa41-bd6b2a11907"}' localhost:8282 policies.PolicyService/RetrieveDatasetsByPolicyID

Note: If you face any problem related to TLS, just add the -plaintext arg to your command.

In case you don't know the specific function that you would like to use, you can list the availiable functions with the command below:

grpcurl -plaintext localhost:8282 list policies.PolicyService

For more infos, you can access the repo on the grpcurl github page