From d1550ee4351d26e0248fd44f51f2e2021653a567 Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:33:23 +0100 Subject: [PATCH 1/6] chore: updated templ version --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 45041bd..5baba73 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/emarifer/go-echo-templ-htmx go 1.21.0 require ( - github.com/a-h/templ v0.2.501 + github.com/a-h/templ v0.2.793 github.com/gorilla/sessions v1.2.2 github.com/labstack/echo-contrib v0.15.0 github.com/labstack/echo/v4 v4.11.4 @@ -19,9 +19,9 @@ require ( github.com/mattn/go-sqlite3 v1.14.19 github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.17.0 - golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.14.0 + golang.org/x/crypto v0.26.0 + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 golang.org/x/time v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index 4da7c56..b77fb2d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/a-h/templ v0.2.501 h1:9rIo5u+B+NDJIkbHGthckUGRguCuWKY/7ri8e2ckn9M= -github.com/a-h/templ v0.2.501/go.mod h1:9gZxTLtRzM3gQxO8jr09Na0v8/jfliS97S9W5SScanM= +github.com/a-h/templ v0.2.793 h1:Io+/ocnfGWYO4VHdR0zBbf39PQlnzVCVVD+wEEs6/qY= +github.com/a-h/templ v0.2.793/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= @@ -35,16 +35,16 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 9278ff2e4850623c45d147c037f643225c45b57d Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:33:39 +0100 Subject: [PATCH 2/6] docs: fixed incorrect documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c170728..296d708 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ $ air # Ctrl + C to stop the application Build for production: ``` -$ go build -ldflags="-s -w" -o ./bin/main . # ./bin/main to run the application / Ctrl + C to stop the application +$ go build -ldflags="-s -w" -o ./bin/main ./cmd/main.go # ./bin/main to run the application / Ctrl + C to stop the application ``` --- From effe46dd057606872d266f20b90ffb5f93e26d5f Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:34:54 +0100 Subject: [PATCH 3/6] feat: added flake --- .envrc | 1 + flake.lock | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 53 ++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..67f7ba1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,176 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722589758, + "narHash": "sha256-sbbA8b6Q2vB/t/r1znHawoXLysCyD4L/6n6/RykiSnA=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "4e08ca09253ef996bd4c03afa383b23e35fe28a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "revCount": 703931, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.703931%2Brev-4aa36568d413aca0ea84a1684d2d46f55dbabad7/0192ff5f-ff6a-733b-b9db-be6b562a64ba/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1724322575, + "narHash": "sha256-kRYwAdYsaICNb2WYcWtBFG6caSuT0v/vTAyR8ap0IR0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2a02822b466ffb9f1c02d07c5dd6b96d08b56c6b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "templ": "templ" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "templ": { + "inputs": { + "gitignore": "gitignore", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_2", + "xc": "xc" + }, + "locked": { + "lastModified": 1730802303, + "narHash": "sha256-vbVgY931pEOEZvfJmjbb0JUfqRJTOnAgNOrWr5axPic=", + "owner": "a-h", + "repo": "templ", + "rev": "4f2ce1648b0ba5b28c6716f43e99ac22cb84108f", + "type": "github" + }, + "original": { + "owner": "a-h", + "repo": "templ", + "type": "github" + } + }, + "xc": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724404748, + "narHash": "sha256-p6rXzNiDm2uBvO1MLzC5pJp/0zRNzj/snBzZI0ce62s=", + "owner": "joerdav", + "repo": "xc", + "rev": "960ff9f109d47a19122cfb015721a76e3a0f23a2", + "type": "github" + }, + "original": { + "owner": "joerdav", + "repo": "xc", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..38821c0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "A Nix-flake-based Go 1.22 development environment"; + + inputs = { + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz"; + templ.url = "github:a-h/templ"; + }; + + outputs = { self, nixpkgs, templ }@inputs: + let + goVersion = 23; # Change this to update the whole stack + overlays = [ (final: prev: { go = prev."go_1_${toString goVersion}"; }) ]; + + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit overlays system; }; + inherit system; + }); + templ = system: inputs.templ.packages.${system}.templ; + in + { + packages = forEachSupportedSystem ({ pkgs, system }: { + korokidsweb = pkgs.buildGoModule { + pname = "korokidsweb"; + version = "0.0.1"; + src = ./.; + vendorHash = null; + + preBuild = '' + ${templ system}/bin/templ generate + ''; + }; + }); + devShells = forEachSupportedSystem ({ pkgs, system }: { + default = pkgs.mkShell { + # added to shell path. Avaiable during dev + packages = with pkgs; [ + # goimports, godoc, etc. + gotools + + # https://github.com/golangci/golangci-lint + golangci-lint + ]; + # dependencies required to build project. Also available during dev + buildInputs = with pkgs; [ + # go (version is specified by overlay) + go + (templ system) + ]; + }; + }); + }; +} From 14c3d7e53b0172f15e97bb798ff698cc84571b19 Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:35:42 +0100 Subject: [PATCH 4/6] fix: git ignore direnv folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c4807af..73a4a15 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ app_data.db **/*_templ.go assets/css/main.css -tailwind/node_modules \ No newline at end of file +tailwind/node_modules +.direnv/ \ No newline at end of file From 327df77c3839275403807eb5c6dcd9f876cee01c Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:36:28 +0100 Subject: [PATCH 5/6] fix: remove txt files from git --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 73a4a15..61b5c3d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ app_data.db assets/css/main.css tailwind/node_modules -.direnv/ \ No newline at end of file +.direnv/ + +/views/**/*.txt \ No newline at end of file From 7a03fa6e0762da0ac01e64921ee52398cdc33fea Mon Sep 17 00:00:00 2001 From: oudwins Date: Sat, 9 Nov 2024 17:42:52 +0100 Subject: [PATCH 6/6] feat: added make file with some commands --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fbacd8c --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +dev: + go run ./cmd/main.go + +build: + go build -ldflags="-s -w" -o ./bin/main ./cmd/main.go