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

golang project: can't find import #275

Closed
NuSkooler opened this issue Dec 5, 2018 · 5 comments
Closed

golang project: can't find import #275

NuSkooler opened this issue Dec 5, 2018 · 5 comments

Comments

@NuSkooler
Copy link

I'm attempting to use xmake v2.2.3.201811282159 with go version go1.11.2 windows/amd64. I created a project as such:

xmake create -n myproj -l go

xmake can now build the project. However, when I import a package in my main.go, xmake fails:

[  0%]: compiling.release src\main.go
error: src\main.go:8:2: can't find import: "github.com/docopt/docopt-go"

The docopt-go is in my $GOPATH. From go env:

set GOPATH=C:\Users\nusko\go

And c:\Users\nusko\go\pkg\windows_amd64\github.com\docopt\docopt-go.a (from using go get...)

Now, if I cd to src and go build, it compiles just fine. It's go tool compile ... that xmake runs that fails.

Any ideas?

@waruqi
Copy link
Member

waruqi commented Dec 5, 2018

Sorry, importing external libraries is not currently supported and we can only compile some codes that uses the built-in library.

At present, the focus of xmake is to improve the compilation of c/c++.

I will support it in the future, but currently I suggest you still use go build directly.

@waruqi waruqi added this to the todo milestone Dec 5, 2018
@NuSkooler
Copy link
Author

@waruqi Fair enough, thanks for the quick response!

@judah-caruso
Copy link

Is this still the case for external go dependencies?

@waruqi
Copy link
Member

waruqi commented Apr 10, 2019

Is this still the case for external go dependencies?

Yes

@xmake-io xmake-io deleted a comment from eretvekasap Apr 21, 2019
@waruqi
Copy link
Member

waruqi commented Jul 25, 2020

I have initially supported the installation and integration of third-party go dependency packages, but it is not very perfect (the specified version is not currently supported and cascading dependencies require manual configuration)

Because currently I use go get to download the dependency package, it does not support the specified version. Although the new go11 module can support downloading the specified version, it does not provide a compiled binary library (only source code). So I don’t know how to compile them to get the corresponding library files.

for example: https://github.com/xmake-io/xmake/blob/dev/tests/projects/go/console_with_pkgs/xmake.lua

add_rules("mode.debug", "mode.release")

add_requires("go::github.com/sirupsen/logrus", {alias = "logrus"})
add_requires("go::golang.org/x/sys/internal/unsafeheader", {alias = "unsafeheader"})
if is_plat("windows") then
    add_requires("go::golang.org/x/sys/windows", {alias = "syshost"})
else
    add_requires("go::golang.org/x/sys/unix", {alias = "syshost"})
end

target("test")
    set_kind("binary")
    add_files("src/*.go")
    add_packages("logrus", "syshost", "unsafeheader")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants