Where, when and how to use golang to serve a website

I am confident in working with Go and have a lot of experience with coding it for my personal projects, but I have never publically and professionally used Go before to serve a website and I want some advice from some true experienced professionals.

My question is, if I am planning on professionally serving my websites with Go, where/when and how should I use Go?

Should I use Go to serve the foundation of my site, such as handling all http requests ("/"), including resources such as images?

If I am gathering information from a database, is it recommended to just use something such as PHP for a quick database select query, or should I serve it with go and the “template/html” package?

Is it also recommended to use a mix of PHP and Go, or if I am going with Go, should I ONLY use Go?

If I shouldn’t be using go to serve all of my website’s content, should I use it for simple GET queries for my site to use with javascript or even PHP? (GET /golangscript?data=true)

Sorry if this question is a little confusing in anyway, I tried my best to write my question as clear as possible :slight_smile:

1 Like

It depends on your overall goals. ¯\(ツ)

What is your goal?

If it’s an internal application that is intended to be a single page app, then, why bother? Setup Caddy Server and serve out rich HTML to call your API server (built using Go).

If your goal is to create a hybrid html/js/go server for the purpose of better SEO optimization in the public space, then, yes, that makes complete sense and you should absolutely go that route.

Go can do what PHP is doing just fine. Query the db and pull information back for template/html packages.

How far do you want to take it? Go is a tool in the toolbox. Don’t overcomplicate your thinking. If you’re comfortable with your tools, use it. If you’re not, then find something you’re comfortable with.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.