]> Skullheadx's Git Forge - monopoly-web.git/commitdiff
hot reload script
authorSkullheadx <admonty1@protonmail.com>
Sat, 16 May 2026 19:32:30 +0000 (15:32 -0400)
committerSkullheadx <admonty1@protonmail.com>
Sat, 16 May 2026 19:32:30 +0000 (15:32 -0400)
flake.nix
main.go

index c74001c42a98e70a7b3c848f144c898f0250b28d..303bcacea50c2c01b00c971a32cb6831b7c34d0e 100644 (file)
--- a/flake.nix
+++ b/flake.nix
       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 {
             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 1db730d5dab00c30f421107880829ad684d5b33e..30841e712d9daf8d99d07302ff0b6076f2af1cf9 100644 (file)
--- 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))
 }