Serving Static Website With Go

Serving static website in Go I would like to describe here how to serve static content with Go. Go http package provides handy function http.FileServer to serve such content. FileServer also allows to browse files when index.html is missing in a catalog. Preparing files Let’s create such structure. $ tree . ├── assets │ ├── page.html │ └── styles │ └── main.css └── main.go File: assets/page.html <!doctype html> <html> <head> <meta charset="utf-8"> <title>Document</title> <link rel="stylesheet" href="/styles/main....

October 25, 2023 · 2 min