您好,登錄后才能下訂單哦!
這篇文章給大家介紹goland服務怎么利用配置文件進行熱重啟,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
開發web api或web項目,修改源碼后,無需手動重啟即可查看效果,使用air即可實現。
安裝air:go get -v -u github.com/cosmtrek/air(或下載所有源碼后,go build,得到air.exe,拷貝到$goroot/bin目錄)
在項目目錄下,創建.air.config文件,修改[build]中的cmd配置,設置為goland編譯程序的命令行命令:
cmd = "go build -o ./tmp/xxx-demo.exe ./main.go"
最終配置文件如下:
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format # Working directory # . or absolute path, please note that the directories following must be under root. root = "." tmp_dir = "tmp" [build] # Just plain old shell command. You could use `make` as well. cmd = "go build -o ./tmp/xxx-demo.exe ./main.go" # Binary file yields from `cmd`. bin = "tmp/xxx-demo.exe" # Customize binary. full_bin = "APP_ENV=dev APP_USER=air ./tmp/main" # Watch these filename extensions. include_ext = ["go", "tpl", "tmpl", "html"] # Ignore these filename extensions or directories. exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"] # Watch these directories if you specified. include_dir = [] # Exclude files. exclude_file = [] # It's not necessary to trigger build each time file changes if it's too frequent. delay = 1000 # ms # Stop to run old binary when build errors occur. stop_on_error = true # This log file places in your tmp_dir. log = "air_errors.log" [log] # Show log time time = false [color] # Customize each part's color. If no color found, use the raw app log. main = "magenta" watcher = "cyan" build = "yellow" runner = "green" [misc] # Delete tmp directory on exit clean_on_exit = true
goland中打開項目,在Terminal中運行air命令,即可自動監控項目代碼修改,自動熱啟動服務,方便開發調試。
關于goland服務怎么利用配置文件進行熱重啟就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。