[Solved] Help needed for wring a go project formula

Jesus. Took hours found it a network, or broken cache problem?!


Trying to build binary from a go project. I’m not familiar with ruby, just trying to guess and try the codes of my formula. Here’s it.

No idea why building failed when uncomment the default_config part, needs your help.

brew install --HEAD routedns -v

require "language/go"

class Routedns < Formula
  desc "DNS stub resolver, proxy and router with support for DoT, DoH, DoQ, and DTLS"
  homepage "https://github.com/folbricht/routedns"
  # url ""
  # sha256 ""
  head "https://github.com/folbricht/routedns.git"

  depends_on "go" => :build

  def install
    ENV["GOPATH"] = buildpath
    path = buildpath/"src/github.com/folbricht/routedns"
    path.install Dir["*"]
    # Language::Go.stage_deps resources, buildpath/"src"

    # open("config.toml", "w") do |f|
    #   default_config = <<~END
    #     # Google DoT
    #     [resolvers.google8]
    #     address = "8.8.8.8:853"
    #     protocol = "dot"

    #     [resolvers.google4]
    #     address = "8.8.4.4:853"
    #     protocol = "dot"

    #     [groups.google-dot]
    #     # type = "cache"
    #     # type = "round-robin"
    #     type = "fail-rotate"
    #     # type = "response-collape"
    #     resolvers = ["google8", "google4"]

    #     [listeners.local-udp]
    #     address = "127.0.0.1:53001"
    #     protocol = "udp"
    #     resolver = "google-dot"

    #     [listeners.local-tcp]
    #     address = "127.0.0.1:53001"
    #     protocol = "tcp"
    #     resolver = "google-dot"
    #   END
    #   f << default_config
    # end

    # config_path = etc/"routedns"
    # mkdir_p config_path
    # Dir.glob(["config.toml"]).each do |dst|
    #   dst_default = config_path/"#{dst}.default"
    #   rm dst_default if dst_default.exist?
    #   config_path.install dst
    # end

    cd path/"cmd/routedns" do
      share_dst = "#{prefix}/share/routedns"
      mkdir_p share_dst
      cp_r "example-config", share_dst
      prefix.install_metafiles

      system "go", "build", "-o", bin/"routedns"
    end
  end

  test do
    system bin/"routedns", "-h"
  end
end

Without know what failed, when and how it’s impossible to help.

Sorry to disturb you. After cleaning homebrew caches and setup a mirror GOPROXY, the problem seem being solved. I tried uninstalling and rebuilding the formula many times with homebrew cached cleard.