Buildfile and Procfile when deploying program to aws

My question is similar to this one and I have followed the suggestions from the last comment in this question Deploying a simple GoLang Application to AWS Elastic Beanstalk . I am however still getting an error with the following, I know that there is something I must be doing wrong in this process

application.go:7:2: cannot find package “github.com/gorilla/mux” in any of:

My code structure is this ![27 AM|690x135]


My build.sh

#!/bin/bash

go get github.com/gorilla/mux
go build -o bin/application application.go

My buildfile.text
make: ./build.sh

My Procfile.text
web: bin/application

I am new to this but the only thing I can think of it that maybe the buildfile and/or Procfile might need a different extension .

I then use zip …/eb.zip -r * .[^.]* to zip my project and upload it to AWS but it always fails once it gets done uploading . With the message that it can not find package github.com/gorilla/mux . Is there something I’m missing with this process … my code compiles locally and this is how it looks

package main

import (
	"net/http"
	"./Controllers"
	"runtime"
	"github.com/gorilla/mux"
	"time"
)

func main() {
        println(runtime.Version())
	runtime.GOMAXPROCS(runtime.NumCPU())
	r := mux.NewRouter()
	r.HandleFunc("/testping", Controllers.TestPing)
	http.Handle("/", r)

	r.PathPrefix("/").Handler(http.StripPrefix("/", http.FileServer(http.Dir("public"))))
	srv := &http.Server{
		ReadTimeout:  20 * time.Second,
		WriteTimeout: 20 * time.Second,
		IdleTimeout:  120 * time.Second,
		Addr:         ":5000",
	}

	srv.ListenAndServe()
}

For me https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/go-environment.html reads as if build- and proc files are ignored when there is a bin/application.go as it is mentioned first in the list of bulletpoints how your application is tried to get built.

Try to rename it and change your buildfiles accordingly.

Disclaimer: never used AWS, this is solely based on my understanding of the documentation linked above.

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