Once we have an EC2 instance ready with the required libraries installed, we can simply copy the application using the secure copy protocol and then run it using the go run command, which we will be covering in this recipe.
Creating, copying, and running a Go web application on your first EC2 instance
How to do it...
- Create http-server.go, where we will create a simple HTTP server that will render Hello World! browsing http://ec2-instance-public-dns:80 or executing curl -X GET http://ec2-instance-public-dns:80 from the command line, as follows:
package main
import
(
"fmt"
"log"
"net/http"
)
const
(
CONN_PORT = "80"
)
func helloWorld(w http.ResponseWriter, r *http.Request)
{
fmt.Fprintf...