-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |