Hello Guys , Good Evening . Recently I come across one issue while deploying my Go app onto Amazon Web Services EC2. Actually in my demo project, I have used https://github.com/magiconair/properties for reading the values from properties file.
Kindly take a note
GoProject/src/MindBowser/MBIS
|------------> resources
|----------> Exception.properties
|------------->utils
|----------> ResourceManager.go
|------------->constants
|------------> DemoConstant.go
|------------------------------> main.go
( Here I've not given the complete structure )
Exception.properties
--------------------
exception.message.could.not.login=Could not log you in.
exception.message.email.not.registered=Email id not registered.
DemoConstant.go
---------------
package constants
var COULD_NOT_LOGIN = "exception.message.could.not.login"
var EMAIL_NOT_REGISTERED = "exception.message.email.not.registered"
ResourceManager.go
------------------
package utils
import (
"github.com/magiconair/properties"
)
var PropertyFile = []string{"${HOME}/GoProject/src/MindBowser/MBIS/resources/exception.properties"}
var Props, _ = properties.LoadFiles(PropertyFile, properties.UTF8, true)
type ResourceManager struct {
}
func (res ResourceManager) GetProperty(strs string) string {
message := ""
var ok bool
message, ok = Props.Get(strs)
if !ok {
return Props.MustGet("not.found")
} else {
return message
}
}
main.go
-----------
package main
import (
"fmt"
"MindBowser/MBIS/resources"
"MindBowser/MBIS/utils"
"MindBowser/MBIS/constants"
)
var resourceManager *utils.ResourceManager = &utils.ResourceManager{}
func main(){
fmt.Println(resourceManager.GetProperty(constants.COULD_NOT_LOGIN))
fmt.Println(resourceManager.GetProperty(constants.EMAIL_NOT_REGISTERED))
/* In above lines I'm just printing the exception messages */
}
So its working is simple and this one is the RESTful Web App and I haven’t included WebService and other layers.
So this demo project is working locally on Ubuntu OS. But after deploying it to AWS EC2, I’m getting the Error
The above code is completely fine and its working locally.
MB@MB-VirtualBox:~/GoProject/src/MindBowser/MBIS/main <-----Here I’m creating binary file which I’m trying to deploy. while executing this errors are coming.
Kindly try to suggest the solution on top priority basis.