stellar / go

Stellar's public monorepo of go code
https://stellar.org/developers
Apache License 2.0
1.3k stars 499 forks source link

buildling instructions don't work, xff.Handler does not exist. #2906

Closed arduent closed 3 years ago

arduent commented 4 years ago

What version are you using?

current

# cat go/go.mod 
module github.com/stellar/go

go 1.13

require (
        bitbucket.org/ww/goautoneg v0.0.0-20120707110453-75cd24fc2f2c
        firebase.google.com/go v3.12.0+incompatible
        github.com/BurntSushi/toml v0.3.1
        github.com/Masterminds/squirrel v0.0.0-20161115235646-20f192218cf5
        github.com/Microsoft/go-winio v0.4.14
        github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f // indirect
        github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f
        github.com/aws/aws-sdk-go v1.25.25
        github.com/dgrijalva/jwt-go v3.2.0+incompatible
        github.com/elazarl/go-bindata-assetfs v1.0.0
        github.com/fatih/structs v1.0.0 // indirect
        github.com/gavv/monotime v0.0.0-20161010190848-47d58efa6955 // indirect
        github.com/getsentry/raven-go v0.0.0-20160805001729-c9d3cc542ad1
        github.com/go-chi/chi v4.0.3+incompatible
        github.com/go-errors/errors v0.0.0-20150906023321-a41850380601
        github.com/gobuffalo/packr v1.12.1 // indirect
        github.com/google/go-querystring v0.0.0-20160401233042-9235644dd9e5 // indirect
        github.com/google/martian v2.1.0+incompatible // indirect
        github.com/googleapis/gax-go v2.0.2+incompatible // indirect
        github.com/gorilla/schema v1.1.0
        github.com/graph-gophers/graphql-go v0.0.0-20190225005345-3e8838d4614c
        github.com/guregu/null v2.1.3-0.20151024101046-79c5bd36b615+incompatible
        github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
        github.com/imkira/go-interpol v1.1.0 // indirect
        github.com/inconshreveable/mousetrap v1.0.0 // indirect
        github.com/jarcoal/httpmock v0.0.0-20161210151336-4442edb3db31
        github.com/jmoiron/sqlx v1.2.0
        github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
        github.com/klauspost/compress v0.0.0-20161106143436-e3b7981a12dd // indirect
        github.com/klauspost/cpuid v0.0.0-20160302075316-09cded8978dc // indirect
        github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 // indirect
        github.com/kr/pretty v0.0.0-20150520163514-e6ac2fc51e89 // indirect
        github.com/kr/text v0.0.0-20150520163712-e373e137fafd // indirect
        github.com/lann/builder v0.0.0-20140829050551-c603884a2c1f // indirect
        github.com/lib/pq v1.2.0
        github.com/magiconair/properties v1.5.4 // indirect
        github.com/manucorporat/sse v0.0.0-20160126180136-ee05b128a739
        github.com/mattn/go-colorable v0.1.2 // indirect
        github.com/mitchellh/go-homedir v1.1.0
        github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366 // indirect
        github.com/mndrix/ps v0.0.0-20131111202200-33ddf69629c1 // indirect
        github.com/moul/http2curl v0.0.0-20161031194548-4e24498b31db // indirect
        github.com/onsi/ginkgo v1.7.0
        github.com/onsi/gomega v1.4.3
        github.com/opentracing/opentracing-go v1.1.0 // indirect
        github.com/pkg/errors v0.8.1
        github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
        github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
        github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00
        github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521 // indirect
        github.com/rubenv/sql-migrate v0.0.0-20190717103323-87ce952f7079
        github.com/sebest/xff v0.0.0-20150611211316-7a36e3a787b5
        github.com/segmentio/go-loggly v0.5.1-0.20171222203950-eb91657e62b2
        github.com/sergi/go-diff v0.0.0-20161205080420-83532ca1c1ca // indirect
        github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
        github.com/sirupsen/logrus v1.4.1
        github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect
        github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94 // indirect
        github.com/spf13/cobra v0.0.0-20160830174925-9c28e4bbd74e
        github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431 // indirect
        github.com/spf13/pflag v0.0.0-20161005214240-4bd69631f475
        github.com/spf13/viper v0.0.0-20150621231900-db7ff930a189
        github.com/stellar/go-xdr v0.0.0-20200331223602-71a1e6d555f2
        github.com/stellar/throttled v2.2.3-0.20190823235211-89d75816f59d+incompatible
        github.com/stretchr/testify v1.5.1
        github.com/tyler-smith/go-bip39 v0.0.0-20180618194314-52158e4697b8
        github.com/valyala/bytebufferpool v1.0.0 // indirect
        github.com/valyala/fasthttp v0.0.0-20170109085056-0a7f0a797cd6 // indirect
        github.com/xeipuuv/gojsonpointer v0.0.0-20151027082146-e0fe6f683076 // indirect
        github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c // indirect
        github.com/xeipuuv/gojsonschema v0.0.0-20161231055540-f06f290571ce // indirect
        github.com/yalp/jsonpath v0.0.0-20150812003900-31a79c7593bb // indirect
        github.com/yudai/gojsondiff v0.0.0-20170107030110-7b1b7adf999d // indirect
        github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce // indirect
        github.com/yudai/pp v2.0.1+incompatible // indirect
        github.com/ziutek/mymysql v1.5.4 // indirect
        golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
        golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
        golang.org/x/text v0.3.3 // indirect
        golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c // indirect
        google.golang.org/api v0.3.1
        google.golang.org/appengine v1.6.1 // indirect
        gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
        gopkg.in/gavv/httpexpect.v1 v1.0.0-20170111145843-40724cf1e4a0
        gopkg.in/gorp.v1 v1.7.1 // indirect
        gopkg.in/square/go-jose.v2 v2.4.1
        gopkg.in/tylerb/graceful.v1 v1.2.13
)
u:~# go list -m
go list -m: not using modules

What did you do?

u:~# go install github.com/stellar/go/services/horizon
can't load package: package github.com/stellar/go/services/horizon: cannot find package "github.com/stellar/go/services/horizon" in any of:
        /usr/lib/go/src/github.com/stellar/go/services/horizon (from $GOROOT)
        /root/go/src/github.com/stellar/go/services/horizon (from $GOPATH)

I think it's supposed to be "go get" not "go install" maybe the build instructions are wrong.

u:~# go get github.com/stellar/go/services/horizon
# github.com/stellar/go/services/horizon/internal/httpx
go/src/github.com/stellar/go/services/horizon/internal/httpx/router.go:77:8: undefined: xff.Handler
u:~# go get github.com/stellar/go/services/horizon
# github.com/stellar/go/services/horizon/internal/httpx
go/src/github.com/stellar/go/services/horizon/internal/httpx/router.go:77:8: undefined: xff.Handler

What did you expect to see?

no errors

What did you see instead?

go/src/github.com/stellar/go/services/horizon/internal/httpx/router.go:77:8: undefined: xff.Handler

in the file github.com/stellar/go/services/horizon/internal/httpx/router.go (line 77)

Changing:

r.Use(xff.Handler)

to :

xffmw, _ := xff.Default()      
r.Use(xffmw.Handler)

then horizon runs. But maybe it doesn't get the "forward ip" from the headers. I haven't gotten that far yet.

I am using go version: go1.14.6 linux/amd64

bartekn commented 4 years ago

Thanks for the report. Looks like we haven't updated the guide after migrating to go modules. You need to set GO111MODULE=on env variable. Then after running go get -v github.com/stellar/go/services/horizon you'll find horizon binary in your $GOPATH/bin/horizon. To add code changes, just git clone the repo.

ire-and-curses commented 4 years ago

Next step: update docs.

bartekn commented 3 years ago

This should work without any config changes in the latest two versions of Golang. If not, please reopen.