我的更改尚未在go应用程序中结束。 怎么回事?

I'm new to go.

I have cloned this project: [oauth2_proxy][1] I'm wanting to add another provider. So I created the provider file in providers. Added the provider name to the providers switch statement. However, when I build the resulting binary, the provider keeps falling back to google.

It seems my provider has not been added. I suspect that go build might be pulling the providers from github and ignoring my local changes. Would that be right? How do you build this thing?

I'm building with go build because ./dist.sh script didn't work for me. I'm managing to produce a binary. But it doesn't appear my code file ended up in it. I know this because when I grep for "google" or "linkedin" or any of the provider names on the resulting binary it says: Binary file oauth2_proxy matches. But for my own provider, there is no match.

It's probably got something to do with the way I'm compiling the app. How do I do that? no instructions on the github page for doing that are provided. Sorry for my ignorance. I'm coming from a c++ background which is more logical. Go seems to pick up dependancies automagically!?


Following suggestions from @Topo

matthewh@xen:~/dev/oauth2_proxy$ export GOPATH=`pwd`
matthewh@xen:~/dev/oauth2_proxy$ rm -rf src
matthewh@xen:~/dev/oauth2_proxy$ go get ./...
go install: no install location for directory /home/matthewh/dev/oauth2_proxy outside GOPATH
    For more details see: 'go help gopath'
go install: no install location for directory /home/matthewh/dev/oauth2_proxy/api outside GOPATH
    For more details see: 'go help gopath'
go install: no install location for directory /home/matthewh/dev/oauth2_proxy/cookie outside GOPATH
    For more details see: 'go help gopath'
go install: no install location for directory /home/matthewh/dev/oauth2_proxy/providers outside GOPATH
    For more details see: 'go help gopath'

src/cloud.google.com/go/internal/retry.go:21:2: cannot find package "github.com/googleapis/gax-go" in any of:
    /usr/local/go/src/github.com/googleapis/gax-go (from $GOROOT)
    /home/matthewh/dev/oauth2_proxy/src/github.com/googleapis/gax-go (from $GOPATH)
src/google.golang.org/api/internal/settings.go:22:2: cannot find package "google.golang.org/grpc" in any of:
    /usr/local/go/src/google.golang.org/grpc (from $GOROOT)
    /home/matthewh/dev/oauth2_proxy/src/google.golang.org/grpc (from $GOPATH)
src/google.golang.org/api/transport/dial.go:30:2: cannot find package "google.golang.org/grpc/credentials" in any of:
    /usr/local/go/src/google.golang.org/grpc/credentials (from $GOROOT)

 ...


EDIT:

I just did go get -v github.com/bitly/oauth2_proxy on my machine.

Verbose Details: http://pasted.co/60e2b56d

Binary is produced under $GOPATH/bin/oauth2_proxy.

-rwxr-xr-x  1 jeeva  staff    10M Jul 11 19:02 oauth2_proxy

Let's start from basis. First setup your Go workspace (How to Write Go Code) pick a directory for GOPATH.

For example: /Users/matt/dev

export GOPATH=/Users/matt/dev

Then do go get to get the oauth2_proxy. Typically go get is git clone of that repository.

go get github.com/bitly/oauth2_proxy

It will get the source code and runs go install. After successful execution of this command. You will see binary file in $GOPATH/bin.

Now modified the source code as you need and run go install to build the binary.

go install github.com/bitly/oauth2_proxy

OR
cd $GOPATH/src/github.com/bitly/oauth2_proxy
go install

If you would like to manually instead of go get. Then pick a directory for GOPATH and export it (as mentioned above) then

mkdir -p $GOPATH/src/github.com/bitly
cd $GOPATH/src/github.com/bitly
git clone https://github.com/bitly/oauth2_proxy.git
cd oauth2_proxy
go get ./...
go install 

Now binary will be in $GOPATH/bin.