GithubHelp home page GithubHelp logo

gob's Introduction

Golang Project Boot

GitHub Go Reference Build coverage

Introduction

Although the Golang programming ecosystem is becoming more and more mature, these tools and frameworks exist independently to solve specific problems. Whenever a new Golang project is started, it requires a series of initialization; What’s worse is that whenever your switch the development environment, same process have to be repeated! This project is built to solve this problem by providing a tool named gbc*, which is similar to Maven or Gradle in the Java ecosystem together with a framework(glue) similar to SpringBoot. Please refer documents for details

Features

  1. Everything is a plugin, you can use any tool you like as a plugin to customize your build process!
  2. Model driver SQL database DAO(data access object).
  3. IoC Container support via samber/do.
  4. Code generation for most popular frameworks scaffolding.
  5. Environment sensitive profile. application.yml for no-test environment and application-test.yml for test environment
  6. Friendly help messages
  7. More ....

What's a gob based project looks like?

Just likeSpringBoot, the most important part of a gob project is the configurations which define your project. There are two main configurations

  1. gob.yaml : it acts as the same as settings.gradle.kts( Gradle) or pom.xml(Maven), you can define any thrid party tool as a plugin in this file.
  2. application.yaml: it acts as the same application.yaml of SpringBoot

Quick Start

  1. Install gbc with below command
    go install github.com/kcmvp/gob/cmd/gbc@latest
  1. Initialize project with below command(in the project home directory)
  gbc init
Make some changes and commit code execute gbc deps

How gbc works

gbc takes everything defined in the gob.yaml as plugin.

flowchart TD
        gbc --> gob.yaml 
        gob.yaml --> plugin1
        gob.yaml --> plugin2
        gob.yaml --> plugin3

You just need to tell gbc 3W(where,when and what)

  1. Where : where to download the tool
  2. When : when to execute to command
  3. What : what to do with the tool

Commands

Build Commands

Plugin Commands

Setup Commands

gbc init

gbc init

Initialize gbc for the project, it will do following initializations

  1. generate file gob.yaml
  2. generate file .golangci.yaml, which is the configuration for golangci-lint
  3. setup git hooks if project in the source control. 4. commit-msg 5. pre-commit 6. pre-push

This command can be executed at any time.

Content of gob.yaml

exec:
    commit-msg-hook: ^#[0-9]+:\s*.{10,}$
    pre-commit-hook:
        - lint
        - test
    pre-push-hook:
        - test
plugins:
    golangci-lint:
        alias: lint #When : when issue `gbc lint`
        args: run ./... #What: execute `golangci-lint run ./...`
        url: github.com/golangci/golangci-lint/cmd/[email protected] #Where: where to download the plugin
    gotestsum:
        alias: test
        args: --format testname -- -coverprofile=target/cover.out ./...
        url: gotest.tools/[email protected]

in most cases you don't need to edit the configuration manually. you can achieve this by plugin commands

gbc build

gbc build

This command would build all the candidate binaries(main methods in main packages) to the target folder.

  1. Final binary name is same as go source file name which contains main method
  2. Would fail if there are same name go main surce file

gbc clean

gbc clean

This command would clean target folder

gbc test

gbc test

This command would run all tests for the project and generate coverage report at target/cover.html

gbc lint

gbc lint

Run golangci-lint against project based on the configuration, a report named target/lint.log will be generated if there are any violations

gbc deps

gbc deps

List project dependencies tree and indicate there are updates for a specific dependency

gbc plugin install

gbc plugin install github.com/golangci/golangci-lint/cmd/[email protected] lint run ./...

It is an advanced version of go install, which supports multi-version.(eg:golangci-lint-v1.55.2, golangci-lint-v1.55.1)

  1. Install the versioned tool(just the same as go install)
  2. Set up the tool as plugin in gob.yaml
  3. You can update adjust the parameters of the plugin by editing gob.yaml

gob plugin list

gob plugin list

List all the installed plugins

gob setup version

gob setup version

This command will generate file version.go in infra folder, and project version informatill will be injected into buildVersion when build the project with command gob build

// buildVersion don't change this
var buildVersion string

FAQ

`

gob's People

Contributors

kcmvp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gob's Issues

awesome list

improve unit test coverage for awesome list requirements

optimize: install plugins on demand

right now gob would always check all the plugins for every run. this can be optimized to only install the demanded plugin. it will save a lot of time especially in ci environment

runs into error

sample code runs into error
operation not supported by device

oldState, err := term.MakeRaw(int(os.Stdin.Fd()))

Add a command list the dependency or plugin

  • add a sub command to build to check there are updates or not for all the dependencies in go.mod
  • add a sub command to plugin to check there are update or not for all the plugins that list in plugins sections

gob plugin support

The idea of gob plugin is that there are many useful tools in golang ecosystem. Different tools aim different convenience for development. so it's better to supply mechanism. As a developer you can add whatever tools you like. As a plugin system it must be have following features:

  • vension wise in project level
  • configurable execution order

Implement build command

  • build all the binarys of the project
  • setup the dependency of the build serials command: clean -> test -> lint -> build

target/test.log: file already closed

when test failed system would run into this error
Error: failed to test the project Error writing to file: write /target/test.log: file already closed

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.