-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Rename examples folder so it's not counted as a source file #596
Rename examples folder so it's not counted as a source file #596
Conversation
Otherwise, it breaks the build: ```text vendor/github.com/Sirupsen/logrus/examples/hook/hook.go:12: cannot use airbrake.NewHook(123, "xyz", "development") (type *airbrake.airbrakeHook) as type "github.com/rafecolton/docker-builder/vendor/github.com/Sirupsen/logrus".Hook in argument to log.Hooks.Add: *airbrake.airbrakeHook does not implement "github.com/rafecolton/docker-builder/vendor/github.com/Sirupsen/logrus".Hook (wrong type for Fire method) have Fire(*"github.com/sirupsen/logrus".Entry) error want Fire(*"github.com/rafecolton/docker-builder/vendor/github.com/Sirupsen/logrus".Entry) error ```
You're trying to fix the wrong issue. Then, both packages will properly be detected as having the same signature and your build will be passing. |
@dmathieu the problem is actually that the airbrake library isn't vendored. So it's looking for the non-vendored logrus package ( If I add the airbrake library to my # search for uses of capital 'S'
> ag -l --go --case-sensitive 'Sirupsen' vendor/ | wc -l
34
# search for uses of lower case 's'
> ag -l --go --case-sensitive 'Sirupsen' vendor/ | wc -l
0 (NOTE: Search uses To fix the import reference in my code base would be impractical, as every vendored library I use also uses the uppercase import. My options are as follows:
Given the options, I definitely choose option 2. I see no reason to vendor code that's only used for example purposes, and to modify it in the |
Rafe, The change to lowercase the import statement and use Go will fetch dependencies whether they are from vendor or not automatically, as in they have the same signature, as long as their path is the same. In your care, they aren't because of the capital S. In your error:
See the lowercase s?
And now the upper-case. This is where the difference is. |
@dmathieu I agree that ideally, myself and all vendors I use would switch to the lowercase version. In order for me to use the lower case I updated my dependencies to ensure that I'm using the latest version in case all of them have already made the update. Looking through my vendor library, the following packages (excluding ones I own) correctly use the lowercase version:
...and the following use the uppercase version:
I found moby/moby#33998 for docker to make the update. Once that PR is merged, I can update my libraries and that will fix the case insensitive issue. That all being said, this PR is still valid. The files in |
I don't think we should rename this folder. Furthermore, this does add the examples into your vendor folder. But those will never be loaded. So the only thing is uses is disk space. And if you need the few kilobytes used by those text files, you have other issues 😆 |
But they are loaded: https://golang.org/pkg/go/build/#Context.Import |
In your Hugo example, there are no |
Do you have benchmarks showing performance difference between the two folders names? |
When named without the underscores, the > cd $GOPATH/src/github.com/sirupsen/logrus
> go list ./...
github.com/sirupsen/logrus
github.com/sirupsen/logrus/examples/basic
github.com/sirupsen/logrus/examples/hook
github.com/sirupsen/logrus/hooks/syslog
github.com/sirupsen/logrus/hooks/test Being available packages also means that any dependencies specified in those files (i.e. |
Yes, but then again, is there any actual performance impact? |
Yes, running |
I agree with @dmathieu that if this solves @rafecolton's issue (hey Rafe, long time no see), it's a secondary effect—not a primary. I'm OK with renaming the |
An alternate solution RE not importing Airbrake (hi Simon!) would be to convert the examples into testable examples. Then, the dependencies wouldn't get pulled in with |
That would seem like a very good solution to me. Being able to point everything at godoc is always nicer. |
Agree, testable examples would be great. |
I'm 100% 👍 for making the examples testable, too. One thing I'd like to ask is whether we actually need the extra example with a hook other than syslog (which is included in this repo)? There is a syslog example in the package's README which should be sufficient. |
#616 replaces the example files with testable examples |
Otherwise, it breaks the build: