Caddy: error loading module requirements

Created on 21 Aug 2019  路  3Comments  路  Source: caddyserver/caddy

I followed the instructions for building caddy:

  1. export GO111MODULE=on
  2. mkdir caddy
  3. cd caddy
  4. create .go file:
package main

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

    // plug in plugins here, for example:
    // _ "import/path/here"
)

func main() {
    // optional: disable telemetry
    // caddymain.EnableTelemetry = false
    caddymain.Run()
}
  1. go mod init caddy
  2. go get github.com/caddyserver/caddy
  3. go build

This is the result:

go: finding github.com/mholt/caddy/caddy/caddymain latest
go: finding github.com/mholt/caddy/caddy latest
go: github.com/mholt/[email protected]: parsing go.mod: unexpected module path "github.com/caddyserver/caddy"
go: error loading module requirements

Arch Linux, go version go1.12.8 linux/amd64

Most helpful comment

I just successfully followed these same steps in an alpine linux Docker image. What is your .go file named? It should have a name like main.go, not just .go. That's the only thing I see different about what you're doing. The directory should also not be in the caddy source tree. Not sure where you've created it.

All 3 comments

I just successfully followed these same steps in an alpine linux Docker image. What is your .go file named? It should have a name like main.go, not just .go. That's the only thing I see different about what you're doing. The directory should also not be in the caddy source tree. Not sure where you've created it.

I just successfully followed these same steps in an alpine linux Docker image. What is your .go file named? It should have a name like main.go, not just .go. That's the only thing I see different about what you're doing. The directory should also not be in the caddy source tree. Not sure where you've created it.

Oh my god, that was exactly it. I guess I didn't read carefully enough. Thanks. I'm not familiar with go so I thought .go was the standard config file name or something.

Ah, wow. Glad you figured that out. :)

The docs say (emphasis added):

create a Go file (_extension_ .go)

Sorry if that wasn't clear. It's a file extension, not a file name.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wallacyyy picture wallacyyy  路  53Comments

adamwathan picture adamwathan  路  37Comments

roblabla picture roblabla  路  45Comments

redbeard0x0a picture redbeard0x0a  路  57Comments

pastjean picture pastjean  路  40Comments