Deploy golang site on netlify

Hey!

I created a static site using golang. I did NOT use a static site generator like hugo.

I use go to create a webserver and serve the pages. The code looks a lot like
https://www.alexedwards.net/blog/serving-static-sites-with-go

How do I deploy this to netlify?

If in the deploy instructions i do go run main.go, I see that the site is served on the port, but the deploy is never complete (it cancels after a while).

Are there any guides or how-to? I am fairly new to golang and would appreciate any tips.

Hey @dc-coder!

I think the issue is that your script is spawning a webserver (see the last line in your screenshot: Listening on port :8000).

Now I don’t have that much experience with Go, but to me this seems like this is intended to be hosted on an actual server and not a static hoster like Netlify. Although, you could probably get around this using their Functions product (Netlify Functions).

The main idea behind Netlify is to use a build script (like the one you use in Go), but not serve the content through your own webserver but instead generate the static assets (the actual HTML files, etc.) and let Netlify take care of hosting and serving them.

thanks for helping out and weighing in @flo! @dc-coder - you can not run a webserver on Netlify, as it is a hosting service for jamstack sites - static html sites, sites built with SSGs that introduce dynamic aspects but querying APIs, that kind of thing.