Skip to content

Commit

Permalink
Set GOEXPERIMENT=loopvar
Browse files Browse the repository at this point in the history
Per: https://go.dev/blog/loopvar-preview

I'll revert this once Go 1.22 makes this behavior the default.
  • Loading branch information
mbland committed Sep 19, 2023
1 parent a6fa91d commit 3876903
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pipeline.yaml
Expand Up @@ -30,6 +30,7 @@ env:
# prod "sam package" and "sam deploy" commands.
# PROD_IMAGE_REPOSITORY = '0123456789.dkr.ecr.region.amazonaws.com/repository-name'
PROD_REGION: us-east-1
GOEXPERIMENT: loopvar

# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers
permissions:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-tests.yaml
Expand Up @@ -2,6 +2,9 @@ name: Run Tests

on: [workflow_call, pull_request]

env:
GOEXPERIMENT: loopvar

jobs:
ci:
name: "Run Tests"
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
@@ -1,3 +1,6 @@
{
"go.buildTags": "all_tests"
"go.buildTags": "all_tests",
"go.testEnvVars": {
"GOEXPERIMENT": "loopvar"
}
}
17 changes: 9 additions & 8 deletions Makefile
Expand Up @@ -10,29 +10,30 @@ SHELL := /bin/bash
# https://github.com/aws-samples/sessions-with-aws-sam/tree/master/go-al2
# https://aws.amazon.com/blogs/compute/migrating-aws-lambda-functions-from-the-go1-x-runtime-to-the-custom-runtime-on-amazon-linux-2/
build-Function:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w" \
-tags lambda.norpc -o $(ARTIFACTS_DIR)/bootstrap lambda/main.go
GOEXPERIMENT=loopvar GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build \
-ldflags="-s -w" -tags lambda.norpc \
-o $(ARTIFACTS_DIR)/bootstrap lambda/main.go

static-checks:
go vet -tags=all_tests ./...
go run honnef.co/go/tools/cmd/staticcheck -tags=all_tests ./...
go build -tags=all_tests ./...
GOEXPERIMENT=loopvar go build -tags=all_tests ./...

small-tests:
go test -tags=small_tests ./...
GOEXPERIMENT=loopvar go test -tags=small_tests ./...

medium-tests:
go test -tags=medium_tests -count=1 ./...
GOEXPERIMENT=loopvar go test -tags=medium_tests -count=1 ./...

contract-tests-aws:
go test -tags=contract_tests -count=1 ./db -args -awsdb
GOEXPERIMENT=loopvar go test -tags=contract_tests -count=1 ./db -args -awsdb

test: static-checks small-tests medium-tests contract-tests-aws

coverage:
go test -covermode=count -coverprofile=coverage.out \
GOEXPERIMENT=loopvar go test -covermode=count -coverprofile=coverage.out \
-tags=small_tests,coverage_tests ./...
go tool cover -html=coverage.out
GOEXPERIMENT=loopvar go tool cover -html=coverage.out

sam-build: template.yml
sam validate
Expand Down

0 comments on commit 3876903

Please sign in to comment.