Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the library compatible with go tools #3

Closed
wants to merge 1 commit into from

Conversation

arikfr
Copy link

@arikfr arikfr commented Jun 2, 2013

Moved each example into its own directory.

Moved each example into its own directory.
@abbot
Copy link
Owner

abbot commented Jun 2, 2013

Examples were already compatible with go tools, both v1.0.x and v1.1. You could build them using the following commands:

go build basic.go
go build digest.go
go build wrapped.go

I'm not convinced that this fix is essential.

@ghost ghost assigned abbot Jun 2, 2013
@arikfr
Copy link
Author

arikfr commented Jun 2, 2013

Sorry for not explaining before. I will try to explain it now.

The problem occurs when you try to build all of your packages, or all packages under certain path (when the go-http-auth is one of them), for example:

$ go build all
$ go build ./src/...

Both valid uses and are handy when you want to build a big project without specifying every single package you have. In this case it will try to build the examples, which will fail for:

can't load package: /Users/arikfr/dev/go/src/github.com/abbot/go-http-auth/examples/basic.go:12:2: local import ".." in non-local package

Now even if you change the local import into regular import (".." -> github.com/abbot/go-http-auth), it will still fail because of redeclaration of same methods (because it tries to build all examples as one package):

# github.com/abbot/go-http-auth/examples
src/github.com/abbot/go-http-auth/examples/digest.go:17: Secret redeclared in this block
    previous declaration at src/github.com/abbot/go-http-auth/examples/basic.go:17
src/github.com/abbot/go-http-auth/examples/digest.go:25: handle redeclared in this block
    previous declaration at src/github.com/abbot/go-http-auth/examples/basic.go:25
src/github.com/abbot/go-http-auth/examples/digest.go:29: main redeclared in this block
    previous declaration at src/github.com/abbot/go-http-auth/examples/basic.go:29
src/github.com/abbot/go-http-auth/examples/wrapped.go:18: Secret redeclared in this block
    previous declaration at src/github.com/abbot/go-http-auth/examples/digest.go:17
src/github.com/abbot/go-http-auth/examples/wrapped.go:30: main redeclared in this block
    previous declaration at src/github.com/abbot/go-http-auth/examples/digest.go:29

If you work differently, you can work around this. But I don't see any reason why not change the structure of the example directory to be compliant with more use cases.

@abbot
Copy link
Owner

abbot commented Jun 2, 2013

Can you provide a minimal set of commands to reproduce the problem?

@arikfr
Copy link
Author

arikfr commented Jun 3, 2013

If you have GOPATH configured, either go build all or go build ./src/... should trigger the problem.

abbot added a commit that referenced this pull request Dec 3, 2013
@abbot
Copy link
Owner

abbot commented Dec 3, 2013

I excluded examples from default build, please reopen the issue if this does not work for you.

@abbot abbot closed this Dec 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants