menu
Channels
Chat
view-forward
# All channels
view-forward
# General
view-forward
# Announcements
view-forward
# Feature Requests
view-forward
# Hyper
view-forward
# Jobs
view-forward
# Micro
view-forward
# Now
view-forward
# PKG
view-forward
# Serve
view-forward
Team

Golang Example: multi-route, multi-lambda with dependencies

January 6, 2019 at 6:44pm

Golang Example: multi-route, multi-lambda with dependencies

January 6, 2019 at 6:44pm (Edited 9 months ago)
Example of
  • using dep to vendor dependencies
  • building multiple Go lambdas
  • routing to multiple lambdas
Note: One minor annoyance is my IDE (VSC) gives me errors for not having a func main() declared in those main packages:
runtime.main_main·f: function main is undeclared in the main package
But if you include a main method to resolve that error it breaks the now builder. I haven't looked into /go builder, but I suspect it's basically gluing in a shim with a main() method from the looks of the errors.
  • UPDATE: I updated the example repo so the IDE error is no longer an issue. Just put a func main(){} in a non-lambda .go file that is also in package main.

January 6, 2019 at 10:33pm
For Zeit, my wishlist is:
- Update https://zeit.co/docs/v2/deployments/official-builders/go-now-go/ with more details about how the builder works. It seems to require a lambda to be in a main package.
- It would be nice if go lambdas didn't need to be in the main package (this would supercede the previous point)
- now support to run dev mode and fire up all the lambdas ;)
Edited
  • reply
  • like

February 11, 2019 at 12:45pm
Hi, , I tried your solution, but the deployment failed, saying there is no lambda function in main.go.
  • reply
  • like
Hi if you can share more info about what your project looks like I might be able to help you.
It's an alternative Now 2.0 builder for Golang that I made. Have you tried it? I found the Zeit provided builder had a lot of issues for me.
  • reply
  • like