-
Notifications
You must be signed in to change notification settings - Fork 45
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
Following GETTING STARTED guide does not work #28
Comments
I guess the code block in this section is the culprit, right?. We should think about how to change the imports in the docs so that it's clear user needs to actually change them to their module path... |
I am not sure if this is a documentation only issue or not. I was able to work around the issue by using direct paths, but this is considered extremely bad form. The code we need to include should be generated into a vendor folder and documentation should be adjusted to identify the proper path from there, and vendoring needs to be turned on during installation, creating a go dependency issue. This is probably not simply a documentation issue if done correctly due to changes in the language. |
That's exactly the misunderstanding I think needs addressing in the docs. You don't need to include any code from "github.com/objectbox/objectbox-go/examples/tasks/internal/model" - the whole "example/tasks" folder is an example of a self-contained application. You can copy-paste it, initialize it as your own go module (picking your own name, for example, |
Just to throw in my 2 cents on this..
Running that command, then informed me of the commands I need to run to get objectbox-go working:
After installing those packages
worked, and I was able to work with the package. I'm new to golang, and it took me a few hours of messing around, to finally give the go test command a try, as I assumed I could just jump straight in. |
🚨 First, please check:
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:
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)
}`
The text was updated successfully, but these errors were encountered: