Coder Social home page Coder Social logo

refresh's Introduction

Refresh

Rebuild and re-run your Go applications when files change.

This project was inspired by https:#github.com/pilu/fresh. Lack of updates and response from the maintainer, but a non-idiomatic codebase, numerous bugs, and lack of detailed reporting made the project a dead end for me to use. Enter refresh.

This simple command line application will watch your files, trigger a build of your Go binary and restart the application for you.

Installation

$ go get github.com/markbates/refresh

Getting Started

First you'll want to create a refresh.yml configuration file:

$ refresh init

If you want the config file in a different directory:

$ refresh init -c path/to/config.yml

Set it up the way you want, but I believe the defaults really speak for themselves, and will probably work for 90% of the use cases out there.

Usage

Once you have your configuration all set up, all you need to do is run it:

$ refresh run

That's it! Now, as you change your code the binary will be re-built and re-started for you.

HTTP Handler

Refresh is nice enough to ship with an http.Handler that you can wrap around your requests. Why would you want to do that? Well, if there is an error doing a build, the built in http.Handler will print the error in your browser in giant text so you'll know that there was a problem, and where to fix it (hopefully).

...
m := http.NewServeMux()
err = http.ListenAndServe(":3000", web.ErrorChecker(m))
...

Configuration Settings

# this is the root of your application relavite to your configuration file:
app_root: .
# a list of folders you don't want to watch. the folders you ignore, the faster things will be:
ignored_folders:
  - vendor
  - log
  - tmp
# a list of file extensions you want to watch for changes:
included_extensions:
  - .go
# the directory you want to build your binary in:
build_path: /tmp
# `fsnotify` can trigger many events at once when you change a file.
# in order to help cut down on the amount of builds that occur, a delay
# is used to let the extra events fly away.
build_delay: 200ms
# what would you like to call the built binary:
binary_name: refresh-build
# any extra commands you want to send to the built binary when it is run:
command_flags: []
# do you want to use colors when printing out log messages:
enable_colors: true

refresh's People

Contributors

markbates avatar jaijiv avatar jraedisch avatar

Watchers

James Cloos avatar  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.