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

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

Closed
sasa-nori opened this issue Oct 9, 2019 · 10 comments

Comments

@sasa-nori
Copy link

Use Go Version

$ go version
go version go1.13.1 darwin/amd64

I did it

$ GOARCH=arm GOOS=linux go build 
build go_api: cannot find module for path github.com/objectbox/objectbox-go/internal/generator

Go env is

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/sasagawanoriyuki/Library/Caches/go-build"
GOENV="/Users/sasagawanoriyuki/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/sasagawanoriyuki/development/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/sasagawanoriyuki/.goenv/versions/1.13.1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/sasagawanoriyuki/.goenv/versions/1.13.1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/sasagawanoriyuki/development/go/src/go_api/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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m5/n0vxl48j0zq8vgbz3v9qqwfh0000gn/T/go-build230359227=/tmp/go-build -gno-record-gcc-switches -fno-common"
@vaind
Copy link
Contributor

vaind commented Oct 9, 2019

You're trying to import github.com/objectbox/objectbox-go/internal/generator which is an internal package. Go tool doesn't allow you to do that. What are you trying to achieve? What code is importing this package?

@sasa-nori
Copy link
Author

I did it

$ GOOS=linux GOARCH=amd64 go build objectbox/shikure.go 
../../../../pkg/mod/github.com/objectbox/[email protected]/objectbox/model.go:30:2: cannot find package

shikure.go is

package objectbox

import (
	"log"
	"net/http"
	"strconv"
	"time"

	"github.com/labstack/echo"
	"github.com/noriyuki-sasagawa/go_api/model"

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

// GetShikureAll シクレ一覧取得
func GetShikureAll(c echo.Context) error {
	// テーブル呼び出し
	box := getBox()

	var list []*model.Shikure
	list, err := box.GetAll()
	if err != nil {
		return err
	}

	return c.JSON(http.StatusOK, list)
}

// AddShikure シクレ追加
func AddShikure(body string, version string) {
	// テーブル呼び出し
	box := getBox()

	const dateLayout = "2006-01-02"
	// データ追加
	time.LoadLocation("Asia/Tokyo")
	versionInt, _ := strconv.Atoi(version)
	id, error := box.Put(&model.Shikure{
		Content: body,
		Hour:    time.Now().Hour(),
		Version: versionInt,
	})
	if error != nil {
		log.Fatalln(error)
		return
	}

	// 追加したデータを取得
	_, error = box.Get(id)
	if error != nil {
		log.Fatalln(error)
	}
}

// RemoveAllShikure シクレ情報全削除
func RemoveAllShikure() {
	// テーブル呼び出し
	box := getBox()
	box.RemoveAll()
}

func getBox() *model.ShikureBox {
	return model.BoxForShikure(initObjectBox())
}

func initObjectBox() *objectbox.ObjectBox {
	objectBox, _ := objectbox.NewBuilder().Model(model.ObjectBoxModel()).Build()
	return objectBox
}

@vaind
Copy link
Contributor

vaind commented Oct 10, 2019

shikure.go is
package objectbox

^ this - your package is most certainly not supposed to be called objectbox but rather something related to your project

@sasa-nori
Copy link
Author

I installed it on Linux instead of Mac and built it.
Probably can't Cross Compile when installed on Mac?

@vaind
Copy link
Contributor

vaind commented Oct 14, 2019

I installed it on Linux instead of Mac and built it.
Probably can't Cross Compile when installed on Mac?

Is this still related to the issue above? We're testing on mac and it works fine. Could you provide more details?

@sasa-nori
Copy link
Author

What I wanted to do was compile for Linux on the Mac.
However, Mac had an error, so it was solved by compiling on Linux.
The problem still remains.

@vaind
Copy link
Contributor

vaind commented Oct 14, 2019

I don't understand how those are related then, sorry.

Is your source publicly accessible? From what I've seen above, you're using an incorrect package name in shikure.go - you're using objectbox. I assume it's the name of the directory where this file is located - so your project looks sth. like: ..../objectbox/shikure.go. If that's right, it's not going to work - this is not related to ObjectBox but rather to how Go packages work. To resolve, you need to rename the directory (and update the package objectbox declaration in its files accordingly) to another name.

@sasa-nori
Copy link
Author

Ah ~
First of all, it can be compiled on Mac and it can be compiled on Linux, so it is not a package issue.

Trying to compile for Linux on a Mac fails.
that's all.

So I thought that if I installed with shell, only Mac libraries would be installed on Mac.

It's a shame that you can't cross compile.

@vaind
Copy link
Contributor

vaind commented Oct 14, 2019

OK so there was a misunderstanding. Cross compilation is not supported yet, we'll have a look what would be necessary to make it work.

vaind added a commit that referenced this issue Nov 1, 2019
New Box C-api interface & reentrant TX

Closes #81, #16, and #82

See merge request objectbox/objectbox-go!46
@vaind
Copy link
Contributor

vaind commented Dec 17, 2019

Closing in favour of #18 for the followup task (cross compilation support)

@vaind vaind closed this as completed Dec 17, 2019
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

No branches or pull requests

2 participants