infogulch / xtemplate

A html/template-based hypertext preprocessor and rapid application development web server written in Go.
Apache License 2.0
73 stars 1 forks source link

xcaddy fails on Mac due to module name change ? #2

Closed gedw99 closed 11 months ago

gedw99 commented 11 months ago

Looks like the Module name has changed ?

xcaddy build --with github.com/infogulch/caddy-xtemplate=.

2023/10/09 14:59:21 [INFO] exec (timeout=0s): /opt/homebrew/opt/go/libexec/bin/go get -d -v github.com/infogulch/caddy-xtemplate github.com/caddyserver/caddy/v2 
go: github.com/infogulch/caddy-xtemplate@v0.0.0-20231007181448-f5f52f687e69 found: parsing go.mod:
        module declares its path as: github.com/infogulch/xtemplate
                but was required as: github.com/infogulch/caddy-xtemplate
go: github.com/infogulch/caddy-xtemplate@upgrade (v0.0.0-20231007181448-f5f52f687e69) requires github.com/infogulch/caddy-xtemplate@v0.0.0-20231007181448-f5f52f687e69: parsing go.mod:
        module declares its path as: github.com/infogulch/xtemplate
                but was required as: github.com/infogulch/caddy-xtemplate
2023/10/09 14:59:21 [FATAL] exit status 1

Might have to do it the old way with custom main.go for now.

package main

import (
    caddycmd "github.com/caddyserver/caddy/v2/cmd"

    // plug in Caddy modules here
    _ "github.com/caddyserver/caddy/v2/modules/standard"
    _ "github.com/infogulch/xtemplate/caddy" 
)

func main() {
    caddycmd.Main()
}
infogulch commented 11 months ago

It's taken me a minute to figure out how to structure the project; I think this last iteration is right. But renaming a module in go can be annoying for users. Sorry about that.

Have you tried clearing the cache with go clean -modcache and then downloading again? (maybe go get ./...)

gedw99 commented 11 months ago

It's cool :) not need to say sorry.

I tried your suggestions but same thing...

go clean -modcache
cd xtemplate && go get ./...

cd xtemplate && GOFLAGS='-tags="sqlite_json"' CGO_ENABLED=1 xcaddy build --with github.com/infogulch/caddy-xtemplate --with github.com/greenpau/caddy-security --with github.com/infogulch/xrss
2023/10/10 09:34:00 [INFO] Temporary folder: /Users/apple/workspace/go/src/github.com/gedw99/gio-htmx/exp/caddy/xtemplate/buildenv_2023-10-10-0934.3938334582
2023/10/10 09:34:00 [INFO] Writing main module: /Users/apple/workspace/go/src/github.com/gedw99/gio-htmx/exp/caddy/xtemplate/buildenv_2023-10-10-0934.3938334582/main.go
package main

import (
        caddycmd "github.com/caddyserver/caddy/v2/cmd"

        // plug in Caddy modules here
        _ "github.com/caddyserver/caddy/v2/modules/standard"
        _ "github.com/infogulch/caddy-xtemplate"
        _ "github.com/greenpau/caddy-security"
        _ "github.com/infogulch/xrss"
)

func main() {
        caddycmd.Main()
}
2023/10/10 09:34:00 [INFO] Initializing Go module
2023/10/10 09:34:00 [INFO] exec (timeout=0s): /opt/homebrew/opt/go/libexec/bin/go mod init caddy 
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2023/10/10 09:34:00 [INFO] Pinning versions
2023/10/10 09:34:00 [INFO] exec (timeout=0s): /opt/homebrew/opt/go/libexec/bin/go get -d -v github.com/caddyserver/caddy/v2 
go: downloading github.com/caddyserver/caddy/v2 v2.7.4
go: downloading github.com/caddyserver/caddy v1.0.5
go: downloading github.com/caddyserver/certmagic v0.19.2
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/prometheus/client_golang v1.14.0
go: downloading github.com/quic-go/quic-go v0.37.5
go: downloading go.uber.org/zap v1.25.0
go: downloading golang.org/x/sys v0.11.0
go: downloading golang.org/x/term v0.11.0
go: downloading go.uber.org/multierr v1.11.0
go: downloading github.com/klauspost/cpuid/v2 v2.2.5
go: downloading github.com/libdns/libdns v0.2.1
go: downloading github.com/mholt/acmez v1.2.0
go: downloading github.com/miekg/dns v1.1.55
go: downloading github.com/zeebo/blake3 v0.2.3
go: downloading golang.org/x/crypto v0.12.0
go: downloading golang.org/x/net v0.14.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.2.0
go: downloading github.com/golang/protobuf v1.5.3
go: downloading github.com/prometheus/client_model v0.3.0
go: downloading github.com/prometheus/common v0.37.0
go: downloading github.com/prometheus/procfs v0.8.0
go: downloading google.golang.org/protobuf v1.31.0
go: downloading github.com/quic-go/qpack v0.4.0
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/golang/mock v1.6.0
go: downloading github.com/onsi/ginkgo/v2 v2.9.5
go: downloading golang.org/x/tools v0.10.0
go: downloading golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/quic-go/qtls-go1-20 v0.3.1
go: downloading golang.org/x/mod v0.11.0
go: downloading github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572
go: downloading github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1
go: added github.com/beorn7/perks v1.0.1
go: added github.com/caddyserver/caddy/v2 v2.7.4
go: added github.com/caddyserver/certmagic v0.19.2
go: added github.com/cespare/xxhash/v2 v2.2.0
go: added github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572
go: added github.com/golang/mock v1.6.0
go: added github.com/golang/protobuf v1.5.3
go: added github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1
go: added github.com/google/uuid v1.3.0
go: added github.com/klauspost/cpuid/v2 v2.2.5
go: added github.com/libdns/libdns v0.2.1
go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go: added github.com/mholt/acmez v1.2.0
go: added github.com/miekg/dns v1.1.55
go: added github.com/onsi/ginkgo/v2 v2.9.5
go: added github.com/prometheus/client_golang v1.14.0
go: added github.com/prometheus/client_model v0.3.0
go: added github.com/prometheus/common v0.37.0
go: added github.com/prometheus/procfs v0.8.0
go: added github.com/quic-go/qpack v0.4.0
go: added github.com/quic-go/qtls-go1-20 v0.3.1
go: added github.com/quic-go/quic-go v0.37.5
go: added github.com/zeebo/blake3 v0.2.3
go: added go.uber.org/multierr v1.11.0
go: added go.uber.org/zap v1.25.0
go: added golang.org/x/crypto v0.12.0
go: added golang.org/x/exp v0.0.0-20230310171629-522b1b587ee0
go: added golang.org/x/mod v0.11.0
go: added golang.org/x/net v0.14.0
go: added golang.org/x/sys v0.11.0
go: added golang.org/x/term v0.11.0
go: added golang.org/x/text v0.12.0
go: added golang.org/x/tools v0.10.0
go: added google.golang.org/protobuf v1.31.0
2023/10/10 09:34:08 [INFO] exec (timeout=0s): /opt/homebrew/opt/go/libexec/bin/go get -d -v github.com/infogulch/caddy-xtemplate github.com/caddyserver/caddy/v2 
go: downloading github.com/infogulch/caddy-xtemplate v0.1.1
go: github.com/infogulch/caddy-xtemplate@v0.1.1 found: parsing go.mod:
        module declares its path as: github.com/infogulch/xtemplate
                but was required as: github.com/infogulch/caddy-xtemplate
go: github.com/infogulch/caddy-xtemplate@upgrade (v0.1.1) requires github.com/infogulch/caddy-xtemplate@v0.1.1: parsing go.mod:
        module declares its path as: github.com/infogulch/xtemplate
                but was required as: github.com/infogulch/caddy-xtemplate
2023/10/10 09:34:08 [FATAL] exit status 1
infogulch commented 11 months ago

Ah the issue is the xcaddy invocation:

# ❌ 
GOFLAGS='-tags="sqlite_json"' CGO_ENABLED=1 xcaddy build --with github.com/infogulch/caddy-xtemplate --with github.com/greenpau/caddy-security --with github.com/infogulch/xrss

# ✔️ 
GOFLAGS='-tags="sqlite_json"' CGO_ENABLED=1 xcaddy build --with github.com/infogulch/xtemplate --with github.com/greenpau/caddy-security --with github.com/infogulch/xrss

I pushed an update to clarify the readme. The readme needs another pass after separating it from caddy, I'll get to that soon.

gedw99 commented 11 months ago

:) thanks