builder

package module
v0.0.0-...-8409213 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 15 Imported by: 0

README

builder

Build Status | codecov | Go Report Card | GoDoc

A simple golang build and restart tool when some file of the project changes

If i miss something or you have something interesting, please be part of this project. Let me know! My contact is at the end.

With support for

  • Rebuild
  • Restart

Dependecy Management

Dep

Project dependencies are managed using Dep. Read more about Dep.

  • Install dependencies: dep ensure
  • Update dependencies: dep ensure -update
Go
go get github.com/joaosoft/builder

Usage

This examples are available in the project at builder/main/main.go

import (
	github.com/joaosoft/builder
	"os"
	"os/signal"
	"syscall"
)

func main() {
	termChan := make(chan os.Signal, 1)
	signal.Notify(termChan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)

	build := builder.NewBuilder(builder.WithReloadTime(1))

	if err := build.Start(nil); err != nil {
		panic(err)
	}

	<-termChan
	if err := build.Stop(nil); err != nil {
		panic(err)
	}
}

Configuration file

{
  "builder": {
    "source": "main/main.go",
    "destination": "bin/builder",
    "reload_time": 1,
    "log": {
      "level": "error"
    }
  },
  "watcher": {
    "reload_time": 1,
    "dirs": {
      "watch":[ "." ],
      "excluded":[ "vendor", "bin" ],
      "extensions": [ "go", "json", "yml" ]
    },
    "log": {
      "level": "error"
    }
  },
  "manager": {
    "log": {
      "level": "error"
    }
  }
}

Known issues

Follow me at

Facebook: https://www.facebook.com/joaosoft

LinkedIn: https://www.linkedin.com/in/jo%C3%A3o-ribeiro-b2775438/

If you have something to add, please let me know joaosoft@gmail.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(file string) bool

func GetEnv

func GetEnv() string

func ReadFile

func ReadFile(file string, obj interface{}) ([]byte, error)

func ReadFileLines

func ReadFileLines(file string) ([]string, error)

func WriteFile

func WriteFile(file string, obj interface{}) error

Types

type AppConfig

type AppConfig struct {
	Builder *BuilderConfig `json:"builder"`
}

AppConfig ...

func NewConfig

func NewConfig() (*AppConfig, manager.IConfig, error)

NewConfig ...

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(options ...BuilderOption) *Builder

func (*Builder) Reconfigure

func (b *Builder) Reconfigure(options ...BuilderOption)

Reconfigure ...

func (*Builder) Start

func (b *Builder) Start(waitGroup ...*sync.WaitGroup) error

Start ...

func (*Builder) Started

func (b *Builder) Started() bool

Started ...

func (*Builder) Stop

func (b *Builder) Stop(waitGroup ...*sync.WaitGroup) error

Stop ...

type BuilderConfig

type BuilderConfig struct {
	Source      string        `json:"source"`
	Destination string        `json:"destination"`
	ReloadTime  time.Duration `json:"reload_time"`
	Log         struct {
		Level string `json:"level"`
	} `json:"log"`
}

BuilderConfig ...

type BuilderOption

type BuilderOption func(builder *Builder)

BuilderOption ...

func WithConfiguration

func WithConfiguration(config *BuilderConfig) BuilderOption

WithConfiguration ...

func WithLogLevel

func WithLogLevel(level logger.Level) BuilderOption

WithLogLevel ...

func WithLogger

func WithLogger(logger logger.ILogger) BuilderOption

WithLogger ...

func WithManager

func WithManager(mgr *manager.Manager) BuilderOption

WithManager ...

func WithQuitChannel

func WithQuitChannel(quit chan int) BuilderOption

WithQuitChannel ...

func WithReloadTime

func WithReloadTime(reloadTime int64) BuilderOption

WithReloadTime ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL