Git Product home page Git Product logo

lets-gopher-exercise's Introduction

Let’s Gopher

Important
This code repository is used as an example project for the training "Go project automation". It’s not intended for real-world use. For a full-fledged Go project generator have a look at 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.

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/<base-path>.

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.

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"

lets-gopher-exercise's People

Contributors

bmuschko avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.