[Golang] Build A Simple Web Service part.4 — Design An API To Integrate With Local Windows Service And Executable File
Introduction
在實務上很多時候需要讓web service呼叫執行檔做一些事情, 本篇將會分析不同設計方式的優缺點, 並且記錄在Golang中要如何實作這些機制 。

Call executable in the API
最直覺的方式是將呼叫執行檔的動作放到Controller中,一旦Request進來便會呼叫該執行檔 ,先試著使用這樣的方式看看。

基於前一篇中Use the interface的專案資料夾的根目錄下 ,新增libs資料夾 , jobExecuter.go ,config.go以及config.json:

以下將說明新增及修改到的檔案 。
libs/jobExecuter.go: jobExecuter.go的內容如下 ,ExecuteCommand的內容就是呼叫某個執行檔. path為檔案路徑 ,arguments為其參數 ,並將執行過後的std output, error output印出來:









