-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
681eed2
commit cd5a7b2
Showing
6 changed files
with
83 additions
and
9 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
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 |
---|---|---|
@@ -1,9 +1,63 @@ | ||
.PHONY: build run | ||
# Both native and cross architecture builds are supported. | ||
# The target architecture is select by setting the ARCH variable. | ||
# When ARCH is undefined it is set to the detected host architecture. | ||
# When ARCH differs from the host architecture a crossbuild will be performed. | ||
ARCHES = amd64 arm64 ppc64le s390x | ||
|
||
# BUILDARCH is the host architecture | ||
# ARCH is the target architecture | ||
# we need to keep track of them separately | ||
BUILDARCH ?= $(shell uname -m) | ||
|
||
# canonicalized names for host architecture | ||
ifeq ($(BUILDARCH),aarch64) | ||
BUILDARCH=arm64 | ||
endif | ||
ifeq ($(BUILDARCH),x86_64) | ||
BUILDARCH=amd64 | ||
endif | ||
|
||
# unless otherwise set, I am building for my own architecture, i.e. not cross-compiling | ||
ARCH ?= $(BUILDARCH) | ||
|
||
# canonicalized names for target architecture | ||
ifeq ($(ARCH),aarch64) | ||
override ARCH=arm64 | ||
endif | ||
ifeq ($(ARCH),x86_64) | ||
override ARCH=amd64 | ||
endif | ||
|
||
|
||
build: | ||
@echo "Building Go application..." | ||
@cd src && go build -o main | ||
@echo "Building Go application..." | ||
cd src && GOOS=linux GOARCH=$(ARCH) go build -o ../bin/main main.go | ||
|
||
zip: | ||
cd bin && zip -j main.zip main | ||
|
||
|
||
run: | ||
go run main.go | ||
|
||
test: | ||
@echo "No Testing Go application..." | ||
|
||
compile: | ||
echo "Compiling for every OS and Platform" | ||
GOOS=linux GOARCH=arm go build -o bin/main-linux-arm main.go | ||
GOOS=linux GOARCH=arm64 go build -o bin/main-linux-arm64 main.go | ||
GOOS=freebsd GOARCH=386 go build -o bin/main-freebsd-386 main.go | ||
|
||
clean: | ||
rm -rf bin/* | ||
|
||
# .PHONY: build run | ||
# build: | ||
# @echo "Building Go application..." | ||
# @cd src && go build -o main | ||
|
||
# run: build | ||
# @echo "Running Go application..." | ||
# @./src/main | ||
|
||
run: build | ||
@echo "Running Go application..." | ||
@./src/main |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module github.com/alexanderfanz/go-htmx-template/src | ||
|
||
go 1.21.4 | ||
|
||
require github.com/aws/aws-lambda-go v1.41.0 // indirect |
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,2 @@ | ||
github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= | ||
github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= |
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 |
---|---|---|
@@ -1,10 +1,26 @@ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/aws/aws-lambda-go/lambda" | ||
) | ||
|
||
type MyEvent struct { | ||
Name string `json:"name"` | ||
} | ||
|
||
func lambdaHandler(ctx context.Context, event *MyEvent) (*string, error) { | ||
log.Printf("Received event: %v", event) | ||
if event == nil { | ||
return nil, fmt.Errorf("received nil event") | ||
} | ||
message := fmt.Sprintf("Hello %s!", event.Name) | ||
return &message, nil | ||
} | ||
|
||
func main() { | ||
log.Println("Starting from main") | ||
lambda.Start(lambdaHandler) | ||
} |