From 75d2f88c65c3c2726d5083a6e1b58653d9d9b9b3 Mon Sep 17 00:00:00 2001 From: Ankit Patial Date: Wed, 17 Sep 2025 22:09:01 +0530 Subject: [PATCH] added in a playground --- .gitignore | 26 +------------------------- go.work | 5 +++++ playground/Makefile | 8 ++++++++ playground/chi/main.go | 15 +++++++++++++++ playground/go.mod | 8 ++++++++ playground/go.sum | 4 ++++ playground/mux/main.go | 15 +++++++++++++++ 7 files changed, 56 insertions(+), 25 deletions(-) create mode 100644 go.work create mode 100644 playground/Makefile create mode 100644 playground/chi/main.go create mode 100644 playground/go.mod create mode 100644 playground/go.sum create mode 100644 playground/mux/main.go diff --git a/.gitignore b/.gitignore index 12a8426..34f8452 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# GoLand -.idea +.prof diff --git a/go.work b/go.work new file mode 100644 index 0000000..c622f51 --- /dev/null +++ b/go.work @@ -0,0 +1,5 @@ +go 1.25.1 + +use . + +use ./playground diff --git a/playground/Makefile b/playground/Makefile new file mode 100644 index 0000000..4eee852 --- /dev/null +++ b/playground/Makefile @@ -0,0 +1,8 @@ + +run-chi: + go run ./chi +run-mux: + go run ./mux + +bench-using-wrk: + wrk -t12 -c400 -d10s http://localhost:3001/ diff --git a/playground/chi/main.go b/playground/chi/main.go new file mode 100644 index 0000000..0e4e7ad --- /dev/null +++ b/playground/chi/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "net/http" + + "github.com/go-chi/chi/v5" +) + +func main() { + r := chi.NewRouter() + r.Get("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("welcome")) + }) + http.ListenAndServe(":3001", r) +} diff --git a/playground/go.mod b/playground/go.mod new file mode 100644 index 0000000..cae3eed --- /dev/null +++ b/playground/go.mod @@ -0,0 +1,8 @@ +module code.patial.tech/go/mux/playground + +go 1.24 + +require ( + code.patial.tech/go/mux v0.7.1 + github.com/go-chi/chi/v5 v5.2.3 +) diff --git a/playground/go.sum b/playground/go.sum new file mode 100644 index 0000000..caaedbd --- /dev/null +++ b/playground/go.sum @@ -0,0 +1,4 @@ +code.patial.tech/go/mux v0.7.1 h1:XJJbG+x06Y14DXQqgDonLarbmdxOhxj21IFD91IPF6Q= +code.patial.tech/go/mux v0.7.1/go.mod h1:Wqto23z9tqJwxB/byiDeEi2NLqauHaOf+HjUkmgp2MM= +github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= +github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= diff --git a/playground/mux/main.go b/playground/mux/main.go new file mode 100644 index 0000000..d5ca446 --- /dev/null +++ b/playground/mux/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "net/http" + + "code.patial.tech/go/mux" +) + +func main() { + r := mux.New() + r.GET("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("welcome")) + }) + http.ListenAndServe(":3001", r) +}