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

Allow to set build tags #6

Merged
merged 1 commit into from
Aug 14, 2015
Merged

Conversation

zimmski
Copy link
Contributor

@zimmski zimmski commented Aug 14, 2015

I now that this breaks the API but the usage is wrong without it if you support build tags in a tool, like in errcheck. I will send out a PR for this in a moment.

@dominikh
Copy link
Collaborator

In my opinion, changing the signature isn't really an option, especially because the new API doesn't look sane, having to carry tags through various functions, singling out a single of the buildContext fields.

The real issue is that the user cannot modify the build context. One option would be to allow access to the global build context, but that wouldn't be thread-safe. Another option might be to provide a new type (type Context struct or something like that), which has an ImportPaths(args []string) method and a BuildContext field.

It should be noted that this code is lifted directly from the Go tool. buildContext was an oversight. The Go tool itself does set tags by manipulating the global buildContext, which won't work for us.

@zimmski
Copy link
Contributor Author

zimmski commented Aug 14, 2015

That would mean that most functions will be turned into methods of the new Context type. Also the old ImportPaths would then instantiate a Context. Is that OK?

@dominikh
Copy link
Collaborator

That sounds fine to me, but let's wait for @kisielk

@kisielk
Copy link
Owner

kisielk commented Aug 14, 2015

Okay, I had some time to look in to how the go tool works with regards to the build context. I agree we should just provide our own Context type that embeds build.Context and has an ImportPaths method. Then the package can instantiate the default in to a global DefaultContext.

@zimmski
Copy link
Contributor Author

zimmski commented Aug 14, 2015

Sounds good. So it is also fine with you to convert the currently touched functions into methods?
On Aug 14, 2015 6:20 PM, Kamil Kisiel notifications@github.com wrote:Okay, I had some time to look in to how the go tool works with regards to the build context. I agree we should just provide our own Context type that embeds build.Context and has an ImportPaths method. Then the package can instantiate the default in to a global DefaultContext.

—Reply to this email directly or view it on GitHub.

@kisielk
Copy link
Owner

kisielk commented Aug 14, 2015

Yeah, the unexported functions can be made in to the methods on the new type. The exported ImportPaths function can just call DefaultContext.ImportPaths

@zimmski
Copy link
Contributor Author

zimmski commented Aug 14, 2015

Done, please take another look.

@kisielk
Copy link
Owner

kisielk commented Aug 14, 2015

Looks good. Next step is to use gotool.Context in errcheck I guess.

kisielk added a commit that referenced this pull request Aug 14, 2015
@kisielk kisielk merged commit 14d7ad1 into kisielk:master Aug 14, 2015
@zimmski zimmski deleted the allow-to-set-build-tags branch August 15, 2015 15:35
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.

3 participants