ZQDGR is Zoe's Quick and Dirty Golang Runner. This is a simple tool that lets you run a go project in a similar way to how you would use npm. ZQDGR lets you watch files and rebuild your project as you make changes. ZQDGR also includes an optional websocket server that will notify listeners that a rebuild has occurred, this is very useful for live reloading when doing web development with Go.
go install github.com/juls0730/zqdgr@latest
Full usage
zqdgr [options] <command>
The list of commands is
-
init
generates a zqdgr.config.json file in the current directory
-
watch <script>
runs the script in "watch mode", when files that follow the pattern in zqdgr.config.json change, the script restarts
-
<script>
runs the script
ZQDGR has the following list of options
-
-no-ws
disables the web socket server running at 2067
Example usage:
zqdgr init
zqdgr watch dev
ZQDGR comes with a websocket to notify listeners that the application has updates, the websocket is accessible at 127.0.0.1:2067/ws
. An example dev script to listen for rebuilds might look like this
let host = window.location.hostname;
const socket = new WebSocket('ws://' + host + ':2067/ws');
socket.addEventListener('message', (event) => {
if (event.data === 'refresh') {
async function testPage() {
try {
let res = await fetch(window.location.href)
} catch (error) {
console.error(error);
setTimeout(testPage, 300);
return;
}
window.location.reload();
}
testPage();
}
});
This project uses work from the following projects:
-
Copyright (c) 2013, Marian Tietz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.