如何在Go服务器中创建自定义域别名?

i have web app running on top of Go. Let's say this web app running on domain.com, every user can create their on page with custom sub domain like user.domain.com .

Some of my user want to add their own custom domain, ex: userdomain.org or page.anotherdomain.com. How do i accomplish this?

I'm already search on google, they should add CNAME alias, but it shown a DNS Resolution Error

Have the user add their domain to your app, then in your http handler check if req.Host matches a known user's page.

func handleUserPage(w http.ResponseWriter, r *http.Request) {
    user, err := db.FindUserByDomain(r.Host)
    if err != nil {
        w.WriteStatus(404)
        return

    }
    //display user's page based on r.URL.Path maybe?
}