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
a year ago
you need to listen on the PORT
environment variable -
port := cmp.Or(os.Getenv("PORT"), "80")
http.ListenAndServe(":" + port, nil)
a year ago
a year ago
i think it was introduced in go 1.22
a year ago
no problem!
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?