Code Monkey home page Code Monkey logo

gowatch's Introduction

gowatch

Go Go Report Card PkgGoDev codecov

δΈ­ζ–‡ζ–‡ζ‘£

gowatch is a command line tool that builds and (re)starts your go project everytime you save a Go or template file.

gowatch

Installation

To install gowatch use the go get command:

go get github.com/silenceper/gowatch

Then you can add gowatch binary to PATH environment variable in your ~/.bashrc or ~/.bash_profile file:

If you already have gowatch installed, updating gowatch is simple:

go get -u github.com/silenceper/gowatch

Usage

cd /path/to/myapp

Start gowatch:

gowatch

Gowatch will watch for file events, and every time you create/modify/delete a file it will build and restart the application,If go build returns an error, it will log it in stdout.

Support Options

  • -o : Not required, specify the target file path for the build
  • -p : Not required, specify the package to be built (can also be a single file)
  • -args: Not required, specify program runtime parameters, for example: -args = '-host =: 8080, -name = demo'
  • -v: Not required, display gowatch version information

example:

gowatch -o ./bin/demo -p ./cmd/demo

Configuration file

In most cases, you don't need to specify the configuration. You can meet most of the requirements by directly executing the gowatch command. Create a gowatch.yml file in the execution directory:

# gowatch.yml configuration example

# The name of the executable file generated under the current directory execution. The default is the current directory name.
appname: "test"

# Specify the command to run after builds done
run_cmd: "./run.sh"

# Specify the directory where the compiled object files are stored
output: /bin/demo
# The file name suffix that needs to be monitored. By default, there is only a '.go' file.
watch_exts:
    - .yml

# The directory that needs to listen for file changes. By default, only the current directory.
watch_paths:
    - ../pk

# Additional parameters that need to be added when running the application
cmd_args:
    - arg1=val1

# Additional parameters that need to be added when building the application
build_args:
    - -race

# Need to increase environment variables, the current environment variables are loaded by default
envs:
    - a=b

# Whether to listen to file changes in the 'vendor' folder
vendor_watch: false

# Directory that do not need to listen for file changes
excluded_paths:
    - path

# main package path, can also be a single file, multiple files separated by commas
build_pkg: ""

# build tags
build_tags: ""

# Commands that can be executed before build the app
#prev_build_cmds:
#  - swag init

# Whether to prohibit automatic operation
disable_run: false

Author

@silenceper

Inspired by bee

gowatch's People

Contributors

silenceper avatar yycoder avatar picasso250 avatar

Watchers

 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.