-
Notifications
You must be signed in to change notification settings - Fork 279
xgo does only work with the go import path #1
Comments
Yes, you're right. I haven't had personally the need for this, hence why I didn't add it. Although it shouldn't be too hard, it's not trivial either as you'll need a mechanism to upload code into the container. Simply specifying a path and expecting xgo to figure out if it's a local private path or a remote public on isn't really doable, but I guess I could introduce an extra flag to signal a path to import into the container before compilation. So in the end, compiling your code could look something like:
where the two could obviously be the same. [Ok, I could implement a mechanism to pick the local version of some package and only go remote if not available locally, but that's a tad overkill and will quickly introduce quirks, bugs and whatnot that the current always-remote-clone cannot have since it always uses virgin states). Anyway, I'll think about this a bit and get back to the issue. In the mean time, if you have a particular idea on how you think this would be useful, or how you imagine it doable, do share :) |
Unfortunately I do not know how Docker works so I have (currently) no idea on how to implement this. But I do understand that the docker approach is more superior in terms of user-friendliness. Since the only steps for a complete cross-compile setup are just installing Docker, your Docker images and xgo. Giving my experience on doing cross-compile setups manually I find xgo's simplicity amazing!
I am eager to help implementing (in two weeks i will have more time since i am relocating 👍 ) but as mentioned I currently do not possess the necessary Docker knowledge. |
Most of these seem reasonable requests so I'll just turn your wish list into a checklist to be able and check them off one by one eventually :) I myself will also be unavailable until the end of next week, so I guess most of these will have to wait till then, but I'll see if I have enough time to address one or two. Docker is really cool but it has quite some quirks, so you do have to jump through some hoops to get everything going (e.g. you can't stream the stdout of docker through your own program (hence why I needed the extra docker pull step for my container). |
Blah... ok, I have the whole thing working for different Go releases, just can't convince docker to automatically build them with the correct dependencies. Their build service is very very limited. I'll try and look around to see if I can do it properly without needing to go down their suggested path (separate repo for every single dockerfile). |
Ok, after a long battle with docker, versioned containers work :) Although for now only Go 1.3.0 is supported, adding additional ones are trivial and I also introduced two wildcard versions: "1.3.x" matching the latest point release and "latest" matching the latest major release of Go. These can be configured via the
|
Just in time for 1.3.1 :-) |
Added support for output prefixing through |
Btw, I've talked to Dave Cheney about his arm packages for 1.3.1, and he said that maybe during the weekend he'll do it, so I'll be able to support the next Go release too afterwards. |
@zimmski I made a fork and implemented what you were requesting. It doesn't build single files, but it builds local packages (a local package can just contain main.go, in your case). Get it here: https://github.com/kdar/xgo/tree/localpkg If looks for a "." or "/" at the beginning of the path to determine if it's a local package. So you can do xgo ./ or something similar. Example:
This works with karalabe's dockerfiles. The only downside is it will error when copying files because the directories overlap (but it works fine regardless of the error displayed). This can be remedied if we modify the Dockerfiles as well to support this. |
I am sorry to tell you guys that I switched to https://github.com/mitchellh/gox for new projects some time ago. But @kdar I will definitely will try your changes with the next cgo-dependent project! |
@kdar This is excellent, thank you! Your example instructions are missing a
|
Had been doing some work lately requiring xgo, so I've added a lot of new features, including building local code. If instead of the import path you specify a local path (begins in either The idea is based on @kdar's code, so I thank him for that, though it needed a bit of rework to enable read only filesystems and multiple GOPATH components. Hope it's useful :) |
@karalabe do you have some examples to show me? im using 1.11.2 |
Completes the addition of go module support, including vendored builds
I do not see a way to give xgo just a file to compile. e.g.
The text was updated successfully, but these errors were encountered: