Bare-metal/VM deployment
Bare-metal deployment is the kind of deployment option that has always existed. You simply take your program and run it on the server. In terms of the deployment process, there is no difference between deploying on a physical server or a VM – the process is the same.
For a bare-metal deployment, we can use the static linking that Go provides by default in its binaries. That means you can build your binary in your development environment, copy it to the server, and run it.
As an example, we are going to use an elementary Go program:
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
})
fmt.Println("running on port 8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}
Quick tip: Enhance your coding experience with the AI Code Explainer...