This might have a negative effect on binaries which like to “vendor” dependencies and re-write dependency import paths, but perhaps this was always a terrible idea and they should be using the alternative approach of building a temporary GOPATH workspace with pinned dependencies.
--
---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I would be reluctant to add new mechanisms to solve problems I'm not seeing.
I think the magic line in README is probably the wrong approach.Presuming we go with the json meta file, what about third parties putting stuff in there? Is that sanctioned? Forbidden? Are we apathetic to it?
I've spent a while thinking about this, including the responses both on and off list, and I think this is something we need to fix for Go 1.3. Aliasing is one of those "programming in the large" issues that Go explicitly tries to tackle: a package needs to have just one import path, not two.
I have seen the described behavior creating issues before, mainly due
to self-imports: let's say rsc.io/pdf imports rsc.io/pdf/fonts, and
then a user imports that under github.com/rsc/pdf. The contained
import will bring the intended path in as well, effectively importing
the same package twice under different paths.
I would be reluctant to add new mechanisms to solve problems I'm not seeing.
On Tue, Feb 25, 2014 at 4:56 PM, Russ Cox <r...@golang.org> wrote:
> I have been playing with 'vanity' import paths and cmd/go.
Technical note (not advocating anything): The symptom is rooted in the
magic redirection capability. One way to get rid of the problem is to
not provide the magic. I don't have statistic data about how often it
is used in the wild, but I have never seen it in any Go package I, or
my employer, have ever used - all of them are directly in
code.google.com or github.com, AFAIR.
any one file.
if there are more than one, with different import path, by definition, the check won't pass. then it's just a matter of better diagnostics.
go get needs to read every go source file, so that's not a problem.
we don't need to require the import line to be present in every file, just one will do. (in fact, i propose we just define go will check every line like that and if they don't all match, go get will always fail)
the problem i can think of is that every fork needs to change the import line, but i expect for non-trivial projects, people will need to change actual import lines anyway. however, as the check only happens at go get time, the usual git fetch/branch trick with already go get packages will still work.
--
--
---
You received this message because you are subscribed to a topic in the Google Groups "golang-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-dev/RgHGBXROeAw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-dev+...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
On Feb 28, 2014 3:31 PM, "Andrew Gerrand" <a...@google.com> wrote:
> By backward compatible do you mean that it would work with Go 1.2? Because I don't see how that is the case. Shouldn't the compiler complain of an unexpected string literal?
yeah, that's a problem.
and it's the reason why i proposed the "// +import" line rather than changing the language.
i don't think this problem is big enough to change the language.
On Fri, Feb 28, 2014 at 3:49 PM, Rob Pike <r...@golang.org> wrote:
It's compatible in the sense that a[i:j:k] was: only software that
uses the feature (or depends on etc.) is affected. No existing code
breaks.Yes, but I'd argue that this problem is different from a[i:j:k] fundamentally.a[i:j:k] is impossible to do in Go 1.1 and earlier without unsafe, so usingit means deliberately breaking Go 1.1 and previous users (just like usingany newer APIs).However, locking the vanity import path alone shouldn't render an otherwiseGo 1.2 clean package to be Go 1.3 only. I expect some users might notstart upgrading to Go 1.3 shortly after it is released, and any uses of vanityimport locked package will break their compilation, which is unfortunate.The workaround is to add an empty source file like this:// +build go1.3package pdf "rsc.io/pdf"
to a package. I'd argue it's not better than doing this:
// +import "rsc.io/pdf"package pdfThe compiler is already accepting commands in comments, so that'snot a problem too, if we want to check the import path at every buildeven without the go command (this might pose problems for users ofcustom build, though).
package foo "github.com/gopherdelight/foo"
package foo "github.com/gopherdelight/foo"This is very nice.
Build tags may skip compilation of a single file, whereas this halts compilation of a package. I think it makes sense to use something different.+ It's only verifying the path on disk rather than hitting the network as in the original proposal.
+ No chance of becoming a metadata file for every odd and end.
Would it be available via the ast package for rewriting package imports?
Does this apply to package main in command line tools?
If many packages do have this additional noise, are there any concerns beyond the noise?
Possible uses:* Ensure vanity urls are used to handle future package moves, package pdf "rsc.io/pdf".* Moved repositories, package main "code.google.com/p/go.tools/cmd/goimports" (at GitHub location).* Renamed repositories (essentially the same, GitHub will redirect but "go get" puts code in the requested folder, this could prevent that). Example: go get github.com/gophertown/gat will get the code for looper (new name).* Gary Burd has been looking for ways to remove temporary forks from search results on godoc.org. A canonical import path would help.
* It encourages cloning to the canonical location (for example, I've worked under the src/github.com/howeyc/fsnotify folder, not under src/github.com/gophertown/fsnotify based on my fork location). This keeps all my fsnotify import paths the same.Possible issues:* Another thing to fix when doing import rewriting for forks/vendor.
* No manual clone workaround if it's a compile-time check. (is that bad?)
* Unlike the original post, "go get github.com/bradfitz/pdf" won't work unless the canonical import path is changed in the fork. Instead one would "go get rsc.io/pdf" and then add an additional remote for bradfitz's fork to pull in his code. (I think this is a good thing, but it requires familiarity with adding remotes).
* Not able to compile under Go 1.2 or less. (without a +build go1.3 tag as per minux)
As such, I suggest pursuing the least impactful change possible, if anything is done at all.
Adding any kind of configuration file is anathema to me. That's one of the things I like best about go - no extraneous files, just code.
On Sat, Mar 1, 2014 at 1:41 AM, Nathan Youngman <n...@nathany.com> wrote:
package foo "github.com/gopherdelight/foo"
What's your opinion about the "// +import " proposal? I don't think it's any worsethan that and it maintains backward compatibility.
Build tags may skip compilation of a single file, whereas this halts compilation of a package. I think it makes sense to use something different.
In a couple of years I'd rather use a formal annotation specification that is part of the formal spec. Maybe that just means adding "// +..." To the spec. But it looks like there is a general need to add annotations to packages, files, and functions. If we break compatibility then let's design a complete formally parsed solution then just an ad-hoc change.
import "packagename" "version"
would seem more valuable IMHO than handling vanity imports.
Just my two cents,
Tom
--
---
You received this message because you are subscribed to a topic in the Google Groups "golang-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-dev/RgHGBXROeAw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
To put it another way, this change would break the go1 compatibility
guidelines. Language changes that are not backwards compatible are not
to be introduced in go1.x
Are we converging on something here?
On Mar 5, 2014 9:02 AM, "Gustavo Niemeyer" <gus...@niemeyer.net> wrote:
> Would it be worth at least ignoring a string used after the package
> name, so if the feature is introduced in 1.4 it won't break people
> using 1.3?
i don't think we've reached concensus to do this at language level.
Just another idea I thought I'd throw into the mix for future
discussion, although I don't expect it to be popular:
Documentation for package declarations are already defined in a single
place per-package. Perhaps if the "Package pkgname ..." convention is
followed, the canonical import path could be defined here as well.
// Package vani.ty/pkgname is an example package.
package pkgname
I like "// +import" because it solves the same problem (reporting information to the go tool) as build tags.On 1 March 2014 08:01, minux <minu...@gmail.com> wrote:On Fri, Feb 28, 2014 at 3:49 PM, Rob Pike <r...@golang.org> wrote:
It's compatible in the sense that a[i:j:k] was: only software that
uses the feature (or depends on etc.) is affected. No existing code
breaks.Yes, but I'd argue that this problem is different from a[i:j:k] fundamentally.a[i:j:k] is impossible to do in Go 1.1 and earlier without unsafe, so usingit means deliberately breaking Go 1.1 and previous users (just like usingany newer APIs).However, locking the vanity import path alone shouldn't render an otherwiseGo 1.2 clean package to be Go 1.3 only. I expect some users might notstart upgrading to Go 1.3 shortly after it is released, and any uses of vanityimport locked package will break their compilation, which is unfortunate.The workaround is to add an empty source file like this:// +build go1.3package pdf "rsc.io/pdf"to a package. I'd argue it's not better than adding this:// +import "rsc.io/pdf"package pdfThe compiler is already accepting commands in comments, so that'snot a problem too, if we want to check the import path at every buildeven without the go command (this might pose problems for users ofcustom build, though).
Just wanted to add, that we already have special file for package documentation. So one can check for the // +import comment there. Using already established standard to make searching for the tag easier.
I'd really love to see a solution which does the exactly opposite of the initial proposal. Rather than allowing a single import path, I'd like to blacklist one. This will prevent users from installing the package directly from GitHub without the downside of breaking forks. We're currently using this at gopkgs.com, but we're doing it via a Go file which panics when the package is imported. See, for example http://gopkgs.com/download/gopkgs.go/magick/gopkgs.go (the file is auto generated). It would be really nice if we could emit an error at build time.