a year ago
My tech stack is.
Gofiber
GORM
Viper
etc
i think this is not very important.
When i run and build in my local computer its fine. Just fine noting failed. But when i want to deploy it in railways it is failed. When i look for where is the problem these are the controller is not found.
Maybe the problem is when database initialize. So, to cover switching database i use viper. if the environment is testing then i will use environment variables. if not, it will use config.yaml
i'm using viper to configure the env. here is the code:
if config.ENV == "TESTING" || config.ENV == "PRODUCTION" {
viper.SetConfigFile("ENV")
err := viper.ReadInConfig()
if err != nil {
return Config{}
}
viper.AutomaticEnv()
err = viper.Unmarshal(&config)
if err != nil {
panic(err)
}
}
The Log are this :
13 [stage-0 7/8] COPY . /app/.
13 DONE 0.0s
14 [stage-0 8/8] RUN --mount=type=cache,id=s/d9a579ee-aa00-4a60-819a-25c189aa8422-/root/cache/go-build,target=/root/.cache/go-build go build -o out
14 0.662 # MyGram/route
14 0.662 route/route.go:60:38: undefined: controller.NewSocialMediaController
#14 ERROR: process "/bin/bash -ol pipefail -c go build -o out" did not complete successfully: exit code: 1
[stage-0 8/8] RUN --mount=type=cache,id=s/d9a579ee-aa00-4a60-819a-25c189aa8422-/root/cache/go-build,target=/root/.cache/go-build go build -o out:
0.662 # MyGram/route0.662 route/route.go:60:38: undefined: controller.NewSocialMediaController
6 Replies
a year ago
Locally i use 1.21.1. For railways i'm not sure how to do it. I just connect github repo and railways detect how to build/deploy it. Default railways builder for golang is nixpacks. and also i try to deploy it using nixpacks locally and i got same error.
a year ago
Is something being .gitignore'd that shouldn't?
Does running go build -o out
locally work?
a year ago
yes it work. No Error message. The things are being ignore are folder .idea and file .DS_Store because i use goland and macbook.
a year ago
Okay. Thank you for answering my discussion.