We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
bug: Lambda execution doesn't work with Golang binary lambdas: <title>
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

Running `awslocal lambda invoke --function-name "localStage-mediaStack-backfillGetFunction91FAA-b70d6394" "manual_ test_output.json"` even a single time causes localstack to continuously try and fail to run the lambda, the terminal hands whilst docker compose logs output:
```
localstack_main  | 2023-06-07T16:47:15.160  INFO --- [   asgi_gw_4] localstack.request.aws     : AWS sts.AssumeRole => 200
localstack_main  | 2023-06-07T16:47:16.000  INFO --- [   asgi_gw_0] localstack.request.http    : POST /_localstack_lambda/f1a13ad3d39e7c5f771f6cf85f78456d/status/f1a13ad3d39e7c5f771f6cf85f78456d/error => 202
localstack_main  | 2023-06-07T16:47:16.378  WARN --- [   asgi_gw_2] l.s.a.i.executor_endpoint  : Execution environment startup failed: {"errorMessage":"Error: fork/exec /var/task/bootstrap: no such file or directory","errorType":"Runtime.InvalidEntrypoint"}
```

The logs won't stop until I pull the container down and restart it (hence I know it's continuously retrying to no avail)

### Expected Behavior

Lambda should be executed just like it does on AWS, returning a sample return string like "Test" (the lambda is very simple)
Even if it does fail (I'm not sure why it'd fail here but not on AWS) then it should try a small finite number of times and then stop

### How are you starting LocalStack?

With a docker-compose file (shown below)

### Steps To Reproduce

I don't think my code itself is the problem since it does work fine on AWS, but for a bit of context:
I use the cdk to compile the binaries and infrastructure which is deployed to LocalStack via:
    cdklocal deploy -a "cdk.out/assembly-localStage/" --all --require-approval "never"

My infra:
https://github.com/KamWithK/exSTATic-backend/tree/master/infrastructure

I can potentially create a small isolated example which illustrates the problem if needed

### Environment

```markdown
version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack:latest
    ports:
      - "127.0.0.1:4566:4566" # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559" # external services port range
    environment:
      - DEBUG=${DEBUG-}
      - DOCKER_HOST=unix:///var/run/docker.sock
      - PERSISTENCE=/tmp/localstack/data
      - AWS_DEFAULT_REGION=ap-southeast-2
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
    healthcheck:
      test: curl http://localhost:4566/_localstack/health
      interval: 1s
      timeout: 1s
      retries: 10
```


### Anything else?

Here's some function info:
```
{
            "FunctionName": "localStage-mediaStack-backfillGetFunction91FAA-b70d6394",
            "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:localStage-mediaStack-backfillGetFunction91FAA-b70d6394",
            "Runtime": "provided.al2",
            "Role": "arn:aws:iam::000000000000:role/localStage-mediaStack-backfillGetFunctionServi-f0162982",
            "Handler": "bootstrap",
            "CodeSize": 14604,
            "Description": "",
            "Timeout": 3,
            "MemorySize": 128,
            "LastModified": "2023-06-07T15:58:33.766076+0000",
            "CodeSha256": "nqvy9NYt9j59ura5fEUE4QaeXOTuTiEsDNgEvsSQGdk=",
            "Version": "$LATEST",
            "TracingConfig": {
                "Mode": "PassThrough"
            },
            "RevisionId": "377a6465-e32b-4ed3-a9f1-396af7ee0d86",
            "PackageType": "Zip",
            "Architectures": [
                "x86_64"
            ],
            "EphemeralStorage": {
                "Size": 512
            },
            "SnapStart": {
                "ApplyOn": "None",
                "OptimizationStatus": "Off"
            }
        }
```

Test lambda:
```golang
package main

import (
	"github.com/aws/aws-lambda-go/lambda"
)

func HandleRequest() (string, error) {
	return "Test", nil
}

func main() {
	lambda.Start(HandleRequest)
}
```


I did find this issue which sounded similar at first, but in my case the code does run on AWS (so I think it's a different problem, put here for reference though):
https://github.com/localstack/localstack/issues/4216

Any help would be greatly appreciated!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `localstack/services/awslambda/packages.py`
Content:
```
1 import os
2 import platform
3 import stat
4 from typing import List
5 
6 from localstack import config
7 from localstack.packages import DownloadInstaller, InstallTarget, Package, PackageInstaller
8 from localstack.packages.core import ArchiveDownloadAndExtractInstaller, SystemNotSupportedException
9 from localstack.utils.platform import get_arch
10 
11 LAMBDA_RUNTIME_INIT_URL = "https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}"
12 
13 LAMBDA_RUNTIME_DEFAULT_VERSION = "v0.1.18-pre"
14 LAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION
15 
16 # GO Lambda runtime
17 GO_RUNTIME_VERSION = "0.4.0"
18 GO_RUNTIME_DOWNLOAD_URL_TEMPLATE = "https://github.com/localstack/awslamba-go-runtime/releases/download/v{version}/awslamba-go-runtime-{version}-{os}-{arch}.tar.gz"
19 
20 
21 class AWSLambdaRuntimePackage(Package):
22     def __init__(self, default_version: str = LAMBDA_RUNTIME_VERSION):
23         super().__init__(name="AwsLambda", default_version=default_version)
24 
25     def get_versions(self) -> List[str]:
26         return [LAMBDA_RUNTIME_VERSION]
27 
28     def _get_installer(self, version: str) -> PackageInstaller:
29         return AWSLambdaRuntimePackageInstaller(name="awslambda-runtime", version=version)
30 
31 
32 class AWSLambdaRuntimePackageInstaller(DownloadInstaller):
33     def _get_arch(self):
34         arch = get_arch()
35         return "x86_64" if arch == "amd64" else arch
36 
37     def _get_download_url(self) -> str:
38         arch = self._get_arch()
39         return LAMBDA_RUNTIME_INIT_URL.format(version=self.version, arch=arch)
40 
41     def _get_install_dir(self, target: InstallTarget) -> str:
42         install_dir = super()._get_install_dir(target)
43         arch = self._get_arch()
44         return os.path.join(install_dir, arch)
45 
46     def _get_install_marker_path(self, install_dir: str) -> str:
47         return os.path.join(install_dir, "var", "rapid", "init")
48 
49     def _install(self, target: InstallTarget) -> None:
50         super()._install(target)
51         install_location = self.get_executable_path()
52         st = os.stat(install_location)
53         os.chmod(install_location, mode=st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
54 
55 
56 class AWSLambdaGoRuntimePackage(Package):
57     def __init__(self, default_version: str = GO_RUNTIME_VERSION):
58         super().__init__(name="AwsLambdaGo", default_version=default_version)
59 
60     def get_versions(self) -> List[str]:
61         return [GO_RUNTIME_VERSION]
62 
63     def _get_installer(self, version: str) -> PackageInstaller:
64         return AWSLambdaGoRuntimePackageInstaller(name="awslamba-go-runtime", version=version)
65 
66 
67 class AWSLambdaGoRuntimePackageInstaller(ArchiveDownloadAndExtractInstaller):
68     def _get_download_url(self) -> str:
69         system = platform.system().lower()
70         arch = get_arch()
71 
72         if system not in ["linux"]:
73             raise SystemNotSupportedException(f"Unsupported os {system} for awslambda-go-runtime")
74         if arch not in ["amd64", "arm64"]:
75             raise SystemNotSupportedException(f"Unsupported arch {arch} for awslambda-go-runtime")
76 
77         return GO_RUNTIME_DOWNLOAD_URL_TEMPLATE.format(
78             version=GO_RUNTIME_VERSION,
79             os=system,
80             arch=arch,
81         )
82 
83     def _get_install_marker_path(self, install_dir: str) -> str:
84         return os.path.join(install_dir, "aws-lambda-mock")
85 
86     def _install(self, target: InstallTarget) -> None:
87         super()._install(target)
88 
89         install_dir = self._get_install_dir(target)
90         install_location = self._get_install_marker_path(install_dir)
91         st = os.stat(install_location)
92         os.chmod(install_location, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
93 
94         go_lambda_mockserver = os.path.join(install_dir, "mockserver")
95         st = os.stat(go_lambda_mockserver)
96         os.chmod(go_lambda_mockserver, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
97 
98 
99 # version of the Maven dependency with Java utility code
100 LOCALSTACK_MAVEN_VERSION = "0.2.21"
101 MAVEN_REPO_URL = "https://repo1.maven.org/maven2"
102 URL_LOCALSTACK_FAT_JAR = (
103     "{mvn_repo}/cloud/localstack/localstack-utils/{ver}/localstack-utils-{ver}-fat.jar"
104 )
105 
106 
107 class AWSLambdaJavaPackage(Package):
108     def __init__(self):
109         super().__init__("LambdaJavaLibs", "0.2.22")
110 
111     def get_versions(self) -> List[str]:
112         return ["0.2.22", "0.2.21"]
113 
114     def _get_installer(self, version: str) -> PackageInstaller:
115         return AWSLambdaJavaPackageInstaller("lambda-java-libs", version)
116 
117 
118 class AWSLambdaJavaPackageInstaller(DownloadInstaller):
119     def _get_download_url(self) -> str:
120         return URL_LOCALSTACK_FAT_JAR.format(ver=self.version, mvn_repo=MAVEN_REPO_URL)
121 
122 
123 awslambda_runtime_package = AWSLambdaRuntimePackage()
124 awslambda_go_runtime_package = AWSLambdaGoRuntimePackage()
125 lambda_java_libs_package = AWSLambdaJavaPackage()
126
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/localstack/services/awslambda/packages.py b/localstack/services/awslambda/packages.py
--- a/localstack/services/awslambda/packages.py
+++ b/localstack/services/awslambda/packages.py
@@ -10,7 +10,7 @@
 
 LAMBDA_RUNTIME_INIT_URL = "https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}"
 
-LAMBDA_RUNTIME_DEFAULT_VERSION = "v0.1.18-pre"
+LAMBDA_RUNTIME_DEFAULT_VERSION = "v0.1.19-pre"
 LAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION
 
 # GO Lambda runtime

{"golden_diff": "diff --git a/localstack/services/awslambda/packages.py b/localstack/services/awslambda/packages.py\n--- a/localstack/services/awslambda/packages.py\n+++ b/localstack/services/awslambda/packages.py\n@@ -10,7 +10,7 @@\n \n LAMBDA_RUNTIME_INIT_URL = \"https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}\"\n \n-LAMBDA_RUNTIME_DEFAULT_VERSION = \"v0.1.18-pre\"\n+LAMBDA_RUNTIME_DEFAULT_VERSION = \"v0.1.19-pre\"\n LAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION\n \n # GO Lambda runtime\n", "issue": "bug: Lambda execution doesn't work with Golang binary lambdas: <title>\n### Is there an existing issue for this?\r\n\r\n- [X] I have searched the existing issues\r\n\r\n### Current Behavior\r\n\r\nRunning `awslocal lambda invoke --function-name \"localStage-mediaStack-backfillGetFunction91FAA-b70d6394\" \"manual_ test_output.json\"` even a single time causes localstack to continuously try and fail to run the lambda, the terminal hands whilst docker compose logs output:\r\n```\r\nlocalstack_main  | 2023-06-07T16:47:15.160  INFO --- [   asgi_gw_4] localstack.request.aws     : AWS sts.AssumeRole => 200\r\nlocalstack_main  | 2023-06-07T16:47:16.000  INFO --- [   asgi_gw_0] localstack.request.http    : POST /_localstack_lambda/f1a13ad3d39e7c5f771f6cf85f78456d/status/f1a13ad3d39e7c5f771f6cf85f78456d/error => 202\r\nlocalstack_main  | 2023-06-07T16:47:16.378  WARN --- [   asgi_gw_2] l.s.a.i.executor_endpoint  : Execution environment startup failed: {\"errorMessage\":\"Error: fork/exec /var/task/bootstrap: no such file or directory\",\"errorType\":\"Runtime.InvalidEntrypoint\"}\r\n```\r\n\r\nThe logs won't stop until I pull the container down and restart it (hence I know it's continuously retrying to no avail)\r\n\r\n### Expected Behavior\r\n\r\nLambda should be executed just like it does on AWS, returning a sample return string like \"Test\" (the lambda is very simple)\r\nEven if it does fail (I'm not sure why it'd fail here but not on AWS) then it should try a small finite number of times and then stop\r\n\r\n### How are you starting LocalStack?\r\n\r\nWith a docker-compose file (shown below)\r\n\r\n### Steps To Reproduce\r\n\r\nI don't think my code itself is the problem since it does work fine on AWS, but for a bit of context:\r\nI use the cdk to compile the binaries and infrastructure which is deployed to LocalStack via:\r\n    cdklocal deploy -a \"cdk.out/assembly-localStage/\" --all --require-approval \"never\"\r\n\r\nMy infra:\r\nhttps://github.com/KamWithK/exSTATic-backend/tree/master/infrastructure\r\n\r\nI can potentially create a small isolated example which illustrates the problem if needed\r\n\r\n### Environment\r\n\r\n```markdown\r\nversion: \"3.8\"\r\n\r\nservices:\r\n  localstack:\r\n    container_name: \"${LOCALSTACK_DOCKER_NAME-localstack_main}\"\r\n    image: localstack/localstack:latest\r\n    ports:\r\n      - \"127.0.0.1:4566:4566\" # LocalStack Gateway\r\n      - \"127.0.0.1:4510-4559:4510-4559\" # external services port range\r\n    environment:\r\n      - DEBUG=${DEBUG-}\r\n      - DOCKER_HOST=unix:///var/run/docker.sock\r\n      - PERSISTENCE=/tmp/localstack/data\r\n      - AWS_DEFAULT_REGION=ap-southeast-2\r\n    volumes:\r\n      - \"${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack\"\r\n      - \"/var/run/docker.sock:/var/run/docker.sock\"\r\n    healthcheck:\r\n      test: curl http://localhost:4566/_localstack/health\r\n      interval: 1s\r\n      timeout: 1s\r\n      retries: 10\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nHere's some function info:\r\n```\r\n{\r\n            \"FunctionName\": \"localStage-mediaStack-backfillGetFunction91FAA-b70d6394\",\r\n            \"FunctionArn\": \"arn:aws:lambda:us-east-1:000000000000:function:localStage-mediaStack-backfillGetFunction91FAA-b70d6394\",\r\n            \"Runtime\": \"provided.al2\",\r\n            \"Role\": \"arn:aws:iam::000000000000:role/localStage-mediaStack-backfillGetFunctionServi-f0162982\",\r\n            \"Handler\": \"bootstrap\",\r\n            \"CodeSize\": 14604,\r\n            \"Description\": \"\",\r\n            \"Timeout\": 3,\r\n            \"MemorySize\": 128,\r\n            \"LastModified\": \"2023-06-07T15:58:33.766076+0000\",\r\n            \"CodeSha256\": \"nqvy9NYt9j59ura5fEUE4QaeXOTuTiEsDNgEvsSQGdk=\",\r\n            \"Version\": \"$LATEST\",\r\n            \"TracingConfig\": {\r\n                \"Mode\": \"PassThrough\"\r\n            },\r\n            \"RevisionId\": \"377a6465-e32b-4ed3-a9f1-396af7ee0d86\",\r\n            \"PackageType\": \"Zip\",\r\n            \"Architectures\": [\r\n                \"x86_64\"\r\n            ],\r\n            \"EphemeralStorage\": {\r\n                \"Size\": 512\r\n            },\r\n            \"SnapStart\": {\r\n                \"ApplyOn\": \"None\",\r\n                \"OptimizationStatus\": \"Off\"\r\n            }\r\n        }\r\n```\r\n\r\nTest lambda:\r\n```golang\r\npackage main\r\n\r\nimport (\r\n\t\"github.com/aws/aws-lambda-go/lambda\"\r\n)\r\n\r\nfunc HandleRequest() (string, error) {\r\n\treturn \"Test\", nil\r\n}\r\n\r\nfunc main() {\r\n\tlambda.Start(HandleRequest)\r\n}\r\n```\r\n\r\n\r\nI did find this issue which sounded similar at first, but in my case the code does run on AWS (so I think it's a different problem, put here for reference though):\r\nhttps://github.com/localstack/localstack/issues/4216\r\n\r\nAny help would be greatly appreciated!\n", "before_files": [{"content": "import os\nimport platform\nimport stat\nfrom typing import List\n\nfrom localstack import config\nfrom localstack.packages import DownloadInstaller, InstallTarget, Package, PackageInstaller\nfrom localstack.packages.core import ArchiveDownloadAndExtractInstaller, SystemNotSupportedException\nfrom localstack.utils.platform import get_arch\n\nLAMBDA_RUNTIME_INIT_URL = \"https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}\"\n\nLAMBDA_RUNTIME_DEFAULT_VERSION = \"v0.1.18-pre\"\nLAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION\n\n# GO Lambda runtime\nGO_RUNTIME_VERSION = \"0.4.0\"\nGO_RUNTIME_DOWNLOAD_URL_TEMPLATE = \"https://github.com/localstack/awslamba-go-runtime/releases/download/v{version}/awslamba-go-runtime-{version}-{os}-{arch}.tar.gz\"\n\n\nclass AWSLambdaRuntimePackage(Package):\n    def __init__(self, default_version: str = LAMBDA_RUNTIME_VERSION):\n        super().__init__(name=\"AwsLambda\", default_version=default_version)\n\n    def get_versions(self) -> List[str]:\n        return [LAMBDA_RUNTIME_VERSION]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaRuntimePackageInstaller(name=\"awslambda-runtime\", version=version)\n\n\nclass AWSLambdaRuntimePackageInstaller(DownloadInstaller):\n    def _get_arch(self):\n        arch = get_arch()\n        return \"x86_64\" if arch == \"amd64\" else arch\n\n    def _get_download_url(self) -> str:\n        arch = self._get_arch()\n        return LAMBDA_RUNTIME_INIT_URL.format(version=self.version, arch=arch)\n\n    def _get_install_dir(self, target: InstallTarget) -> str:\n        install_dir = super()._get_install_dir(target)\n        arch = self._get_arch()\n        return os.path.join(install_dir, arch)\n\n    def _get_install_marker_path(self, install_dir: str) -> str:\n        return os.path.join(install_dir, \"var\", \"rapid\", \"init\")\n\n    def _install(self, target: InstallTarget) -> None:\n        super()._install(target)\n        install_location = self.get_executable_path()\n        st = os.stat(install_location)\n        os.chmod(install_location, mode=st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n\nclass AWSLambdaGoRuntimePackage(Package):\n    def __init__(self, default_version: str = GO_RUNTIME_VERSION):\n        super().__init__(name=\"AwsLambdaGo\", default_version=default_version)\n\n    def get_versions(self) -> List[str]:\n        return [GO_RUNTIME_VERSION]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaGoRuntimePackageInstaller(name=\"awslamba-go-runtime\", version=version)\n\n\nclass AWSLambdaGoRuntimePackageInstaller(ArchiveDownloadAndExtractInstaller):\n    def _get_download_url(self) -> str:\n        system = platform.system().lower()\n        arch = get_arch()\n\n        if system not in [\"linux\"]:\n            raise SystemNotSupportedException(f\"Unsupported os {system} for awslambda-go-runtime\")\n        if arch not in [\"amd64\", \"arm64\"]:\n            raise SystemNotSupportedException(f\"Unsupported arch {arch} for awslambda-go-runtime\")\n\n        return GO_RUNTIME_DOWNLOAD_URL_TEMPLATE.format(\n            version=GO_RUNTIME_VERSION,\n            os=system,\n            arch=arch,\n        )\n\n    def _get_install_marker_path(self, install_dir: str) -> str:\n        return os.path.join(install_dir, \"aws-lambda-mock\")\n\n    def _install(self, target: InstallTarget) -> None:\n        super()._install(target)\n\n        install_dir = self._get_install_dir(target)\n        install_location = self._get_install_marker_path(install_dir)\n        st = os.stat(install_location)\n        os.chmod(install_location, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n        go_lambda_mockserver = os.path.join(install_dir, \"mockserver\")\n        st = os.stat(go_lambda_mockserver)\n        os.chmod(go_lambda_mockserver, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n\n# version of the Maven dependency with Java utility code\nLOCALSTACK_MAVEN_VERSION = \"0.2.21\"\nMAVEN_REPO_URL = \"https://repo1.maven.org/maven2\"\nURL_LOCALSTACK_FAT_JAR = (\n    \"{mvn_repo}/cloud/localstack/localstack-utils/{ver}/localstack-utils-{ver}-fat.jar\"\n)\n\n\nclass AWSLambdaJavaPackage(Package):\n    def __init__(self):\n        super().__init__(\"LambdaJavaLibs\", \"0.2.22\")\n\n    def get_versions(self) -> List[str]:\n        return [\"0.2.22\", \"0.2.21\"]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaJavaPackageInstaller(\"lambda-java-libs\", version)\n\n\nclass AWSLambdaJavaPackageInstaller(DownloadInstaller):\n    def _get_download_url(self) -> str:\n        return URL_LOCALSTACK_FAT_JAR.format(ver=self.version, mvn_repo=MAVEN_REPO_URL)\n\n\nawslambda_runtime_package = AWSLambdaRuntimePackage()\nawslambda_go_runtime_package = AWSLambdaGoRuntimePackage()\nlambda_java_libs_package = AWSLambdaJavaPackage()\n", "path": "localstack/services/awslambda/packages.py"}], "after_files": [{"content": "import os\nimport platform\nimport stat\nfrom typing import List\n\nfrom localstack import config\nfrom localstack.packages import DownloadInstaller, InstallTarget, Package, PackageInstaller\nfrom localstack.packages.core import ArchiveDownloadAndExtractInstaller, SystemNotSupportedException\nfrom localstack.utils.platform import get_arch\n\nLAMBDA_RUNTIME_INIT_URL = \"https://github.com/localstack/lambda-runtime-init/releases/download/{version}/aws-lambda-rie-{arch}\"\n\nLAMBDA_RUNTIME_DEFAULT_VERSION = \"v0.1.19-pre\"\nLAMBDA_RUNTIME_VERSION = config.LAMBDA_INIT_RELEASE_VERSION or LAMBDA_RUNTIME_DEFAULT_VERSION\n\n# GO Lambda runtime\nGO_RUNTIME_VERSION = \"0.4.0\"\nGO_RUNTIME_DOWNLOAD_URL_TEMPLATE = \"https://github.com/localstack/awslamba-go-runtime/releases/download/v{version}/awslamba-go-runtime-{version}-{os}-{arch}.tar.gz\"\n\n\nclass AWSLambdaRuntimePackage(Package):\n    def __init__(self, default_version: str = LAMBDA_RUNTIME_VERSION):\n        super().__init__(name=\"AwsLambda\", default_version=default_version)\n\n    def get_versions(self) -> List[str]:\n        return [LAMBDA_RUNTIME_VERSION]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaRuntimePackageInstaller(name=\"awslambda-runtime\", version=version)\n\n\nclass AWSLambdaRuntimePackageInstaller(DownloadInstaller):\n    def _get_arch(self):\n        arch = get_arch()\n        return \"x86_64\" if arch == \"amd64\" else arch\n\n    def _get_download_url(self) -> str:\n        arch = self._get_arch()\n        return LAMBDA_RUNTIME_INIT_URL.format(version=self.version, arch=arch)\n\n    def _get_install_dir(self, target: InstallTarget) -> str:\n        install_dir = super()._get_install_dir(target)\n        arch = self._get_arch()\n        return os.path.join(install_dir, arch)\n\n    def _get_install_marker_path(self, install_dir: str) -> str:\n        return os.path.join(install_dir, \"var\", \"rapid\", \"init\")\n\n    def _install(self, target: InstallTarget) -> None:\n        super()._install(target)\n        install_location = self.get_executable_path()\n        st = os.stat(install_location)\n        os.chmod(install_location, mode=st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n\nclass AWSLambdaGoRuntimePackage(Package):\n    def __init__(self, default_version: str = GO_RUNTIME_VERSION):\n        super().__init__(name=\"AwsLambdaGo\", default_version=default_version)\n\n    def get_versions(self) -> List[str]:\n        return [GO_RUNTIME_VERSION]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaGoRuntimePackageInstaller(name=\"awslamba-go-runtime\", version=version)\n\n\nclass AWSLambdaGoRuntimePackageInstaller(ArchiveDownloadAndExtractInstaller):\n    def _get_download_url(self) -> str:\n        system = platform.system().lower()\n        arch = get_arch()\n\n        if system not in [\"linux\"]:\n            raise SystemNotSupportedException(f\"Unsupported os {system} for awslambda-go-runtime\")\n        if arch not in [\"amd64\", \"arm64\"]:\n            raise SystemNotSupportedException(f\"Unsupported arch {arch} for awslambda-go-runtime\")\n\n        return GO_RUNTIME_DOWNLOAD_URL_TEMPLATE.format(\n            version=GO_RUNTIME_VERSION,\n            os=system,\n            arch=arch,\n        )\n\n    def _get_install_marker_path(self, install_dir: str) -> str:\n        return os.path.join(install_dir, \"aws-lambda-mock\")\n\n    def _install(self, target: InstallTarget) -> None:\n        super()._install(target)\n\n        install_dir = self._get_install_dir(target)\n        install_location = self._get_install_marker_path(install_dir)\n        st = os.stat(install_location)\n        os.chmod(install_location, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n        go_lambda_mockserver = os.path.join(install_dir, \"mockserver\")\n        st = os.stat(go_lambda_mockserver)\n        os.chmod(go_lambda_mockserver, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)\n\n\n# version of the Maven dependency with Java utility code\nLOCALSTACK_MAVEN_VERSION = \"0.2.21\"\nMAVEN_REPO_URL = \"https://repo1.maven.org/maven2\"\nURL_LOCALSTACK_FAT_JAR = (\n    \"{mvn_repo}/cloud/localstack/localstack-utils/{ver}/localstack-utils-{ver}-fat.jar\"\n)\n\n\nclass AWSLambdaJavaPackage(Package):\n    def __init__(self):\n        super().__init__(\"LambdaJavaLibs\", \"0.2.22\")\n\n    def get_versions(self) -> List[str]:\n        return [\"0.2.22\", \"0.2.21\"]\n\n    def _get_installer(self, version: str) -> PackageInstaller:\n        return AWSLambdaJavaPackageInstaller(\"lambda-java-libs\", version)\n\n\nclass AWSLambdaJavaPackageInstaller(DownloadInstaller):\n    def _get_download_url(self) -> str:\n        return URL_LOCALSTACK_FAT_JAR.format(ver=self.version, mvn_repo=MAVEN_REPO_URL)\n\n\nawslambda_runtime_package = AWSLambdaRuntimePackage()\nawslambda_go_runtime_package = AWSLambdaGoRuntimePackage()\nlambda_java_libs_package = AWSLambdaJavaPackage()\n", "path": "localstack/services/awslambda/packages.py"}]}