簡體   English   中英

將多個應用程序組合成一個二進制文件

[英]Combine multiple applications into single binary

假設我有四個應用程序:

  1. http-網關
  2. NATS
  3. 業務邏輯客戶端
  4. 業務邏輯服務器
Gateway <--> NATS <---> B.L.

我的項目結構如下:

nats-cluster\
  cmd\
    gateway\gatway.go
    blclient\blclient.go
    blserver\blserver.go
  gateway\
  blclient\
  blserver\

目前,我必須分別運行其中的四個,然后他們才能相互交談。 網關和 BLclient 使用request-reply模式,而blclient使用grpcblserver交換消息。 我想知道是否有任何方法可以在 Go 中生成單個二進制文件,以便應用程序可以通過單個二進制文件運行。

有沒有辦法在 Go 中將多個應用程序二進制文件組合成一個?

我將 NATS 服務器嵌入到 Simple IoT 應用程序中。 這是我如何做到的:

https://github.com/simpleiot/simpleiot/blob/master/cmd/siot/main.go#L452

https://github.com/simpleiot/simpleiot/blob/master/natsserver/nats-server.go

效果很好,而且超級容易做。

對於某些應用程序,將所有內容捆綁在一個 Go 應用程序中是有意義的,因為部署要簡單得多。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM