好吧,我想我終于在沒有更多想法或幫助的情況下堅持嘗試了。我嘗試使用https://github.com/billgraziano/go-windows-svc/blob/master/cmd/gosvc/main.go。我克隆了它并根據(jù)自述文件的內(nèi)容進行了調(diào)整。這應(yīng)該會啟動一項服務(wù)。該服務(wù)正在運行我們將調(diào)用的 DCA,它會啟動服務(wù)器。所以我什至還沒有開始調(diào)試這方面的其他問題。問題是當我嘗試進行構(gòu)建時PS C:\Users\rutger\go\src\go-windows-svc\cmd\gosvc> go build main.gomain.go:10:2: cannot find package "bitbucket.org/somepalce/go-dca-base/cmd/dca-agent/main.go" in any of: c:\go\src\bitbucket.org\someplace\go-dca-base\cmd\dca-agent\main.go (from $GOROOT) C:\Users\rutger\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go (from $GOPATH)這是他的程序的主要內(nèi)容,但第一個導入是相對于我的路徑進行調(diào)整的。包主import ( "bitbucket.org/someplace/go-dca-base/cmd/dca-agent/main.go" "github.com/pkg/errors")windows服務(wù)項目的文件結(jié)構(gòu)C:\USERS\RUTGER\GO\SRC\GO-WINDOWS-SVC├───app└───cmd └───gosvc -- (has the main)DCA 的文件結(jié)構(gòu)C:\USERS\RUTGER\GO\SRC\BITBUCKET.ORG\SOMEPLACE\GO-DCA-BASE\CMD\DCA-AGENT├───cmd -- (has main for DCA)├───compile└───logsPS C:\Users\rutger\go\src\go-windows-svc\cmd\gosvc> go build main.go main.go:10:2: 找不到包“bitbucket.org/somepalce/go-dca-base /cmd/dca-agent/main.go”位于以下任一位置:c:\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go(來自 $GOROOT)C: \Users\rutger\go\src\bitbucket.org\somepalce\go-dca-base\cmd\dca-agent\main.go (來自 $GOPATH) PS C:\Users\rutger\go\src\go-windows -svc\cmd\gosvc>
走吧,道路崎嶇不平。
慕尼黑8549860
2023-07-10 10:10:40