class ServerGo < Formula desc "Server for OpenIoTHub" homepage "https://github.com/OpenIoTHub/server-go" url "https://github.com/OpenIoTHub/server-go.git", tag: "v1.1.65", revision: "e7416e34d01b6989ad395339edd00ae6ac954460" license "MIT" livecheck do url :stable strategy :github_latest end bottle do sha256 cellar: :any_skip_relocation, big_sur: "f09c3b2830df79c8fed0ea4da8dd56d0dedb343996b9d1518a9627caece24279" sha256 cellar: :any_skip_relocation, catalina: "ee8a6a8d3bdb8528614ebd6e5d696804b92bb014f46fe894309c50d59abb13ad" sha256 cellar: :any_skip_relocation, mojave: "9adaf7d94669982fc6d151fc1b11f0bf9dfde8640eaaf8f8b09e1f071442bd90" end depends_on "go" => :build def install (etc/"server-go").mkpath system "go", "build", "-mod=vendor", "-ldflags", "-s -w -X main.version=#{version} -X main.commit=#{Utils.git_head} -X main.builtBy=homebrew", *std_go_args etc.install "server-go.yaml" => "server-go/server-go.yaml" end plist_options manual: "server-go -c #{HOMEBREW_PREFIX}/etc/server-go/server-go.yaml" def plist <<~EOS Label #{plist_name} KeepAlive ProgramArguments #{opt_bin}/server-go -c #{etc}/server-go/server-go.yaml StandardErrorPath #{var}/log/server-go.log StandardOutPath #{var}/log/server-go.log EOS end test do assert_match version.to_s, shell_output("#{bin}/server-go -v 2>&1") assert_match "config created", shell_output("#{bin}/server-go init --config=server.yml 2>&1") assert_predicate testpath/"server.yml", :exist? end end