testing deployment to web

hello work test app

Silvern Skye 81d80e11

+336
+22
README.md
··· 1 + # Quick hello world to test deployment 2 + 3 + ## Todo 4 + - [x] write hello world 5 + - templ views 6 + - add tmple dependcy 7 + - complie: go tool templ generate 8 + - use env secret 9 + - port num 10 + - test this locally 11 + 12 + - [ ] upload to tangled 13 + - add git 14 + 15 + - deploy using railway 16 + - use free tier 17 + - try custom domain 18 + - use cli 19 + 20 + - if good, attach custom domain 21 + 22 + - dev & main branches
+23
go.mod
··· 1 + module test-deploy 2 + 3 + go 1.24.4 4 + 5 + require ( 6 + github.com/a-h/parse v0.0.0-20250122154542-74294addb73e // indirect 7 + github.com/a-h/templ v0.3.943 // indirect 8 + github.com/andybalholm/brotli v1.1.0 // indirect 9 + github.com/cenkalti/backoff/v4 v4.3.0 // indirect 10 + github.com/cli/browser v1.3.0 // indirect 11 + github.com/fatih/color v1.16.0 // indirect 12 + github.com/fsnotify/fsnotify v1.7.0 // indirect 13 + github.com/mattn/go-colorable v0.1.13 // indirect 14 + github.com/mattn/go-isatty v0.0.20 // indirect 15 + github.com/natefinch/atomic v1.0.1 // indirect 16 + golang.org/x/mod v0.26.0 // indirect 17 + golang.org/x/net v0.42.0 // indirect 18 + golang.org/x/sync v0.16.0 // indirect 19 + golang.org/x/sys v0.34.0 // indirect 20 + golang.org/x/tools v0.35.0 // indirect 21 + ) 22 + 23 + tool github.com/a-h/templ/cmd/templ
+33
go.sum
··· 1 + github.com/a-h/parse v0.0.0-20250122154542-74294addb73e h1:HjVbSQHy+dnlS6C3XajZ69NYAb5jbGNfHanvm1+iYlo= 2 + github.com/a-h/parse v0.0.0-20250122154542-74294addb73e/go.mod h1:3mnrkvGpurZ4ZrTDbYU84xhwXW2TjTKShSwjRi2ihfQ= 3 + github.com/a-h/templ v0.3.943 h1:o+mT/4yqhZ33F3ootBiHwaY4HM5EVaOJfIshvd5UNTY= 4 + github.com/a-h/templ v0.3.943/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= 5 + github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= 6 + github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= 7 + github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= 8 + github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= 9 + github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= 10 + github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= 11 + github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= 12 + github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= 13 + github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= 14 + github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= 15 + github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= 16 + github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= 17 + github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 18 + github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 19 + github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 20 + github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0A= 21 + github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= 22 + golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= 23 + golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= 24 + golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= 25 + golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= 26 + golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= 27 + golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 28 + golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 29 + golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 30 + golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= 31 + golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 32 + golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= 33 + golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
+25
main.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + "net/http" 6 + "os" 7 + ) 8 + 9 + var testEnv string 10 + 11 + func main() { 12 + portNum := "8080" 13 + os.Getenv("TEST_ENV") 14 + 15 + mux := http.NewServeMux() 16 + mux.HandleFunc("/", handleRoot) 17 + 18 + fmt.Println("server listening to " + portNum) 19 + http.ListenAndServe(":"+portNum, mux) 20 + } 21 + 22 + func handleRoot(w http.ResponseWriter, r *http.Request) { 23 + rootPage := HelloPage(testEnv) 24 + rootPage.Render(r.Context(), w) 25 + }
+44
view.templ
··· 1 + package main 2 + 3 + 4 + templ HelloPage(name string) { 5 + @basicPage("Test deploy", "Hello World") { 6 + <div>Hello, { name }</div> 7 + } 8 + 9 + } 10 + 11 + 12 + templ basicHtml(pageName string) { 13 + <!DOCTYPE html> 14 + 15 + <html lang="en"> 16 + <head> 17 + <meta charset="UTF-8" /> 18 + <title>{pageName}</title> 19 + <meta name="viewport" content="width=device-width,initial-scale=1" /> 20 + <link rel="icon" href="favicon.png"> 21 + </head> 22 + 23 + <body> 24 + {children...} 25 + </body> 26 + </html> 27 + } 28 + 29 + 30 + templ basicPage(title string, headerTitle string) { 31 + @basicHtml(title) { 32 + 33 + <header> 34 + <h1>{headerTitle}</h1> 35 + </header> 36 + 37 + <main> 38 + {children...} 39 + </main> 40 + } 41 + 42 + } 43 + 44 +
+189
view_templ.go
··· 1 + // Code generated by templ - DO NOT EDIT. 2 + 3 + // templ: version: v0.3.943 4 + package main 5 + 6 + //lint:file-ignore SA4006 This context is only used if a nested component is present. 7 + 8 + import "github.com/a-h/templ" 9 + import templruntime "github.com/a-h/templ/runtime" 10 + 11 + func HelloPage(name string) templ.Component { 12 + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 13 + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 14 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { 15 + return templ_7745c5c3_CtxErr 16 + } 17 + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 18 + if !templ_7745c5c3_IsBuffer { 19 + defer func() { 20 + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 21 + if templ_7745c5c3_Err == nil { 22 + templ_7745c5c3_Err = templ_7745c5c3_BufErr 23 + } 24 + }() 25 + } 26 + ctx = templ.InitializeContext(ctx) 27 + templ_7745c5c3_Var1 := templ.GetChildren(ctx) 28 + if templ_7745c5c3_Var1 == nil { 29 + templ_7745c5c3_Var1 = templ.NopComponent 30 + } 31 + ctx = templ.ClearChildren(ctx) 32 + templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 33 + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 34 + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 35 + if !templ_7745c5c3_IsBuffer { 36 + defer func() { 37 + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 38 + if templ_7745c5c3_Err == nil { 39 + templ_7745c5c3_Err = templ_7745c5c3_BufErr 40 + } 41 + }() 42 + } 43 + ctx = templ.InitializeContext(ctx) 44 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div>Hello, ") 45 + if templ_7745c5c3_Err != nil { 46 + return templ_7745c5c3_Err 47 + } 48 + var templ_7745c5c3_Var3 string 49 + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(name) 50 + if templ_7745c5c3_Err != nil { 51 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view.templ`, Line: 6, Col: 20} 52 + } 53 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) 54 + if templ_7745c5c3_Err != nil { 55 + return templ_7745c5c3_Err 56 + } 57 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div>") 58 + if templ_7745c5c3_Err != nil { 59 + return templ_7745c5c3_Err 60 + } 61 + return nil 62 + }) 63 + templ_7745c5c3_Err = basicPage("Test deploy", "Hello World").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) 64 + if templ_7745c5c3_Err != nil { 65 + return templ_7745c5c3_Err 66 + } 67 + return nil 68 + }) 69 + } 70 + 71 + func basicHtml(pageName string) templ.Component { 72 + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 73 + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 74 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { 75 + return templ_7745c5c3_CtxErr 76 + } 77 + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 78 + if !templ_7745c5c3_IsBuffer { 79 + defer func() { 80 + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 81 + if templ_7745c5c3_Err == nil { 82 + templ_7745c5c3_Err = templ_7745c5c3_BufErr 83 + } 84 + }() 85 + } 86 + ctx = templ.InitializeContext(ctx) 87 + templ_7745c5c3_Var4 := templ.GetChildren(ctx) 88 + if templ_7745c5c3_Var4 == nil { 89 + templ_7745c5c3_Var4 = templ.NopComponent 90 + } 91 + ctx = templ.ClearChildren(ctx) 92 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>") 93 + if templ_7745c5c3_Err != nil { 94 + return templ_7745c5c3_Err 95 + } 96 + var templ_7745c5c3_Var5 string 97 + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(pageName) 98 + if templ_7745c5c3_Err != nil { 99 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view.templ`, Line: 18, Col: 18} 100 + } 101 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) 102 + if templ_7745c5c3_Err != nil { 103 + return templ_7745c5c3_Err 104 + } 105 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</title><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><link rel=\"icon\" href=\"favicon.png\"></head><body>") 106 + if templ_7745c5c3_Err != nil { 107 + return templ_7745c5c3_Err 108 + } 109 + templ_7745c5c3_Err = templ_7745c5c3_Var4.Render(ctx, templ_7745c5c3_Buffer) 110 + if templ_7745c5c3_Err != nil { 111 + return templ_7745c5c3_Err 112 + } 113 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</body></html>") 114 + if templ_7745c5c3_Err != nil { 115 + return templ_7745c5c3_Err 116 + } 117 + return nil 118 + }) 119 + } 120 + 121 + func basicPage(title string, headerTitle string) templ.Component { 122 + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 123 + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 124 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { 125 + return templ_7745c5c3_CtxErr 126 + } 127 + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 128 + if !templ_7745c5c3_IsBuffer { 129 + defer func() { 130 + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 131 + if templ_7745c5c3_Err == nil { 132 + templ_7745c5c3_Err = templ_7745c5c3_BufErr 133 + } 134 + }() 135 + } 136 + ctx = templ.InitializeContext(ctx) 137 + templ_7745c5c3_Var6 := templ.GetChildren(ctx) 138 + if templ_7745c5c3_Var6 == nil { 139 + templ_7745c5c3_Var6 = templ.NopComponent 140 + } 141 + ctx = templ.ClearChildren(ctx) 142 + templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 143 + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 144 + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 145 + if !templ_7745c5c3_IsBuffer { 146 + defer func() { 147 + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 148 + if templ_7745c5c3_Err == nil { 149 + templ_7745c5c3_Err = templ_7745c5c3_BufErr 150 + } 151 + }() 152 + } 153 + ctx = templ.InitializeContext(ctx) 154 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<header><h1>") 155 + if templ_7745c5c3_Err != nil { 156 + return templ_7745c5c3_Err 157 + } 158 + var templ_7745c5c3_Var8 string 159 + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(headerTitle) 160 + if templ_7745c5c3_Err != nil { 161 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view.templ`, Line: 34, Col: 22} 162 + } 163 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) 164 + if templ_7745c5c3_Err != nil { 165 + return templ_7745c5c3_Err 166 + } 167 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</h1></header><main>") 168 + if templ_7745c5c3_Err != nil { 169 + return templ_7745c5c3_Err 170 + } 171 + templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer) 172 + if templ_7745c5c3_Err != nil { 173 + return templ_7745c5c3_Err 174 + } 175 + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</main>") 176 + if templ_7745c5c3_Err != nil { 177 + return templ_7745c5c3_Err 178 + } 179 + return nil 180 + }) 181 + templ_7745c5c3_Err = basicHtml(title).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) 182 + if templ_7745c5c3_Err != nil { 183 + return templ_7745c5c3_Err 184 + } 185 + return nil 186 + }) 187 + } 188 + 189 + var _ = templruntime.GeneratedTemplate