About problems when compiling third-party cloudflare plugins

At present, what I hope is to add third-party plug-ins through the source code, but unfortunately I have encountered some problems. Since I am still a super novice, I would like to ask you how to solve it?

As an example to restore the problem, I will show the process of my compilation:

Set the transitional environment variable for Go modules

export GO111MODULE=on

Create a file called caddy.go in the opt/ directory.

touch caddy.go

Edit the caddy.go file,Join the cloudflare plugin

package main

import (
	"github.com/caddyserver/caddy/caddy/caddymain"

	// plug in plugins here, for example:
	// _ "import/path/here"
        _ "github.com/caddyserver/dnsproviders/cloudflare"
)

func main() {
	// optional: disable telemetry
	// caddymain.EnableTelemetry = false
	caddymain.Run()
}

Then execute “go mod init caddy”

go mod init caddy

Run

go get github.com/caddyserver/caddy

Run

go install

But found the following problem

root@ip:/opt# go install
go: github.com/caddyserver/dnsproviders@v0.3.0 requires
        github.com/h2non/gock@v0.0.0-00010101000000-000000000000: unknown revision 000000000000
root@ip:/opt# 

what should I do? Can you tell me the solution? I am still a newbie

What is your go.mod?

Try removing $GOPATH/pkg/mod and also try go get github.com/caddyserver/dnsproviders@c2e7db47dc629b8813286b70ff106a4fc55bfb3b (the latest commit, instead of latest release).

go.mod

module caddy

go 1.13

I tried to delete $ GOPATH / pkg / mod and try go get github.com/caddyserver/dnsproviders@c2e7db47dc629b8813286b70ff106a4fc55bfb3b, but the following problem still occurs:


root@ip-172-31-32-102:~# go install

go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0

go: downloading github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a

go: downloading github.com/gorilla/websocket v1.4.0

go: downloading github.com/dustin/go-humanize v1.0.0

go: downloading gopkg.in/yaml.v2 v2.2.2

go: downloading github.com/hashicorp/go-syslog v1.0.0

go: downloading github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4

go: downloading github.com/lucas-clemente/quic-go v0.10.2

go: downloading github.com/naoina/toml v0.1.1

go: extracting github.com/hashicorp/go-syslog v1.0.0

go: extracting github.com/naoina/toml v0.1.1

go: extracting gopkg.in/natefinch/lumberjack.v2 v2.0.0

go: downloading github.com/naoina/go-stringutil v0.1.0

go: extracting github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4

go: extracting github.com/naoina/go-stringutil v0.1.0

go: extracting gopkg.in/yaml.v2 v2.2.2

go: extracting github.com/dustin/go-humanize v1.0.0

go: extracting github.com/gorilla/websocket v1.4.0

go: extracting github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a

go: extracting github.com/lucas-clemente/quic-go v0.10.2

go: downloading github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115

go: downloading github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9

go: downloading github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f

go: downloading github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47

go: downloading github.com/lucas-clemente/quic-go-certificates v0.0.0-20160823095156-d2f86524cced

go: finding github.com/caddyserver/dnsproviders v0.3.0

go: extracting github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115

go: extracting github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f

go: extracting github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47

go: downloading github.com/caddyserver/dnsproviders v0.3.0

go: extracting github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9

go: extracting github.com/lucas-clemente/quic-go-certificates v0.0.0-20160823095156-d2f86524cced

go: extracting github.com/caddyserver/dnsproviders v0.3.0

go: github.com/caddyserver/dnsproviders@v0.3.0 requires

github.com/h2non/gock@v0.0.0-00010101000000-000000000000: unknown revision 000000000000
root@ip:~# go get github.com/caddyserver/dnsproviders@c2e7db47dc629b8813286b70ff106a4fc55bfb3b
go: finding github.com/caddyserver/dnsproviders c2e7db47dc629b8813286b70ff106a4fc55bfb3b
go get: github.com/caddyserver/dnsproviders@v0.3.1-0.20190725163104-c2e7db47dc62 requires
        github.com/h2non/gock@v0.0.0-00010101000000-000000000000: unknown revision 000000000000

Still not, suggesting an error

Hmm, I dunno. Try using replace as suggested here: go mod vendor: parsing go.mod: unexpected module path "gopkg.in/h2non/gock.v1" · Issue #50 · h2non/gock · GitHub

OK, the problem is solved

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.