php小編柚子將為您介紹如何使用Golang從`template`目錄外部呼叫SAM。 SAM(Serverless Application Model)是一種用於定義和部署無伺服器應用程式的開發框架,而Golang則是一種高效且易於使用的程式語言。在開發過程中,我們可能需要從外部目錄呼叫SAM模板,本文將詳細介紹此過程。透過以下步驟,您將能夠輕鬆在Golang中使用外部SAM範本。
問題內容
我有一個多模組項目,其中一個模組用於執行整合測試,而另一個模組則包含我的應用程式(待測試)。我想從 sam 模板目錄外部運行 build
和 invoke
。
使用指令 sam build -ttests/helloworld/template.yaml
執行階段建立工作正常,如下所示
~/w/r/sommelier (feature-integrationtests|✔) $ sam build -t tests/helloworld/template.yaml building codeuri: /users/kuldeep/work/repos/sommelier/lambdas/import-recommendations runtime: provided.al2 metadata: {'buildmethod': 'go1.x'} architecture: arm64 functions: helloworldfunction running gomodulesbuilder:build build succeeded built artifacts : .aws-sam/build built template : .aws-sam/build/template.yaml commands you can use next ========================= [*] validate sam template: sam validate [*] invoke function: sam local invoke [*] test function in the cloud: sam sync --stack-name {{stack-name}} --watch [*] deploy: sam deploy --guided
但是當我嘗試呼叫時,它失敗如下
~/W/r/sommelier (feature-integrationTests|✔) $ sam local invoke -t tests/helloworld/template.yaml Invoking bootstrap (provided.al2) Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided.al2:rapid-1.70.0-arm64. Mounting /Users/kuldeep/Work/repos/sommelier/lambdas/import-recommendations as /var/task:ro,delegated inside runtime container START RequestId: 53716d16-562c-42f1-bad7-b415e27004b3 Version: $LATEST 24 Jan 2023 09:56:03,133 [ERROR] (rapid) Init failed error=fork/exec /var/task/bootstrap: no such file or directory InvokeID= Function 'HelloWorldFunction' timed out after 5 seconds END RequestId: 5eeafe42-303b-40b4-bf96-d74809bb8636 REPORT RequestId: 5eeafe42-303b-40b4-bf96-d74809bb8636 Init Duration: 0.13 ms Duration: 5000.00 ms Billed Duration: 5000 ms Memory Size: 128 MB Max Memory Used: 128 MB No response from invoke container for HelloWorldFunction
我應該怎麼做才能達成這個目標?
解決方法
想通了。基本上, sam build -t ......
在目前工作目錄中建置並產生工件。要運行已建置的內容,我們不需要指定模板位置,而是直接執行 sam local invoke
以上是如何使用 Golang 從 `template` 目錄外部呼叫 SAM?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

go'SselectStatementTreamLinesConcurrentProgrambyMultiplexingOperations.1)itallowSwaitingOnMultipleChannEloperations,執行thefirstreadyone.2)theDefirstreadyone.2)thedefefcasepreventlocksbysbysbysbysbysbythoplocktrograpraproxrograpraprocrecrecectefnoopeready.3)

contextancandwaitgroupsarecrucialingoformanaginggoroutineseflect.1)context contextsallowsAllowsAllowsAllowsAllowsAllingCancellationAndDeadLinesAcrossapibiboundaries,確保GoroutinesCanbestoppedGrace.2)WaitGroupsSynChronizeGoroutines,確保Allimizegoroutines,確保AllizeNizeGoROutines,確保AllimizeGoroutines

goisbeneformervicesduetoitssimplicity,效率,androbustConcurrencySupport.1)go'sdesignemphasemphasizessimplicity and效率,Idealformicroservices.2))其ConcconcurnCurnInesSandChannelsOdinesSallessallessallessAlloSalosalOsalOsalOsalOndlingConconcConccompi.3)

Golangisidealforbuildingscalablesystemsduetoitsefficiencyandconcurrency,whilePythonexcelsinquickscriptinganddataanalysisduetoitssimplicityandvastecosystem.Golang'sdesignencouragesclean,readablecodeanditsgoroutinesenableefficientconcurrentoperations,t

Golang在並發性上優於C ,而C 在原始速度上優於Golang。 1)Golang通過goroutine和channel實現高效並發,適合處理大量並發任務。 2)C 通過編譯器優化和標準庫,提供接近硬件的高性能,適合需要極致優化的應用。

選擇Golang的原因包括:1)高並發性能,2)靜態類型系統,3)垃圾回收機制,4)豐富的標準庫和生態系統,這些特性使其成為開發高效、可靠軟件的理想選擇。

Golang適合快速開發和並發場景,C 適用於需要極致性能和低級控制的場景。 1)Golang通過垃圾回收和並發機制提升性能,適合高並發Web服務開發。 2)C 通過手動內存管理和編譯器優化達到極致性能,適用於嵌入式系統開發。

Golang在編譯時間和並發處理上表現更好,而C 在運行速度和內存管理上更具優勢。 1.Golang編譯速度快,適合快速開發。 2.C 運行速度快,適合性能關鍵應用。 3.Golang並發處理簡單高效,適用於並發編程。 4.C 手動內存管理提供更高性能,但增加開發複雜度。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Atom編輯器mac版下載
最受歡迎的的開源編輯器

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)