goland服務(wù)熱重啟的配置文件
開發(fā)web api或web項(xiàng)目,修改源碼后,無(wú)需手動(dòng)重啟即可查看效果,使用air即可實(shí)現(xiàn)。
安裝air:go get -v -u github.com/cosmtrek/air(或下載所有源碼后,go build,得到air.exe,拷貝到$goroot/bin目錄)
在項(xiàng)目目錄下,創(chuàng)建.air.config文件,修改[build]中的cmd配置,設(shè)置為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中打開項(xiàng)目,在Terminal中運(yùn)行air命令,即可自動(dòng)監(jiān)控項(xiàng)目代碼修改,自動(dòng)熱啟動(dòng)服務(wù),方便開發(fā)調(diào)試。
到此這篇關(guān)于goland服務(wù)熱重啟的文章就介紹到這了,更多相關(guān)goland熱重啟內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
golang 實(shí)用庫(kù)gotable的具體使用
使用gotable框架以實(shí)現(xiàn)在CLI命令行界面中打印表格。本文就介紹一下golang 實(shí)用庫(kù)gotable的使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-07-07
試了下Golang實(shí)現(xiàn)try catch的方法
雖然在使用Golang的時(shí)候發(fā)現(xiàn)沒(méi)有try catch這種錯(cuò)誤處理機(jī)制但是想一想golang作為一門優(yōu)雅的語(yǔ)言,似乎也是情理之中。那么夠怎么捕獲異常呢,本文就來(lái)介紹一下2021-07-07
Go緩沖channel和非緩沖channel的區(qū)別說(shuō)明
這篇文章主要介紹了Go緩沖channel和非緩沖channel的區(qū)別說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-04-04
golang?MySQL實(shí)現(xiàn)對(duì)數(shù)據(jù)庫(kù)表存儲(chǔ)獲取操作示例
這篇文章主要為大家介紹了golang?MySQL實(shí)現(xiàn)對(duì)數(shù)據(jù)庫(kù)表存儲(chǔ)獲取操作示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11
golang 生成二維碼海報(bào)的實(shí)現(xiàn)代碼
這篇文章主要介紹了golang 生成二維碼海報(bào)的實(shí)現(xiàn)代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-02-02
golang?metrics各個(gè)指標(biāo)含義講解說(shuō)明
這篇文章主要為大家介紹了golang?metrics各個(gè)指標(biāo)含義講解說(shuō)明,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05
Go gin權(quán)限驗(yàn)證實(shí)現(xiàn)過(guò)程詳解
這篇文章主要為大家介紹了Go gin權(quán)限驗(yàn)證實(shí)現(xiàn)過(guò)程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01
關(guān)于go get 下載第三方包存儲(chǔ)路徑問(wèn)題
這篇文章主要介紹了關(guān)于go get 下載第三方包存儲(chǔ)路徑問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
Go語(yǔ)言中程序是怎么編譯的實(shí)現(xiàn)
本文主要介紹了Go語(yǔ)言中程序是怎么編譯的實(shí)現(xiàn),深入探討Go語(yǔ)言的編譯機(jī)制和最新的模塊管理系統(tǒng)Go Modules的使用,具有一定的參考價(jià)值,感興趣的可以了解一下2024-06-06

