我需要 cd 到特定目錄,然后簡單地運行go run main.go并啟動我的應用程式。我有以下內容:
stand-app: |
$(info Booting up the app for local testing)
cd $(PWD)/cmd/myapp
go run main.go
當我運行目標時,我得到以下資訊:
go run main.go
stat main.go: no such file or directory
make: *** [stand-app] Error 1
但是位置是正確的,我可以簡單地通過 cd 到該目錄并運行命令來執行這些步驟。我哪里錯了?
謝謝
uj5u.com熱心網友回復:
配方中的每個邏輯行都在不同的 shell 中運行。當前作業目錄是shell的一個屬性;當 shell 消失時,對作業目錄的任何更改也會消失。因此,您cd ...是無操作的:它更改了該 shell 中的作業目錄,然后 shell 退出,下一個 shell 從原始作業目錄開始。
將這兩行合二為一邏輯行;也許是這樣的:
stand-app:
$(info Booting up the app for local testing)
cd $(PWD)/cmd/myapp && go run main.go
只是提醒一下:PWD做起來一點也不特別。如果您呼叫 make 的 shell 設定了它,它將有一個值,如果您呼叫 make 的 shell 沒有設定它,它將沒有值(或者如果在父 shell 中設定不正確,它將有錯誤的值)。您可能想改用 make 的CURDIR變數:
stand-app:
$(info Booting up the app for local testing)
cd '$(CURDIR)/cmd/myapp' && go run main.go
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/524278.html
標籤:去生成文件目标
上一篇:helm模板中$_的含義是什么
下一篇:如果帶有posgres連接的SQLX的transaction.Commit失敗,您是否需要呼叫transaction.RollBack
