Unable to build Caddy module

1. The problem I’m having: Unable to build Caddy module

  • I wanted to try building caddy modules , so I picked up the example module from : Extending Caddy — Caddy Documentation
  • I build it using the command 'xcaddy build filename ’ in this case its caddy_vis_ip.go

2. Error messages and/or full log output: I am getting the following error

3. Caddy version:

  • Caddy version is : v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy: I installed Caddy in the following method :

-Install — Caddy Documentation

a. System environment:

  • I am on ubuntu - Ubuntu 18.04.6 LTS

b. Command:

  • I am using the command : xcaddy build caddy_vis_ip.go

You can’t build from a specific filename. You need a valid git repo with a go.mod file.

Okay, so do i give the git repo in the import section of the code ?

Take a look at any of the plugins on Download Caddy, look at their github repos to see how the files are structured.

Your module needs a name, generally it’s a github repo “URL” (not a real URL) which Go can use to pull the module.

You can do a module replacement using xcaddy to make it use your local copy when developing/debugging like this: --with github.com/your/module=../path/to/your/module. See the syntax here GitHub - caddyserver/xcaddy: Build Caddy with plugins

From the Golang wiki, this is how you make a module: Modules · golang/go Wiki · GitHub

Thanks for the help!

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