Skip to content

GoDep Design doc #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions aws_lambda_builders/workflows/go_dep/DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Go Dep - Lambda Builder

## Scope
Building Go projects using the dep tool (https://github.com/golang/dep) is rather simple, if you was to do
this by hand, you would perform these commands:

- `dep ensure`
- `GOOS=linux GOARCH=amd64 go build -o handler main.go`
- `zip -r source.zip`

The scope of the Go dep builder is to create a macro for these commands to ensure that spelling and paths are correct.
We don't have to care about versioning of the tooling of either Go or dep since Lambda doesn't have to care, and so it becomes
user preference.

## Implementation
The go-dep builder runs the above commands with some minor tweaks, the commands ran on behalf of the user are:

1. dep ensure
2. GOOS=linux GOARCH=amd64 go build -o $ARTIFACT_DIR/$HANDLER_NAME $SOURCE_DIR

The main difference being we want to capture the compiled binary to package later, so the binary has the
output path as the artifact dir set by the caller.

## Challenges
There are no challenges for go building, most problems have been abstracted away by the Go tooling

## Notes
Go does native cross-compilation regardless of what's compiling it. Regardless of how the user builds their code it would run on
AWS Lambda.

### Layers
This pattern might not work for Layers, plugins for go require an extra compilation flag (`-buildmode=plugin`), this would be something
to add later on, should SAM CLI support building layers