DEV Community

Cover image for Initialize a Go project with “go-blueprint”
Quang Hieu (Bee)
Quang Hieu (Bee)

Posted on

13

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
Enter fullscreen mode Exit fullscreen mode

Image description

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

https://go-blueprint.dev/
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Step 5.2: Run command:

PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • Open the project quickly with Visual Studio Code using command
code .
Enter fullscreen mode Exit fullscreen mode

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!")
Enter fullscreen mode Exit fullscreen mode

Image description

Step 9: Open terminal and run command:

make run
Enter fullscreen mode Exit fullscreen mode

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:

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
micah_shallom profile image
Shallom Micah Bawa

awesome tool

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more