confd icon indicating copy to clipboard operation
confd copied to clipboard

how do you build?

Open xin-at-marathon opened this issue 2 years ago • 3 comments

This is the 1st time I try to build confd.

go version
go version go1.18.3 linux/amd64
export GOPATH=/data

I follow the instruction:

$ mkdir -p $GOPATH/src/github.com/kelseyhightower
$ git clone https://github.com/kelseyhightower/confd.git $GOPATH/src/github.com/kelseyhightower/confd
$ cd $GOPATH/src/github.com/kelseyhightower/confd
$ make

then I got error:

Building confd...
go: cannot find main module, but found Gopkg.lock in /data/src/github.com/kelseyhightower/confd
        to create a module there, run:
        go mod init
make: *** [build] Error 1

If I run go mod init, I will get:

go mod init
go: creating new go.mod: module github.com/kelseyhightower/confd
go: copying requirements from Gopkg.lock
go: to add module requirements and sums:
        go mod tidy

If I run go mod tidy, I will get:

……
……
……
go: found github.com/armon/go-radix in github.com/armon/go-radix v1.0.0
go: found github.com/hashicorp/go-memdb in github.com/hashicorp/go-memdb v1.3.3
go: found github.com/hashicorp/golang-lru in github.com/hashicorp/golang-lru v0.5.4
go: found github.com/keybase/go-crypto/openpgp in github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4
go: found github.com/keybase/go-crypto/openpgp/packet in github.com/keybase/go-crypto v0.0.0-20200123153347-de78d2cb44f4                                                                                                                     
go: found github.com/mitchellh/go-testing-interface in github.com/mitchellh/go-testing-interface v1.14.1
go: found github.com/patrickmn/go-cache in github.com/patrickmn/go-cache v2.1.0+incompatible
go: found github.com/ghodss/yaml in github.com/ghodss/yaml v1.0.0
go: found github.com/grpc-ecosystem/grpc-gateway/runtime in github.com/grpc-ecosystem/grpc-gateway v1.16.0
go: found github.com/tmc/grpc-websocket-proxy/wsproxy in github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75                                                                                                              
go: found github.com/prometheus/client_golang/prometheus in github.com/prometheus/client_golang v1.12.2
go: found github.com/jonboulle/clockwork in github.com/jonboulle/clockwork v0.3.0
go: found golang.org/x/time/rate in golang.org/x/time v0.0.0-20220609170525-579cf78fd858
go: found github.com/xiang90/probing in github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
go: found golang.org/x/sync/errgroup in golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
go: found github.com/golang/glog in github.com/golang/glog v1.0.0
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.6
go: found github.com/hashicorp/go-plugin in github.com/hashicorp/go-plugin v1.4.4
go: found github.com/hashicorp/go-version in github.com/hashicorp/go-version v1.5.0
go: found github.com/grpc-ecosystem/grpc-gateway/utilities in github.com/grpc-ecosystem/grpc-gateway v1.16.0
go: found github.com/google/btree in github.com/google/btree v1.1.1
go: found github.com/golang/groupcache/lru in github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: found github.com/hashicorp/yamux in github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87
go: found github.com/duosecurity/duo_api_golang in github.com/duosecurity/duo_api_golang v0.0.0-20220428205559-fa137a8ef05b                                                                                                                  
go: found github.com/duosecurity/duo_api_golang/authapi in github.com/duosecurity/duo_api_golang v0.0.0-20220428205559-fa137a8ef05b                                                                                                          
go: found github.com/gocql/gocql in github.com/gocql/gocql v1.1.0
go: found github.com/SAP/go-hdb/driver in github.com/SAP/go-hdb v0.106.1
go: found gopkg.in/mgo.v2 in gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
go: found github.com/denisenkom/go-mssqldb in github.com/denisenkom/go-mssqldb v0.12.2
go: found github.com/go-sql-driver/mysql in github.com/go-sql-driver/mysql v1.6.0
go: found github.com/lib/pq in github.com/lib/pq v1.10.6
go: github.com/kelseyhightower/confd/backends/etcdv3 imports
        github.com/coreos/etcd/clientv3 tested by
        github.com/coreos/etcd/clientv3.test imports
        github.com/coreos/etcd/auth imports
        github.com/coreos/etcd/mvcc/backend imports
        github.com/coreos/bbolt: github.com/coreos/[email protected]: parsing go.mod:
        module declares its path as: go.etcd.io/bbolt
                but was required as: github.com/coreos/bbolt

If I run make AGAIN, I'll get this error:

make
Building confd...
go: inconsistent vendoring in /data/src/github.com/kelseyhightower/confd:
        github.com/BurntSushi/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/aws/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/coreos/[email protected]+incompatible: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/coreos/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/fsnotify/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/garyburd/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/go-ini/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/gogo/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/golang/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/golang/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/hashicorp/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/jmespath/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/kelseyhightower/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/mitchellh/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/mitchellh/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/ryanuber/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/samuel/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/sethgrid/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/sirupsen/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/ugorji/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        github.com/xordataexchange/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        google.golang.org/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        google.golang.org/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        gopkg.in/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

        To ignore the vendor directory, use -mod=readonly or -mod=mod.
        To sync the vendor directory, run:
                go mod vendor
make: *** [build] Error 1

any hint? please help.

xin-at-marathon avatar Jun 14 '22 08:06 xin-at-marathon

I was trying the same locally with up to date golang, also 1.10 - no luck. Then I noticed it contains dockerfile in the repo root, built an image from it, installed gcc apk update; apk add gcc then make build and it worked

eugenetaranov avatar Aug 11 '22 09:08 eugenetaranov

This is extremely gross, and I'm not super well-versed in the go build, but this is how I've gotten it to (seemingly 😅) build cleanly with go1.18.1:

cd "${GOPATH}/src/github.com/kelseyhightower/confd"
go mod init
go mod tidy -e -compat=1.10
go mod vendor 2>&1 | grep 'go get ' | while read LINE; do
    sh -c "$LINE"
done
go mod vendor
make

RangerRick avatar Aug 24 '22 13:08 RangerRick

@xin-at-marathon I tried to add go mod and go 1.19 support at #860 , You can use this version to build confd.

Need @kelseyhightower review.

yufeiminds avatar Sep 09 '22 04:09 yufeiminds