Giter VIP home page Giter VIP logo

mga's Introduction

MGA: Modern Go Application tool

GitHub Workflow Status Go Report Card

Go application development tool applying modern practices.

The mga tool is an experimental collection of tools and practices related to developing Go applications. Its goal is to make the maintenance of applications, thus the life of developers easier.

⚠️ This tool is still under heavy development! Things may change. ⚠️

Currently it includes code generators and scaffolding tools:

  • Go kit endpoint generator (based on a service interface)
  • Testify mock generator (similar to mockery)
  • Event dispatcher generator (based on event interface) (compatible with Watermill)
  • Event handler generator (based on event structs) (compatible with Watermill)

Roadmap:

See the Modern Go Application for a detailed usage example.

Installation

Download a prebuilt binary from the Releases page, or install the tool from source:

go get sagikazarmark.dev/mga

Usage

Endpoint generator

An endpoint can be generated based on a service interface:

package my

import (
    "context"
)

// +kit:endpoint

// Service is a business service.
type Service interface{
    // DoSomething is a service call.
    //
    // Named parameters and results are optional, but they make the generated code nicer.
    DoSomething(ctx context.Context, myparam string) (id string, err error)
}

Then run the generator:

mga generate kit endpoint ./...

See Modern Go Application for an example.

Testify mock generator

package my

// +testify:mock

// Service is a business service.
type Service interface{}

// +testify:mock:testOnly=true

// Service2 is a business service.
type Service2 interface{}
mga generate testify mock ./...

Event dispatcher generator

package my

import (
    "context"
)

// +mga:event:dispatcher

type Events interface{
    MyEvent(ctx context.Context, ev MyEvent) error
}

type MyEvent struct{}
mga generate event dispatcher ./...

See Modern Go Application for an example.

Event handler generator

package my

// +mga:event:handler

type Event struct{
    ID string

    MyParam string
}
mga generate event handler ./...

See Modern Go Application for an example.

License

The MIT License (MIT). Please see License File for more information.

mga's People

Contributors

sagikazarmark avatar

Stargazers

 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.