Git Product home page Git Product logo

Comments (12)

vaind avatar vaind commented on May 20, 2024

Hmm, just checked on a blank golang:1.13.3 docker image and it worked for me :/

I see you're using the manual installation for a project without go modules, i.e. you're installing objectbox-go globally into your $GOPATH. Is that what you intended? If so, have you had objectbox-go installed before so maybe there's some conflict with an old version?

Maybe you could try removing the installed version like in the script below. This assumes a global installation, i.e. when you're not using go-modules.

rm -r $GOPATH/src/github.com/objectbox/objectbox-go

If you're using go modules, you should just import the package using import "github.com/objectbox/objectbox-go/objectbox". You still need to install the objectbox-c binary library for the program to work.

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

Ok, thanks. Switched to using go-modules.

Here is what I see now:

go build ./src/services/calculation/
cannot find module for path github.com/objectbox/objectbox-go/internal/generator

cat go.mod
module bitbucket.org/rerosum/algotrader

go 1.13

require (
github.com/boltdb/bolt v1.3.1
github.com/gorilla/mux v1.7.3
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
github.com/magefile/mage v1.9.0
github.com/nats-io/nats.go v1.9.1
github.com/objectbox/objectbox-go v1.0.0
github.com/pkg/errors v0.8.1
)

ls -la /mnt/c/DEV/projects/go/src/github.com/objectbox/
total 0
drwxrwxrwx 1 bob bob 512 Dec 13 08:43 .
drwxrwxrwx 1 bob bob 512 Dec 12 13:14 ..
drwxrwxrwx 1 bob bob 512 Dec 12 17:06 download
drwxrwxrwx 1 bob bob 512 Dec 12 17:06 lib

from objectbox-go.

vaind avatar vaind commented on May 20, 2024

cannot find module for path github.com/objectbox/objectbox-go/internal/generator

Are you, by any chance, importing .../internal/generator directly, it's something used by the generator command-line application and not intended to be used by the library users. That's why it's in internal and go prevents a direct import.

Also, I don't understand how your /mnt/c/DEV/projects/go/src/github.com/objectbox/ ended up looking how it does. Maybe you have executed the download.sh when inside that directory? Because it looks like the temporary dir created by the download.sh/install.sh, not like go package source (this repository). Removing /mnt/c/DEV/projects/go/src/github.com/objectbox/ would be probably a good idea - Go is probably picking it up as a module installed globally but the directory's content isn't correct.

I hope that helps

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

Ok, further cleanup of my GOPATH:

go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bob/.cache/go-build"
GOENV="/home/bob/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/bob/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/home/bob/go/src/bitbucket.org/rerosum/algotrader/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build223621530=/tmp/go-build -gno-record-gcc-switches"

Failing on:

~/go/src/bitbucket.org/rerosum/algotrader$ go build ./src/data
../../../../pkg/mod/github.com/objectbox/[email protected]/objectbox/model.go:30:2: cannot find package

where ./src/data has:

import (
"github.com/objectbox/objectbox-go/objectbox"
)

line 30 of model.go:

import "github.com/objectbox/objectbox-go/internal/generator"

we have this directory on the source path:

ls -la ../../../../pkg/mod/github.com/objectbox/[email protected]/internal/generator/
total 80
dr-xr-xr-x 4 bob bob 4096 Dec 13 11:55 .
dr-xr-xr-x 3 bob bob 4096 Dec 13 11:55 ..
-r--r--r-- 1 bob bob 3796 Dec 13 11:55 ast.go
-r--r--r-- 1 bob bob 2511 Dec 13 11:55 binding-property.go
-r--r--r-- 1 bob bob 28326 Dec 13 11:55 binding.go
-r--r--r-- 1 bob bob 3761 Dec 13 11:55 fields.go
-r--r--r-- 1 bob bob 6897 Dec 13 11:55 generator.go
-r--r--r-- 1 bob bob 8460 Dec 13 11:55 merge.go
dr-xr-xr-x 2 bob bob 4096 Dec 13 11:55 modelinfo
-r--r--r-- 1 bob bob 751 Dec 13 11:55 options.go
dr-xr-xr-x 2 bob bob 4096 Dec 13 11:55 templates

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

Same issue when running the install script from the project root:

:~/go/src/bitbucket.org/rerosum/algotrader$ bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-go/master/install.sh)
Base config: OS Linux and arch x86_64
Using configuration Linux::x86_64
Downloading ObjectBox library version 0.6.0 testing (4db1be536558d833e52e862fd84d64d75c2b3656)...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 394k 100 394k 0 0 284k 0 0:00:01 0:00:01 --:--:-- 755k
Downloaded:
396K download/testing/libobjectbox-0.6.0-4db1be536558d833e52e862fd84d64d75c2b3656.tgz

Extracting into download/testing/libobjectbox-0.6.0-4db1be536558d833e52e862fd84d64d75c2b3656...
Copied to /home/bob/go/src/bitbucket.org/rerosum/algotrader/objectboxlib/lib:
total 1036
-rwxr-xr-x 1 bob bob 1057848 Dec 13 12:48 libobjectbox.so
OK. Do you want to install the library into /usr/lib? [Y/n] y
Installing /usr/lib/libobjectbox.so
[sudo] password for bob:
Installed objectbox libraries:
libobjectbox.so (libc6,x86-64) => /usr/lib/libobjectbox.so
/home/bob/go/src/bitbucket.org/rerosum/algotrader
../../../../pkg/mod/github.com/objectbox/[email protected]/objectbox/model.go:30:2: cannot find package

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

from go help gopath:

Internal Directories

Code in or below a directory named "internal" is importable only
by code in the directory tree rooted at the parent of "internal"

the model.go file is rooted in:
github.com/objectbox/[email protected]/objectbox/model.go

but the generator package is rooted in:

github.com/objectbox/objectbox-go/internal/generator

So if I read the help file correctly, model cannot import generator, hence the error message.

Am I correct?

from objectbox-go.

vaind avatar vaind commented on May 20, 2024

I can't see anything wrong with your go env 👍

/home/bob/go/src/bitbucket.org/rerosum/algotrader

With go modules, your project should not be in the $GOPATH, IIRC I've had problems with such projects before. Not sure if it's the cause here, but could you try moving your project out of GOPATH, i.e. out of /home/bob/go, at least temporarily. Maybe also try searching for all directories named objectbox to make sure there are no stray ones, like find ~ -type d -name objectbox

I can't imagine how the internal could be the culprit, in that case, the code wouldn't work for anyone, ever, not even in the library itself.

Code in or below a directory named "internal" is importable only by code in the directory tree rooted at the parent of "internal"

"The parent of "internal"" => github.com/objectbox/objectbox-go
"the directory tree rooted" => anything below objectbox-go, i.e. also objectbox-go/objectbox/model.go

Just an idea: if you're using "objectbox" as a package (directory) name inside your project, it might be messing with go package resolution as well (seen it in the past).


If nothing else helps, maybe trying to narrow down the scope would help to find the problem, e.g. by trying to include objectbox in a minimal example project you could share. If that still doesn't work for you, and the example works in a docker image, then we at least know it's somehow related to the environment.

from objectbox-go.

vaind avatar vaind commented on May 20, 2024

Also, there was an issue #16 - giving the same error message - turned out to be due to cross-compilation. You aren't trying to do that, are you?

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

Firstly, thank you for helping me work through my issue. I'm sure the problem is on my side, so I took your advice and started from a clean test project located outside of the GOPATH. Here is what I see when running the installer:

bob@TRADE-SERVER:~/DEV/testObjectBox$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bob/.cache/go-build"
GOENV="/home/bob/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/bob/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build427124736=/tmp/go-build -gno-record-gcc-switches"
bob@TRADE-SERVER:~/DEV/testObjectBox$ bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-go/master/install.sh)
Base config: OS Linux and arch x86_64
Using configuration Linux::x86_64
Downloading ObjectBox library version 0.8.1 testing (4db1be536558d833e52e862fd84d64d75c2b3656)...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  428k  100  428k    0     0   596k      0 --:--:-- --:--:-- --:--:--  596k
Downloaded:
432K    download/testing/libobjectbox-0.8.1-4db1be536558d833e52e862fd84d64d75c2b3656.tgz

Extracting into download/testing/libobjectbox-0.8.1-4db1be536558d833e52e862fd84d64d75c2b3656...
Copied to /home/bob/DEV/testObjectBox/objectboxlib/lib:
total 1128
-rwxr-xr-x 1 bob bob 1153296 Dec 16 12:21 libobjectbox.so
OK. Do you want to install the library into /usr/lib? [Y/n] y
Installing /usr/lib/libobjectbox.so
Installed objectbox libraries:
        libobjectbox.so (libc6,x86-64) => /usr/lib/libobjectbox.so
/home/bob/DEV/testObjectBox
Your project doesn't seem to be using go modules. Installing FlatBuffers & ObjectBox using go get.
# github.com/objectbox/objectbox-go/objectbox
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:26:14: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:42:17: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:46:48: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:91:52: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:166:27: undefined: TypeId
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:170:25: undefined: TypeId
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:184:17: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/condition.go:188:40: undefined: QueryBuilder
../../go/src/github.com/objectbox/objectbox-go/objectbox/entity.go:21:5: undefined: TypeId
bob@TRADE-SERVER:~/DEV/testObjectBox$ find ~ -type d -name objectbox
/home/bob/go/src/github.com/objectbox
/home/bob/go/src/github.com/objectbox/objectbox-go/objectbox
/home/bob/go/pkg/mod/cache/download/github.com/objectbox
/home/bob/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/objectbox
/home/bob/go/pkg/mod/github.com/objectbox
/home/bob/go/pkg/mod/github.com/objectbox/[email protected]/objectbox
/home/bob/go/pkg/mod/github.com/objectbox/[email protected]/objectbox

I have to say I'm baffled why my environment is behaving differently than yours.

I'll try any ideas you might have, thank you.

from objectbox-go.

rerosum avatar rerosum commented on May 20, 2024

Looks like I figured it out. Here is what was wrong with my environment:

I didn't have gcc installed and w/o it I was missing the *.h files typically found in the ../include system folder and which are needed for the imports of objectbox.h. This prevented querybuilder.go from compiling which is needed by condition.go.

I'm all set for now, thanks for all the help!

from objectbox-go.

vaind avatar vaind commented on May 20, 2024

I'm glad to hear that you've figured it out. It's a pity the error is so cryptic/unrelated to the actual cause :/ I'll update the docs with the findings. Thanks for the feedback.

from objectbox-go.

greenrobot avatar greenrobot commented on May 20, 2024

I didn't have gcc installed

@vaind can our setup script check for that and give advice how to install it?

from objectbox-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.