Description
🚨 First, please check:
- existing issues (including closed ones),
- Docs https://golang.objectbox.io/
- FAQ page https://golang.objectbox.io/faq
Description
When I add the code from the getting started guide into a main.go file and run "go run main.go", I receive the following error:
package command-line-arguments main.go:5:2: use of internal package github.com/objectbox/objectbox-go/examples/tasks/internal/model not allowed
Basic info
Please complete the following information:
-
ObjectBox version (are you using the latest version?): [e.g. v1.1.2]
not sure how to tell,, I ran the install script, it is the version installed from there -
GO version:
go version go1.15.3 darwin/amd64 -
Reproducibility: [e.g. occurred once only | occasionally without visible pattern | always]
always -
Device: [e.g. Desktop]
Desktop -
OS: [e.g. Ubuntu 20.04]
MacOS
How to reproduce
Steps to reproduce the behavior:
- Enter code from user guide in files specified
- Run go generate
- Run go run
- Receive eror
Expected behavior
This should run the sample program documented
Code
`package main
import (
"fmt"
"github.com/objectbox/objectbox-go/examples/tasks/internal/model"
"github.com/objectbox/objectbox-go/objectbox"
)
func initObjectBox() *objectbox.ObjectBox {
objectBox, _ := objectbox.NewBuilder().Model(model.ObjectBoxModel()).Build()
return objectBox
}
func main() {
// load objectbox
ob := initObjectBox()
defer ob.Close() // In a server app, you would just keep ob and close on shutdown
box := model.BoxForTask(ob)
// Create
id, _ := box.Put(&model.Task{
Text: "Buy milk",
})
task, _ := box.Get(id) // Read
task.Text += " & some bread"
fmt.Printf("My Test Record:\n")
fmt.Printf("%+v", task)
fmt.Printf("\n\n")
box.Put(task) // Update
count, _ := box.Count()
fmt.Printf("After the add, there are %d tasks in the list\n", count)
box.Remove(task) // Delete
count, _ = box.Count()
fmt.Printf("After the remove, there are %d tasks in the list\n", count)
}`