Feature request: Go function caching should follow `replace` directives
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Describe your idea/feature/enhancement
I have a Go monorepo (also a Go workspace) that's used to deploy to AWS via SAM, and share code between multiple Lambda functions by way of Go's `replace` directive in `go.mod`.
However, with SAM, Go functions are built and cached based upon just the contents within their `CodeUri` folder, meaning that whilst SAM's Go builder works fine, its caching is based on only part of the source code, meaning that rebuilds do not occur when the underlying modules change.
My Go functions' `go.mod` files look like this:
```
module example.com/private/awsfunc
go 1.24.1
require (
github.com/aws/aws-lambda-go v1.45.0
example.com/private/package v1.0.0
)
replace example.com/private/package => ../../modules/package
```
`../../modules/package` is still within the monorepo/workspace and this builds fine with SAM. However, as I say, changes to `../../modules/package` don't cause a rebuild of the function since this source code isn't part of the function's directory tree.
### Proposal
1. SAM to parse `go.mod` files to obtain additional source code paths specified by `replace`.
2. SAM to factor these code paths into computation of the directory hash for the function, and thus would rebuild correctly whenever that `replace` referenced directory's contents change.
### Additional Details
Contributor guide
Assessment
This issue has not been assessed yet.