Skip to content

typical-go/typical-go

Repository files navigation

Release Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Go-Workflow Go Report Card codebeat badge BCH compliance codecov

Typical Go

Build Automation Tool For Golang

  • Manage build tasks — alternative for makefile
  • Framework-based Build Tool — no DSL to be learned, write build task in Go
  • Wrapper Script — single script to prepare and run the build-tool
  • Supporting java-like annotation for code generation — alternative for go-generate

Requirements

Typical Go known to work with Go 1.17 and later.

Getting Started

  1. Install typical-go (Optional, only needed to set up new project)

    $ go get -u github.com/typical-go/typical-go
    
  2. Setup new project

    $ typical-go setup -new -go-mod -project-pkg=[PACKAGE_NAME]
    
    • -new generate simple app and typical-build source
    • -go-mod initiate go.mod
    • -project-pkg name of project package
  3. Generate wrapper for existing project

    $ typical-go setup
    
  4. Run the project

    $ typical-go run
    

    Or via wrapper (recommendation)

    $ ./typicalw 
    

Check examples/my-project for what generated new project look like

Wrapper Script

typicalw is a bash script to prepare and run the build-tool.

$ ./typicalw

You can hack the parameters accordingly

PROJECT_PKG="github.com/typical-go/typical-go"
BUILD_TOOL="tools/typical-build"
TYPTMP=.typical-tmp
TYPGO=$TYPTMP/bin/typical-go
TYPGO_SRC=github.com/typical-go/typical-go

Any downloaded or required file will be saved in temporary folder which is located in .typical-tmp in project directory including typical-go itself. Its mean you don't need to install typical-go manually and the project always use designed version.

To update typical-go to new version

$ go get -u github.com/typical-go/typical-go
$ rm -rf .typical-tmp

Project Descriptor

By default, project descriptor is located in tools/typical-build/typical-build.go which contain project detail and task list.

var descriptor = typgo.Descriptor{
   ProjectName:    "application-name",
   ProjectVersion: "1.0.0",

   Environment: typgo.DotEnv(".env"),

   Tasks: []typgo.Tasker{
      // test
      &typgo.GoTest{
         Includes: []string{"internal/*", "pkg/*"},
      },
      // build
      &typgo.GoBuild{},
      // run
      &typgo.RunBinary{
         Before: typgo.TaskNames{"build"},
      },
   },
}

The descriptor file is regular golang file that will be compiled by typical-go, so main function should be defined.

func main() {
	typgo.Start(&descriptor)
}

It is possible to use other custom build-tool framework, check examples/custom-build-tool for example.

Wiki

Check wiki for more documentation

Examples

Typical-Go using itself as build-tool which is an excellent example.

For other examples:

License

This project is licensed under the MIT License - see the LICENSE.md file for details