Build and (re)start go web apps after saving/creating/deleting source files.

unmaintained

Fresh

Join the chat at https://gitter.im/pilu/fresh Build Status

Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file.

If the web framework you are using supports the Fresh runner, it will show build errors on your browser.

It currently works with Traffic, Martini and gocraft/web.

Installation

go get github.com/pilu/fresh

Usage

cd /path/to/myapp

Start fresh:

fresh

Fresh 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 the tmp folder.

Traffic already has a middleware that shows the content of that file if it is present. This middleware is automatically added if you run a Traffic web app in dev mode with Fresh. Check the _examples folder if you want to use it with Martini or Gocraft Web.

fresh uses ./runner.conf for configuration by default, but you may specify an alternative config filepath using -c:

fresh -c other_runner.conf

Here is a sample config file with the default settings:

root:              .
tmp_path:          ./tmp
build_name:        runner-build
build_log:         runner-build-errors.log
valid_ext:         .go, .tpl, .tmpl, .html
no_rebuild_ext:    .tpl, .tmpl, .html
ignored:           assets, tmp
build_delay:       600
colors:            1
log_color_main:    cyan
log_color_build:   yellow
log_color_runner:  green
log_color_watcher: magenta
log_color_app:

Author

More

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Comments
  • abandoned?

    abandoned?

    Hey @pilu - just wondering if you're no longer supporting fresh? .. it's a great project and my team uses it everyday (my fork though, since its quite stale) .. whats up?

  • Double restart?

    Double restart?

    Using fresh with a small Go server on OS X. Whenever I save a file, fresh recompiles and restarts the application twice. Is this common? How to troubleshoot this?

    Other than this small issue, really enjoying the tool. Please keep it up!

  • Add ability to ignore a directory

    Add ability to ignore a directory

    I'm unable to use Fresh with one of my web applications because it contains a frontend directory with several thousand javascript files (node_modules). When attempting to run Fresh on the application directory, it attempts to watch each of these files and subsequently crashes ("too many open files").

    This PR adds a configuration setting to ignore a folder in the directory which Fresh is run in.

  • Add a build_args setting

    Add a build_args setting

    This controls what is passed to go build. In our use case our main.go isn't in the root directory, but we want to watch the entire root for file changes. So I pass RUNNER_BUILD_ARGS=./cmd/app to fresh

  • fresh: command not found on Ubuntu

    fresh: command not found on Ubuntu

    I installed fresh using go get and I see it being placed at ~/go/src/github.com/pilu/fresh.

    echo $GOPATH /home/me/go

    I can build and run my project at ~/go/src/myapp, but as for fresh I get:

    me@pc:~/go/src/myapp$ fresh
    fresh: command not found
    

    How can I fix this?

  • Error: too many open files

    Error: too many open files

    The project I am trying to use Fresh with uses AngularJS for everything UI-related (no use of html/template anywhere), and Fresh dies when it tries to descend into the directory containing all of the AngularJS stuff.

    I tried to restrict which files Fresh looks at by setting valid_ext: .go in a custom config file, however Fresh still fails like so:

    $ fresh -c=fresh.conf
    Loading settings from fresh.conf
    12:10:09 runner      | InitFolders
    12:10:09 runner      | mkdir ./tmp
    12:10:09 runner      | mkdir ./tmp: file exists
    12:10:09 watcher     | Watching .
    12:10:09 watcher     | Watching old-data
    12:10:09 watcher     | Watching www
    12:10:09 watcher     | Watching www/app
    12:10:09 watcher     | Watching www/app/css
    12:10:09 watcher     | Watching www/app/fonts
    12:10:09 watcher     | Watching www/app/img
    12:10:09 watcher     | Watching www/app/js
    12:10:09 watcher     | Watching www/app/lib
    12:10:09 watcher     | Watching www/app/lib/angular
    12:10:09 watcher     | Watching www/app/lib/angular/i18n
    too many open files
    
  • Exclude dirs

    Exclude dirs

    This will allow you to specify directories you want excluded. I tried https://github.com/phaikawl/fresh which also attempts to add this feature, however it never worked quite right for me.

    You add directories you want excluded via the runner.conf :

    exclude_dir: assets, bower_components, something_else
    
  • Watcher crashes when using a different root in config

    Watcher crashes when using a different root in config

    I was trying to set fresh up in a project that has a structure like this:

    myProject/
        public/
            index.html
            ...
        src/
            files.go
            ...
        scripts/
            fresh.runner.conf
    

    I made a config that sets the root to: .domain.com/me/myProject/src

    Then I change into the myProject location and run: `fresh -c scripts/fresh.runner.conf``

    The watcher crashes with:

    Loading settings from scripts/fresh.runner.conf
    16:30:05 runner      | InitFolders
    16:30:05 runner      | mkdir ./tmp
    16:30:05 runner      | mkdir ./tmp: file exists
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x20 pc=0x43e51c]
    
    goroutine 1 [running]:
    runtime.panic(0x4fdc00, 0x659ce8)
        /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
    github.com/pilu/fresh/runner.func·005(0xc2100640d3, 0x2b, 0x0, 0x0, 0x7f20247ea238, ...)
        /path/to/go/src/github.com/pilu/fresh/runner/watcher.go:41 +0x2c
    path/filepath.Walk(0xc2100640d3, 0x2b, 0x55d160, 0x4, 0xc2100661b0)
        /usr/local/go/src/pkg/path/filepath/path.go:378 +0x81
    github.com/pilu/fresh/runner.watch()
        /path/to/go/src/github.com/pilu/fresh/runner/watcher.go:50 +0x6b
    github.com/pilu/fresh/runner.Start()
        /path/to/go/src/github.com/pilu/fresh/runner/start.go:110 +0x32
    main.main()
        /path/to/go/src/github.com/pilu/fresh/main.go:35 +0x16c
    

    My hope was that I could monitor both the public/ static files, along with the go source in the sub directories.

    Thanks!

  • Add polling support for situations where fsnotify isn't sufficient

    Add polling support for situations where fsnotify isn't sufficient

  • Cross-Compile

    Cross-Compile

    Is there any flags to specify the exact build parameters:

    I run a mac but I want to build a linux executable. I use this command:

    GOOS=linux GOARCH=amd64 go build -o main.linux main.go

  • syscall undefined installing on windows 7

    syscall undefined installing on windows 7

    PS C:\Users\shxu\Dropbox\go\src\poem> go get github.com/pilu/fresh
    
    ..\github.com\pilu\fresh\runner\start.go:92: undefined: syscall.Rlimit
    ..\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.Setrlimit
    ..\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.RLIMIT_NOFILE
    
  • Cannot scan command inputs

    Cannot scan command inputs

    If i'm launching my app with fresh, i'm not able to scan user input from the command line. (tested with bufio and others go scanners)

    This bunch of code (from https://developers.google.com/gmail/api/quickstart/go) :

    	authURL := config.AuthCodeURL("state-token", oauth2.AccessTypeOffline)
    	fmt.Printf("Go to the following link in your browser then type the "+
    		"authorization code: \n%v\n", authURL)
    	scanner := bufio.NewScanner(os.Stdin)
    	scanner.Scan()
    	err := scanner.Err()
    	if err != nil {
    		log.Fatalf("Unable to retrieve authorization code: %v", err)
    	}
    	authCode := scanner.Text()
    	fmt.Printf("Auth code: %s\n", authCode)
    

    will never stop (it should stop at "Scan()" on line 5)

    If I'm launching my app without fresh this code works.

    Do someone knows how can I fix this ?

    Thanks a lot

  • Add tutorial for installing fresh via go install

    Add tutorial for installing fresh via go install

    As an amateur go dev, I always face the problem fresh not found when following the instructions of this library when I set up a new machine or re-install go.

    Here is a note I added under the installation section. Hope it helps other guys like me.

  • no required module provides package github.com/pilu/fresh; to add it:

    no required module provides package github.com/pilu/fresh; to add it:

    I have installed fresh, and was able to run it successfully in the last file. When I open the second file, it does not run with an error. But the first one still works.

  • fresh: command not find

    fresh: command not find

    I used go get -v -u github.com/pilu/fresh in ubuntu, but when I use fresh, I get the error about command not find. And I can't see the fresh in go/bin, but I can see the fresh in go/pkg. Could anyone give me some help to fix this issue?

  • The correct path could not be found

    The correct path could not be found

    E:\dason\golang>fresh 18:8:03 runner | InitFolders 18:8:03 runner | mkdir ./tmp 18:8:03 runner | mkdir ./tmp: Cannot create a file when that file already exists. 18:8:03 watcher | Watching . 18:8:03 main | Waiting (loop 1)... 18:8:03 main | receiving first event / 18:8:03 main | sleeping for 600 milliseconds 18:8:03 main | flushing events 18:8:03 main | Started! (5 Goroutines) 18:8:03 main | remove tmp\runner-build-errors.log: The system cannot find the file specified. 18:8:03 build | Building... 18:8:03 main | Build Failed: package go: no Go files in F:\software\Go\src\go

Related tags
CBuild build system - A tiny build system for C

cuild - CBuild A build system for C Building $ go build . Usage Similar to GNU Make, a file named "Cuildfile" is required. You have a few flags to us

Jan 17, 2022
KintoHub is an open source build and deployment platform designed with a developer-friendly interface for Kubernetes.
KintoHub is an open source build and deployment platform designed with a developer-friendly interface for Kubernetes.

What is Kintohub? KintoHub is an open source build and deployment platform designed with a developer-friendly interface for Kubernetes. Build your cod

Jun 7, 2022
☁️ Live reload for Go apps
☁️ Live reload for Go apps

Air ☁️ Live reload for Go apps Motivation When I get started with developing websites in Go and gin framework, it's a pity that gin lacks live-reloadi

Jan 1, 2023
a build tool for Go, with a focus on cross-compiling, packaging and deployment

goxc NOTE: goxc has long been in maintenance mode. Ever since Go1.5 supported simple cross-compilation, this tool lost much of its value. There are st

Dec 9, 2022
Build system and task runner for Go projects
Build system and task runner for Go projects

Gilbert is task runner that aims to provide declarative way to define and run tasks like in other projects like Gradle, Maven and etc.

Dec 21, 2022
Monitoring changes in the source file and automatically compile and run (restart).
Monitoring changes in the source file and automatically compile and run (restart).

dogo Monitoring changes in the source file and automatically compile and run (restart). 中文 Install go get github.com/liudng/dogo Create config Here's

Dec 28, 2022
Create build pipelines in Go

taskflow Create build pipelines in Go This package aims to simplify the creation of build pipelines in Go instead of using scripts or Make. taskflow A

Dec 30, 2022
Colorize (highlight) `go build` command output
Colorize (highlight) `go build` command output

colorgo colorgo is a wrapper to go command that colorizes output from go build and go test. Installation go get -u github.com/songgao/colorgo Usage c

Dec 18, 2022
Build systems with Go examples
Build systems with Go examples

What is this? This is a repository containing all the examples from the book BUILD SYSTEMS with GO (and save the world). This book is written to help

Dec 23, 2022
🌍 Earthly is a build automation tool for the container era
 🌍 Earthly is a build automation tool for the container era

?? Earthly is a build automation tool for the container era. It allows you to execute all your builds in containers. This makes them self-contained, repeatable, portable and parallel. You can use Earthly to create Docker images and artifacts (eg binaries, packages, arbitrary files).

Dec 30, 2022
An experimental way to apply patches to the Go runtime at build time.

go-patch-overlay An experimental way to apply patches to the Go runtime at build time. Assuming you have a directory of patches to apply to the Go sou

Oct 31, 2022
Please is a cross-language high-performance extensible build system for reproducible multi-language builds.

Please is a cross-language build system with an emphasis on high performance, extensibility and reproducibility. It supports a number of popular languages and can automate nearly any aspect of your build process.

Dec 30, 2022
Blueprint Build System For Golang

Blueprint Build System Blueprint is being archived on 2021 May 3. On 2021 May 3, we will be archiving the Blueprint project. This means it will not be

Nov 20, 2021
Embed static files in Go binaries (replacement for gobuffalo/packr)

Pkger github.com/markbates/pkger is a tool for embedding static files into Go binaries. It will, hopefully, be a replacement for github.com/gobuffalo/

Dec 29, 2022
Live reload utility for Go web servers

gin gin is a simple command line utility for live-reloading Go web applications. Just run gin in your app directory and your web app will be served wi

Jan 4, 2023
Builds and restarts a Go project when it crashes or some watched file changes
Builds and restarts a Go project when it crashes or some watched file changes

gaper Used to build and restart a Go project when it crashes or some watched file changes Aimed to be used in development only. Changelog See Releases

Dec 30, 2022
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

#1 Golang live reload and task runner Content - ⭐️ Top Features - ???? Get started - ?? Config sample - ?? Commands List - ?? Support and Suggestions

Jan 6, 2023
Various tools for usage with Golang like installer, github tool and cloud features.

Gopei2 (Go Programming Environment Installer) Gopei shell install Go compiler, LiteIDE and configure for you the entire environment, variables, paths,

Dec 23, 2022
An extremely fast JavaScript bundler and minifier
An extremely fast JavaScript bundler and minifier

An extremely fast JavaScript bundler and minifier

Jan 4, 2023