Application failed to respond (with hello world in Golang)

fmateluna
TRIAL

a year ago

hi!, i new here, am try to deploy a simple runtine in golang , it's a simple web app, so i try deploy but don't work, this is my "site" https://portalcomunidadretro.up.railway.app/, my code is :

package main

import (
"fmt"
"net/http"
)

func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("here!")
http.ServeFile(w, r, "static/index.html")
})
http.HandleFunc("/saludo", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("Buscando index!!")
fmt.Fprintf(w, "All OK!!")

})
fmt.Println("Servidor escuchando en el puerto :80, sin novedades")
http.ListenAndServe(":80", nil)

}

according to railway, everything is ok and ready to work, but when I enter the url, it tells me that there is an error, i need help

0 Replies

fmateluna
TRIAL

a year ago

371a1282-6fbe-4e47-8656-d10aec6b432c


fmateluna
TRIAL

a year ago

this is my project ID


a year ago

you need to listen on the PORT environment variable -

port := cmp.Or(os.Getenv("PORT"), "80")

http.ListenAndServe(":" + port, nil)

fmateluna
TRIAL

a year ago

what is cmp.Or ??


a year ago


fmateluna
TRIAL

a year ago

thanks, this method don't exist in my import

1237129154437185500


a year ago

i think it was introduced in go 1.22


fmateluna
TRIAL

a year ago

oka, thanks again


fmateluna
TRIAL

a year ago

it's fine , thanks


a year ago

no problem!


fmateluna
TRIAL

a year ago

so, how add way to compiled my project?

2024/05/06 20:23:37 Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub

where is the deploy yml?


Application failed to respond (with hello world in Golang) - Railway Help Station