-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc #6
Open
4k1k0
wants to merge
1
commit into
main
Choose a base branch
from
doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Doc #6
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,79 @@ | ||
# just-go | ||
|
||
## Descripción | ||
Este proyecto tiene como objetivo crear un cookie cutter para proyectos desarrollados en Go, basado en la estructura recomendada de [Standard Go Layout ](https://github.com/golang-standards/project-layout). just-go proporciona una estructura base para proyectos Go, que incluye scripts de construcción y pruebas automatizadas, lo que permite a los desarrolladores comenzar a trabajar en su código rápidamente, sin preocuparse por la configuración de la estructura del proyecto. | ||
|
||
Esta herramienta facilita el desarrollo de proyectos Go, ahorrando tiempo y esfuerzo en la creación de la estructura del proyecto. Además, el uso de una estructura de proyecto estándar también facilita la colaboración en equipo, ya que todos los miembros del equipo estan familiarizados con la estructura del proyecto. | ||
Este proyecto expone la funcionalidad para crear herramientas CLI para generar proyectos personalizados. No necesariamente de Golang, puede implementarse para cualquier tipo de proyecto. | ||
|
||
## Requisitos previos | ||
## Uso | ||
|
||
Instala `just-go` como biblioteca para tu generador. | ||
|
||
## Instalación | ||
```shell | ||
$ go get github.com/gophers-mx/just-go | ||
``` | ||
|
||
Crea una estructura con los campos necesarios para tus archivos template. | ||
|
||
```golang | ||
type Details struct { | ||
Name string | ||
} | ||
``` | ||
|
||
Crea un directorio de assets con tus templates de proyecto para utilizarlo en tu proyecto. | ||
|
||
```golang | ||
//go:embed assets/* | ||
var assets embed.FS | ||
``` | ||
|
||
Crea una estructura que implemente la interfaz `Generator` con el m'etodo `Run(cfg *config.Cfg)` y utiliza las funciones del paquete `files` para poder realizar las copias de archivos, directorios y generaci'on de templates. | ||
|
||
```golang | ||
package cli | ||
|
||
import ( | ||
"github.com/gophers-mx/just-go/config" | ||
"github.com/gophers-mx/just-go/pkg/files" | ||
) | ||
|
||
type CustomGenerator struct {} | ||
|
||
func (lg *CustomGenerator) Run(cfg *config.Cfg) { | ||
files.GenFromTemplate("assets", "", "README.md") | ||
files.CopyDirectory("assets/cmd", "cmd") | ||
files.CopyFile("assets", "", "hello.md") | ||
} | ||
``` | ||
|
||
Crea una instancia de la estructura `Generathor` y ejecuta su m'etodo `Run()`. | ||
|
||
```golang | ||
func main() { | ||
generathor := &justgo.Generathor{ | ||
Assets: assets, | ||
ProjectName: "hello world", | ||
Generator: cli.NewGeneratorCLI(), | ||
TemplateDetails: Details{ | ||
Name: "hello world", | ||
}, | ||
} | ||
|
||
generathor.Run() | ||
} | ||
``` | ||
|
||
Puedes encontrar un ejemplo completo [aqui](https://github.com/4k1k0/gen-cli). | ||
|
||
## Uso | ||
Para generar un nuevo proyecto, se ejecuta el comando ```just-go init --type cli --name nombre_proyecto``` | ||
|
||
## Contribuir | ||
Si quieres contribuir al proyecto, puedes enviar tu pull request. Las sugerencias tambi? son bienvenidas. | ||
|
||
Si quieres contribuir al proyecto, puedes enviar tu pull request. Las sugerencias son bienvenidas. | ||
|
||
## Licencia | ||
[![GPLv3](https://www.gnu.org/graphics/gplv3-127x51.png "Licencia GNU General Public License")](https://www.gnu.org/licenses/gpl-3.0.html) | ||
|
||
[![GPLv3](https://www.gnu.org/graphics/gplv3-127x51.png "Licencia GNU General Public License")](https://www.gnu.org/licenses/gpl-3.0.html) | ||
|
||
## Contacto | ||
[Gohpers MX en Telegram](https://t.me/golangmx) | ||
|
||
[Gohpers MX en Telegram](https://t.me/golangmx) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por qué exponer el proyecto como una librería si estaba pensado a ser una CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Para ser más flexibles con los templates. Aunque estaba pensando menter un cli aquí mismo con un template. Así puede ser ambas. ¿Cómo ven?