Skip to content

Commit 20ab64d

Browse files
authored
[AWSX-2115] chore(go-forwarder): init Go module, Makefile, .gitignore… (#1083)
1 parent b6366a3 commit 20ab64d

6 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Go Forwarder
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "aws/logs_monitoring_go/**"
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-24.04-arm
11+
defaults:
12+
run:
13+
working-directory: aws/logs_monitoring_go
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-go@v5
17+
with:
18+
go-version-file: aws/logs_monitoring_go/go.mod
19+
- name: golangci-lint
20+
uses: golangci/golangci-lint-action@v9
21+
with:
22+
working-directory: aws/logs_monitoring_go
23+
24+
test:
25+
runs-on: ubuntu-24.04-arm
26+
defaults:
27+
run:
28+
working-directory: aws/logs_monitoring_go
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-go@v5
32+
with:
33+
go-version-file: aws/logs_monitoring_go/go.mod
34+
- name: Run tests
35+
run: go test -race ./...
36+
37+
build:
38+
runs-on: ubuntu-24.04-arm
39+
defaults:
40+
run:
41+
working-directory: aws/logs_monitoring_go
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: actions/setup-go@v5
45+
with:
46+
go-version-file: aws/logs_monitoring_go/go.mod
47+
- name: Build binary
48+
run: GOOS=linux GOARCH=arm64 go build -o bootstrap ./cmd/forwarder/

aws/logs_monitoring_go/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.aws-sam
2+
samconfig.toml
3+
template.yaml

aws/logs_monitoring_go/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.PHONY: build package test lint clean sam-build sam-invoke sam-deploy build-ForwarderFunction
2+
3+
BINARY_NAME := bootstrap
4+
ZIP_NAME := forwarder.zip
5+
6+
build:
7+
GOOS=linux GOARCH=arm64 go build -o $(BINARY_NAME) ./cmd/forwarder/
8+
9+
# Used by `sam build`
10+
build-ForwarderFunction:
11+
GOOS=linux GOARCH=arm64 go build -o $(ARTIFACTS_DIR)/bootstrap ./cmd/forwarder/
12+
13+
package: build
14+
zip $(ZIP_NAME) $(BINARY_NAME)
15+
16+
test:
17+
go test -race ./...
18+
19+
lint:
20+
golangci-lint run ./...
21+
22+
clean:
23+
rm -f $(BINARY_NAME) $(ZIP_NAME)
24+
25+
sam-build:
26+
sam build
27+
28+
EVENT ?= events/cloudwatch_logs.json
29+
sam-invoke: sam-build
30+
sam local invoke ForwarderFunction -e $(EVENT)
31+
32+
sam-deploy: sam-build
33+
sam deploy
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed
2+
// under the Apache License Version 2.0.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
// Copyright 2026-Present Datadog, Inc.
5+
6+
package main
7+
8+
import (
9+
"context"
10+
"encoding/json"
11+
"log"
12+
13+
"github.com/aws/aws-lambda-go/lambda"
14+
)
15+
16+
func handleRequest(ctx context.Context, event json.RawMessage) error {
17+
log.Printf("Received event: %s", string(event))
18+
return nil
19+
}
20+
21+
func main() {
22+
lambda.Start(handleRequest)
23+
}

aws/logs_monitoring_go/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/DataDog/datadog-serverless-functions/aws/logs_monitoring_go
2+
3+
go 1.26
4+
5+
require github.com/aws/aws-lambda-go v1.53.0

aws/logs_monitoring_go/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/aws/aws-lambda-go v1.53.0 h1:uAMv6W/vCP/L494BAUSxe+8KVBIPK+SGPyapFt3FuMk=
2+
github.com/aws/aws-lambda-go v1.53.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
8+
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)