Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bmuschko/lets-gopher-exercise
A flexible project generator for Go.
https://github.com/bmuschko/lets-gopher-exercise
Last synced: 7 days ago
JSON representation
A flexible project generator for Go.
- Host: GitHub
- URL: https://github.com/bmuschko/lets-gopher-exercise
- Owner: bmuschko
- License: apache-2.0
- Created: 2019-01-13T23:46:14.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T02:02:52.000Z (over 1 year ago)
- Last Synced: 2024-06-19T00:28:35.274Z (5 months ago)
- Language: Go
- Homepage:
- Size: 1.96 MB
- Stars: 12
- Watchers: 2
- Forks: 27
- Open Issues: 4
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Let's Gopher
IMPORTANT: This code repository is used as an example project for the training https://github.com/bmuschko/go-project-automation/["Go project automation"]. It's not intended for real-world use. For a full-fledged Go project generator have a look at https://github.com/bmuschko/letsgopher[this repository].
Let's Gopher is a simple, yet flexible project generator for Go. The tool uses templates available in the directory `~/.lets-gopher/templates`. Users can create templates manually by creating directories and files as desired. Templates hosted on Git repositories can be downloaded and added to the template directory.
This project is based on https://github.com/golang/go/wiki/Modules[Go Modules]. Please enable Go Modules by setting the environment variable `export GO111MODULES=on`.
== Installing a template
The project doesn't come with any templates out-of-the-box. You need to install them yourself. The tool will report missing templates in the console output.
----
go run main.go
2019/01/17 13:30:20 No templates found!
----Templates can only be installed from a Git URL. To install a template, run the `install` command with the `--url` parameter. The tool will clone the repository.
----
go run main.go install --url="https://github.com/bmuschko/go-helloworld-template.git"
2019/01/17 13:32:21 Cloning template from repository https://github.com/bmuschko/go-helloworld-template.git
----Subsequent `install` operations pull the latest change from the originating repository.
----
go run main.go install --url="https://github.com/bmuschko/go-helloworld-template.git"
2019/01/17 13:32:25 Pulling latest changes for existing template in /Users/bmuschko/.lets-gopher/templates/go-helloworld-template
----Alternatively, you can just create a new directory under `~/.lets-gopher/templates` and populate it with files.
== Generating projects from a template
You can generate a new project from the template if at least one template can be found. The files of a selected template will be written to `$GOPATH/src/`.
----
go run main.go
? What template would you like to use to generate a project? [Use arrows to move, type to filter]
❯ go-helloworld-template
You choose "go-helloworld-template"
? What base path would like to use? github.com/bmuschko/helloworld
You choose "github.com/bmuschko/helloworld"
Generating project in "/Users/bmuschko/go/src/github.com/bmuschko/helloworld"
----== Configuring default conventions
You might get tired of having to spell out certain default values. For example, you'll likely want to use the same domain whenever you generate a new project. The tool can be configured in the file `~/.lets-gopher/.lets-gopher.yml`.
[source,yaml]
----
domain: github.com/bmuschko
----Configured default values are consumed as applicable but can still be reconfigured.
----
go run main.go
? What template would you like to use to generate a project? [Use arrows to move, type to filter]
❯ go-helloworld-template
You choose "go-helloworld-template"
? What base path would like to use? (github.com/bmuschko/go-helloworld-template)
You choose "github.com/bmuschko/go-helloworld-template"
Generating project in "/Users/bmuschko/go/src/github.com/bmuschko/go-helloworld-template"
----