0

I am trying to build a Homebrew formula for a Go service I have built and make it easy to install for my co-workers. I am total newbie to Ruby. The formula I write fails to run with following error

my-server.rb:1:in `<main>': uninitialized constant Formula (NameError)

Formula code is as below

class My < Formula
  desc "My Server"
  homepage "https://my.io/"
  url "https://github.com/my-server/archive/v1.0.8.tar.gz"
  sha256 "f9c7b083f19ba1ff2ec3bebc69102ac053cb4f4e0002c6c8df7b3969d46a275b"
  head "https://github.com/my-server.git"
  version "1.0.8"

  depends_on "go" => :build

  def install
    ENV["GOPATH"] = buildpath

    bin_path = buildpath/"src/github.com/my-server"
    # Copy all files from their current location (GOPATH root)
    # to $GOPATH/src/github.com/my-server
    bin_path.install Dir["*"]


    Language::Go.stage_deps resources, buildpath/"src"
    cd bin_path do
      # Install the compiled binary into Homebrew's `bin` - a pre-existing
      # global variable
      system "go", "build", "./..."
      system "go", "build", "-o", bin/"my-server", "main.go"
    end
  end

  test do
    assert_match "[GIN-debug] Listening and serving HTTP on 0.0.0.0:3636", shell_output("#{bin}/my-server", 2)
  end
end
Korba
  • 435
  • 1
  • 4
  • 18

0 Answers0