Golang to AWS Beanstalk error

I am new to Golang and created a very simply application that says Hello World in a html page . I then try to get my GO code to amazon beanstalk by copying the project and making it a zip file and then uploading it to beanstalk but I always get this error

Unable to launch application as the source bundle does not contain a Buildfile, Procfile or an executable.

Does anyone know how to fix this or get around it… this is my code below and then a simple html page. Any suggestions would be great

package main

import (
GitHub - gorilla/mux: Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
“net/http”
“time”
“log”
“os”
)

func main() {
port := os.Getenv(“PORT”)
if port == “” {
port = “5000”
}

r := mux.NewRouter()

r.PathPrefix(“/”).Handler(http.StripPrefix(“/”, http.FileServer(http.Dir(“Views/”))))
http.Handle(“/”, r)
srv := &http.Server{
ReadTimeout: 20 * time.Second,
WriteTimeout: 20 * time.Second,
IdleTimeout: 120 * time.Second,
Addr: “:5000”,
}
http.ListenAndServe(“:”+port,nil)
log.Println(srv.ListenAndServe())
}

For simple Go applications, there are two ways to deploy your application:

  1. Provide a source bundle with a source file at the root called application.go that contains the main package for your application. Elastic Beanstalk builds the binary using the following command:
    go build -o bin/application application.go
    After the application is built, Elastic Beanstalk starts it on port 5000.
  2. Provide a source bundle with a binary file called application. The binary file can be located either at the root of the source bundle or in the bin/ directory of the source bundle. If you place the application binary file in both locations, Elastic Beanstalk uses the file in the bin/ directory.

Elastic Beanstalk launches this application on port 5000.
source: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html

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