Logo

dev-resources.site

for different kinds of informations.

Initialize a Go project with “go-blueprint”

Published at
6/25/2024
Categories
go
beginners
initgo
goblueprint
Author
Quang Hieu (Bee)
Categories
4 categories in total
go
open
beginners
open
initgo
open
goblueprint
open
Initialize a Go project with “go-blueprint”

Image description

Step-by-step guide to initiating a Go project. Make sure you have Go installed on your machine. You can download it from the official Go website 👉 https://golang.org/dl/
Step 1: Open terminal:

Image description

Step 2: Install go-blueprint with the following command:

go install github.com/melkeydev/go-blueprint@latest

Image description

Step 3: Open the "go-blueprint" tool on the browser with the following link:

https://go-blueprint.dev/

Step 4: Fill in the necessary information of the project into the form such as projectName, database, framework, and some advanced options if used:

Image description

  • From the information we filled in the form, we will receive an order as shown in the picture.

Image description

Step 5: Copy the command, paste it into the terminal and press enter:

go-blueprint create --name my_project --framework gin --driver mongo

Image description

  • If you encounter the "command not found" error as below, follow the next steps in step 5. Otherwise, you can proceed to step 6

Image description

Step 5.1: Run command:

GOPATH=$HOME/go

Step 5.2: Run command:

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

Image description

So it's already fixed. You can refer to the error at the link: here

Step 5.3: Then run the command:

go-blueprint create --name my_project --framework gin --driver mongo

Step 6: When run successfully, we will get results as shown:

Image description

Step 7: Open the project with Visual Studio Code

  • Enter the "my_project" directory using the command
cd my_project
  • Open the project quickly with Visual Studio Code using command
code .

Image description

  • This is the result received

Image description

  • That's a great tool. So we have successfully initiated a Go project with "go-blueprint". To continue running the project we just initiated, we perform the following steps

Step 8: Open the main.go file in the cmd/api folder and add the following line:

fmt.Println("Hello, World!")

Image description

Step 9: Open terminal and run command:

make run

Image description

We have finally completed the initialization of the Go project and successfully ran the project.

You can refer to "Go-blueprint" here 👉 Go-blueprint

If you found this article useful and interesting, please share it with your friends and family. I hope you found it helpful. Thanks for reading 🙏

Let's get connected! You can find me on:

Featured ones: