From 0a80ab4d7afd5ccd83012227f642b5217fbb9f0c Mon Sep 17 00:00:00 2001 From: Skullheadx Date: Sat, 16 May 2026 15:32:30 -0400 Subject: [PATCH] hot reload script --- flake.nix | 14 ++++++++++++++ main.go | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index c74001c..303bcac 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,11 @@ version = "0.1"; system = "x86_64-linux"; pkgs = import nixpkgs {inherit system;}; + + go-watch = pkgs.writeScriptBin "go-watch" '' + #!${pkgs.stdenv.shell} + find . -name "*.go" | ${pkgs.entr}/bin/entr -r ${pkgs.nix}/bin/nix run + ''; in { packages.${system}.default = pkgs.buildGoModule { @@ -38,7 +43,16 @@ gopls gotools go-tools + + git + entr + curl + go-watch ]; + shellHook = '' + echo "Welcome to monopoly-web backend." + echo "Run 'go-watch' to hot reload the go server" + ''; }; }; }; diff --git a/main.go b/main.go index 1db730d..30841e7 100644 --- a/main.go +++ b/main.go @@ -10,12 +10,12 @@ import ( ); func main() { - fmt.Println("ur mom") + fmt.Println("monopoly-web") - helloHandler:= func(w http.ResponseWriter, req *http.Request) { - io.WriteString(w, "Hello ur mom!\n") + healthHandler:= func(w http.ResponseWriter, req *http.Request) { + io.WriteString(w, "Status: healthy\n") } - http.HandleFunc("/hello", helloHandler) + http.HandleFunc("/health", healthHandler) log.Fatal(http.ListenAndServe(":8080",nil)) } -- 2.54.0