-
Notifications
You must be signed in to change notification settings - Fork 265
How the CLI works
Probably you think that Create Go App CLI is a "black box" that magically creates objects out of thin air. But that's not really true. The whole project is built on UNIX principles that each element must have a clear function that it does well.
So, basically the CLI contains three main parts, which we will describe in more detail below:
- Pre-configured backend part
- Frontend part generated by Vite.js
- Deploy-ready Ansible roles
The backend part is full-fledged prepared templates with popular Go web frameworks, which were created by the authors of Create Go App and placed in the project organization on GitHub.
In the background, the usual git clone <URL>
will happen, but followed by a cleanup of unnecessary folders so that you can start implementing your logic right away. You get right out of the box: CRUD methods with implementation examples, JWT authorization and token update, database configuration, auto-generated documentation for REST API from Swagger, clear, and simple project structure.
Make sure that you have Golang version
1.17.x
or higher installed on your computer.
You can choose between:
Name | Version | Link to Go template |
---|---|---|
Fiber | latest |
create-go-app/fiber-go-template |
net/http | latest |
create-go-app/net_http-go-template |
The frontend part will be generated using wonderful tool Vite.js under the hood.
Note that the CLI does not do any transformations with this part of your project. That is, you have to write the frontend yourself from scratch, Create Go App only helps in organizing the structure and simplifies project generation.
This will use the usual Node.js command npm init vite@latest <FOLDER> -- --template <TEMPLATE>
.
Make sure that you have Node.js version
12.x
or higher and npm7.x
or higher installed on your computer.
You can choose between:
Name | Version | Link to JavaScript template | Link to TypeScript template |
---|---|---|---|
Pure (vanilla) | - | vanilla |
vanilla-ts |
React | latest |
react |
react-ts |
Preact | latest |
preact |
preact-ts |
Vue.js | latest |
vue |
vue-ts |
Svelte | latest |
svelte |
svelte-ts |
Lit | latest |
lit |
lit-ts |
And the latest Next.js and Nuxt 3 frontend parts will be generated using the create-next-app and nuxi utilities.
The most interesting part, which contains several atomic Ansible roles, inventory, and playbook for successful deployment of your project to a remote server. All the necessary role files are stored in the binary itself and are copied instantly, which is why the CLI is so fast! Roles were created by the authors of Create Go App and verified by numerous test and production runs on real servers.
The CLI currently includes roles for:
- Initial configuration of the remote server;
- Docker settings to create containers;
- Proxy server settings (Traefik Proxy, Nginx);
- Settings for creating a container with the backend part;
Make sure you have Ansible version
2.9
or higher and Python3.8
or higher installed to work successfully.
After filling out the inventory in the hosts.ini
file and running the cgapp deploy
command from the project root folder, the roles are analyzed and Ansible is called to do the rest of the work. Be patient because this process can take anywhere from 30 seconds, depending on the performance of your remote server.
Sometimes it happens, it's true... but don't get upset! 🙂
Wiki is a dynamically growing section, so write us your question and we'll try to answer it. If the question is interesting and/or repeated too often, we'll add it to a FAQ section (with reference to the author's issue).
The best way to ask a question is to create a new issue or a discussion in GitHub repository.
So, follow this checklist to ask a question that we can answer in the shortest possible time:
- Try to search similar question in the Create Go App CLI issues section.
- If your question is about Ansible, Docker, Go, JavaScript, TypeScript, or else, try to search at StackOverflow first.
- Please fully follow our template to create a new issue.
- If English is not your native language, please use online translator in advance (for example, DeepL or Google Translate).
- Demonstrate understanding to authors, because this is Open Source and not-for-profit product, and their support is not paid.
- Be nice to the other members of our community.