In order to tell Go that this is a Go module, you will need to create a Go module using the go mod command:

go mod init greeter
In order to tell Go that this is a Go module, you will need to create a Go module using the go mod command:

go mod init greeter
Let’s take a closer look at the module method. If you had a go.mod file in your project with a module declaration such as the following:

module github.com/sammy/shark
If you are running macOS or Linux, you will find a new executable file that has been named after the directory in which you built your program:

Outputgreeter  main.go
Run the following go build command with the -o flag:

go build -o bin/hello
To find where your $GOPATH directory is located, run the following command:

go env GOPATH
The output you receive will vary, but the default is the go directory inside of your $HOME directory:

Output$HOME/go
Now, that you’ve created your executable, run it to make sure the binary has been built correctly. On macOS or Linux, run the following command:

./greeter
The output of the binary will match the output from when you ran the program with go run:

OutputHello, World!
This will build your binary and place it in $GOPATH/bin. To test this, run the following:

ls $GOPATH/bin

Recommend

How To Build and Install Go Programs Step 1 — Setting Up and Running the Go Binary

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Conclusion Want to learn more? Join the DigitalOcean Community! Still looking for an answer?

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Step 5 — Verifying Certbot Auto-Renewal

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Step 4 — Obtaining an SSL Certificate

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Step 3 — Allowing HTTPS Through the Firewall

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Step 2 — Confirming Nginx’s Configuration

How To Set Up Let's Encrypt with Nginx Server Blocks on Ubuntu 16.04 Step 1 — Installing Certbot

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 8 — Suppression d’une tâche

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 7 — Affichage des tâches terminées

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 6 — Affichage des tâches en attente uniquement

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 5 — Fin d’une tâche

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 4 — Liste de toutes les tâches

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 3 — Création d’une tâche

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 2 — Création d’un programme CLI

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Étape 1 — Installation du pilote Go de MongoDB

Comment utiliser Go avec MongoDB en utilisant le pilote MongoDB Go Conditions préalables

Como instalar o Linux, o Nginx, o MySQL e a pilha PHP (LEMP) no CentOS 8 [Início rápido] Passo 4 — Testar o PHP com o Nginx

Como instalar o Linux, o Nginx, o MySQL e a pilha PHP (LEMP) no CentOS 8 [Início rápido] Passo 3 — Instalar o PHP-FPM

Como instalar o Linux, o Nginx, o MySQL e a pilha PHP (LEMP) no CentOS 8 [Início rápido] Passo 2 — Instalar o MariaDB

Como instalar o Linux, o Nginx, o MySQL e a pilha PHP (LEMP) no CentOS 8 [Início rápido] Passo 1 — Instalar o Nginx

Lidando com a função Panics em Go Detectando panics com o recover

Lidando com a função Panics em Go Lidando com os panics

Lidando com a função Panics em Go Funções adiadas