I wanted to create a small standalone web application in Go, the opposite of a regular web application where resources would be served separately via a CDN or HTTP server such as Nginx. However, if performance is not a critical concern or the application is intended for low traffic, using a standalone application simplifies deployment and distribution because it's just an executable binary. Several packages are available for embedding resources into a Go application: Rice Statik Bindata I won't delve into the specifics of each library, but I prefer the approach due to its ease of use and active support. bindata Getting Started First, let's create an inside the directory in your project: index.html frontend/ <html> <body> Hello, World! </body> </html> Now that we have a project setup and a static resource to test, let's install using the command: bindata go get -u github.com/jteeuwen/go-bindata/... We're ready to run the backend code of the web application. Create a file, and copy the following code: main.go package main import ( "bytes" "io" "net/http" ) //go:generate go-bindata -prefix "frontend/" -pkg main -o bindata.go frontend/... func static_handler(rw http.ResponseWriter, req *http.Request) { var path string = req.URL.Path if path == "" { path = "index.html" } if bs, err := Asset(path); err != nil { rw.WriteHeader(http.StatusNotFound) } else { var reader = bytes.NewBuffer(bs) io.Copy(rw, reader) } } func main() { http.Handle("/", http.StripPrefix("/", http.HandlerFunc(static_handler))) http.ListenAndServe(":3000", nil) } Important line in this code: //go:generate go-bindata -prefix "frontend/" -pkg main -o bindata.go frontend/... The line above allows us to run the command when is called. As of version 1.4, you can run custom commands during the generation phase. It's just a matter of adding to your go file. go-bindata go generate //go:generate command argument... The command line has several parameters, so check the on how to use it. In our case, we say: go-bindata documentation define part of the pathname for static -prefix "frontend/" define the package name used in the generated code -pkg main define the name of the generated file -o bindata.go After running the command, you should see a generated file named . The structure of your project should look like this: go generate bindata.go . │ ├── bindata.go (auto-generated file) ├── frontend │ └── index.html └── main.go The logic for serving static files is in the function, which receives the request and checks if the path matches the static path. The check is done using the function, automatically exported by the user. If the resource does not exist, we return a , otherwise, we return the contents of the resource. static_handler Asset bindata.go 404 The rest of the code is for creating the web application and binding our template to match all incoming requests for . If you have trouble understanding this code, check out the official Go for . static_handler / documentation http package As a quick reminder of how Go handles packages, all identifiers will be automatically exported to other packages with the same name if the first letter of the identifier name starts with a capital letter. Based on this rule, the file provides the function for the package. This loads and returns an asset for the given name. It returns an error if the resource cannot be found or cannot be loaded. bindata.go Asset main