GoをHerokuにデプロイすると落ちる

HerokuのBuildpackがgo 1.19にまだ対応していないのが理由らしい。
バージョンをgo1.18に下げる必要がある。

$ go mod init hello
$ vim go.mod
- go 1.19
+ go 1.18

テストコード

package main

import (
	"io"
	"net/http"
	"os"
)

func hello(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "hello world")
}

func main() {
	port := os.Getenv("PORT")
	http.HandleFunc("/", hello)
	http.ListenAndServe(":"+port, nil)
}