DEV Community

renanbastos93
renanbastos93

Posted on • Edited on

Boneless: a CLI to create your apps with Go

Boneless is a powerful tool that offers a wide range of features to facilitate application development. In this blog post, we will explore some essential tools that can be used in conjunction with Boneless: Service Weaver, Go Migrate, SQLC, and Fiber. Let's discover how these tools can boost productivity and efficiency in application development.


After setting the context and providing a comprehensive introduction, we will demonstrate how to use our CLI. First, we need to install the necessary CLI tools.


By the way, first, we need to install the binary of Service Weaver, Go Migrate, SQLC, and Boneless. Even so, I suggest you read the documentation of all of them on your official websites.

$ go install -tags 'mysql sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
$ go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
$ go install github.com/ServiceWeaver/weaver/cmd/weaver@latest
$ go install github.com/renanbastos93/boneless/cmd/boneless@latest
Enter fullscreen mode Exit fullscreen mode

Well, let's go on an adventure


Create scratch project

Always remember to check the available methods by executing boneless help. After that, we can proceed to create a new folder and a go.mod file.

$ mkdir -p myapp
$ cd myapp
$ go mod tidy myapp

# "Now we can start utilizing commands from Boneless
$ boneless create-scratch
Enter fullscreen mode Exit fullscreen mode

After creating the project, we can go ahead and execute it.

$ SERVICEWEAVER_CONFIG="./weaver.toml" boneless run
Enter fullscreen mode Exit fullscreen mode

Adding a New app

If you want to add a new component to your application built with Boneless, the process is straightforward. Here are the steps you can follow

$ boneless create-app user
Enter fullscreen mode Exit fullscreen mode

After that, you need to make changes according to your requirements.

In addition, there are other Boneless commands available that you can use when they are truly necessary. See below:

$ boneless help
Usage: boneless [target]

Targets:
  help                                     Show commands for use
  version                                  Show version
  new  <sql|sqlite3>                       Create a project from scratch using Weaver, SQLC, and go-migrate
  create-scratch <sql|sqlite3>             Create a project from scratch using Weaver, SQLC, and go-migrate
  build                                    Build the Weaver component with SQLC
  make-migrate <app-name> <name>           Create a new migration for an app
  migrate <app-name> <up|down>             Run migrations for an app
  create-app <app-name>                    Create a new app based on a template
  build-app <app-name>                     Build an app using Weaver and SQLC
  run                                      Run the project using Weaver

Parameters:
  <app-name>                               Name of the app to create or run migrations on
  <name>                                   Name of the migration to create
  <up|down>                                Specify "up" to apply migrations or "down" to rollback migrations
  <sql|sqlite>                             Specify "sql" to use some SQL "sqlite3" to use sqlite3 and it is the default

Examples:
  boneless help
  boneless version
  boneless create-scratch
  boneless build
  boneless make-migrate my-app migration-name
  boneless migrate my-app up
  boneless create-app my-app
  boneless build-app my-app
  boneless run
Enter fullscreen mode Exit fullscreen mode

Conclusion

In summary, we have explored the powerful tools available for application development using Boneless. We discussed the Command Line Interface (CLI) that facilitates the creation of web applications, along with Service Weaver, Go Migrate, SQLC, and Fiber. These tools provide essential features to boost productivity and efficiency in developing distributed applications, managing database migrations, generating secure code, and building fast web applications.

By utilizing these tools together, developers have a wide range of resources at their disposal to create robust, scalable, and secure applications. Through the Boneless CLI, you can initiate projects, manage database migrations, and leverage the benefits of Service Weaver and Fiber to build efficient and responsive APIs.

We hope this article has provided a comprehensive overview of these tools and sparked your interest in further exploring the potential of Boneless and its components. With the right combination of tools and knowledge, you will be well-positioned to develop high-quality web applications.

Top comments (21)

Collapse
 
ebourgess profile image
Elias Bourgess

One of the main reasons I didn't use Golang for development projects was because of having to add all these dependencies manually. Thank you for creating and sharing this tool, this will come really helpful for me later on.

Collapse
 
ewaldhorn profile image
Ewald

That's interesting. The main reason I love Go is because I have complete control over dependencies, as they vary per project.

It's always so neat to see different perspectives. If I may ask, what did you end up using instead of Go?

Collapse
 
ebourgess profile image
Elias Bourgess

I mainly looked for Typescript due to the ease of it. Or if I was to build something big I used to use Symfony (the PHP framework).

These days I barely do any big projects due to focusing more on Ansible automation in my day to day work, and not having any energy to do personal projects outside of working hours.

Thread Thread
 
ewaldhorn profile image
Ewald

Ah I see. I hope you get some time to do fun personal projects again!

Thread Thread
 
renanbastos93 profile image
renanbastos93

Nice, interesting man. Well, What did you think about Boneless? I will be happy to know

Thread Thread
 
ewaldhorn profile image
Ewald

It looks interesting, I haven't had time to play with it yet, I have too many side projects already!!

Thread Thread
 
renanbastos93 profile image
renanbastos93

of course, no worries dude. Well, when you test it share your opinion, open issues, etc. Thanks.

Thread Thread
 
ewaldhorn profile image
Ewald

Will do!

Collapse
 
renanbastos93 profile image
renanbastos93

Currently, I primarily use Go with minimal dependencies to create projects from scratch. I believe in continuously improving my projects with small, incremental changes. However, I'm interested in providing more flexibility for others to choose their preferred dependencies.

If you're interested in contributing or suggesting changes, I encourage you to either reach out to me directly or open an issue on GitHub. I appreciate collaborative input and value the opportunity to enhance the project based on the needs and perspectives of the community. Your contributions and feedback are always welcome."

Thread Thread
 
ewaldhorn profile image
Ewald

Awesome, I'll keep that in mind!

Collapse
 
renanbastos93 profile image
renanbastos93

Thank you for your message! I completely understand your concern about managing dependencies in Golang. It can be a time-consuming task. I'm glad to hear that you found the tool I created helpful. I appreciate your kind words, and I'm confident it will make your future development projects much easier. If you have any questions or need further assistance, feel free to let me know

Collapse
 
gerimate profile image
Geri Máté

Looks amazing, congrats!

Collapse
 
renanbastos93 profile image
renanbastos93

Thank you so much! If you have any questions or if there's anything else I can assist you with, please feel free to reach out.

Collapse
 
guipassos profile image
Guilherme C. Passos

Great Job my friend!
This CLI is exceptionally, functional and user-friendly!

Collapse
 
renanbastos93 profile image
renanbastos93

Thank you so much! I'm glad you think so. I put a lot of effort into making this CLI exceptionally functional and user-friendly, so it's great to hear that you appreciate it. Your kind words mean a lot to me.

Collapse
 
ewaldhorn profile image
Ewald

This is a neat tool, I can see it being of benefit, especially to new Go developers, but also for older hands who just want to get the config done and get coding already.

Nicely done!

Collapse
 
renanbastos93 profile image
renanbastos93

Awesome, thanks for you feedback.

Collapse
 
k1lgor profile image
k1lgor

Is this boneless similar to cobra

Collapse
 
renanbastos93 profile image
renanbastos93

Why do you think about that?

Collapse
 
k1lgor profile image
k1lgor

answering with queston, nice..

Thread Thread
 
renanbastos93 profile image
renanbastos93

I am sorry dude. I did a mistake with you.
Well, Boneless and Cobra are not the same. Boneless is a CLI tool with the goal of facilitating the creation of web applications. It is often used in conjunction with other technologies like Service Weaver, Go Migrate, SQLC, and Fiber. Boneless provides functionality specific to web application development.

On the other hand, Cobra is a CLI library in the Go programming language that helps create other CLI tools. It provides a framework for building powerful and flexible command-line interfaces with features such as command hierarchies and flags. Cobra is focused on enabling the development of general-purpose CLI applications.

So, while both Boneless and Cobra are CLI-related tools, they have different purposes and functionalities. Boneless is geared towards web application development, while Cobra is a library for creating various types of CLI tools.