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

Calling methods results undefined ( .\main.go:36:28: undefined: faunadb.CreateCollection ) #90

Closed
hasante opened this issue Apr 6, 2020 · 12 comments

Comments

@hasante
Copy link
Contributor

hasante commented Apr 6, 2020

auth::go run main.go

command-line-arguments

.\main.go:36:28: undefined: faunadb.CreateCollection
.\main.go:45:15: undefined: faunadb.Collection
.\main.go:58:15: undefined: faunadb.Collection
.\main.go:70:4: undefined: faunadb.Collection
.\main.go:87:6: undefined: faunadb.Collection
.\main.go:97:45: undefined: faunadb.RefCollection
.\main.go:97:61: undefined: faunadb.Collection

When I isolate the file, it successfully works without giving me any errors, but when I add it to a project, it results in an error. This is just a small section of the problem. I found mostt others when I was using it resulted in some weird errors.

I have tried my best, but I just can't seem to solve it, please help me.

@hasante
Copy link
Contributor Author

hasante commented Apr 6, 2020

Found an odd behaviour, when there is the go.mod modules file, it doesn't work, but works when taken out.

@hasante
Copy link
Contributor Author

hasante commented Apr 6, 2020

Also this is my go.mod file:

module github.com/Henry-Asante/auth_service

go 1.13

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fauna/faunadb-go v2.0.0+incompatible
github.com/gorilla/mux v1.7.4
github.com/stretchr/testify v1.5.1 // indirect
github.com/subosito/gotenv v1.2.0
golang.org/x/crypto v0.0.0-20200403201458-baeed622b8d8
)

@hasante
Copy link
Contributor Author

hasante commented Apr 7, 2020

Was able to work when I used Go dep for my package management

@mbraeutig
Copy link

Get the same issue,
when i working with the tutorial
https://docs.fauna.com/fauna/current/tutorials/crud

undefined: faunadb.CreateCollection

My go.mod (snippet)
require github.com/fauna/faunadb-go v2.0.0+incompatible

What must i do ?

@hasante
Copy link
Contributor Author

hasante commented Apr 10, 2020

@mbraeutig

You need to change your dependency management to go dep: Tutorial I used

The idea that worked for me, was to change my project directory to my $GOPATH, I used during installation.

Then from there, I run go get .../dep, and run dep init to initiate a new project.

Then you can add modules by running the command

dep ensure --add github.com/fauna/faunadb-go( Find the correct path from docs)

This solved all my dependency issues and a lot of red flags I had when developing outside my $GOPATH, and using GO MOD.

Hope this works for you, all the best!!

@mbraeutig
Copy link

@Henry-Asante

Yeah thanks a lot.

I have found another solution.
Clonning
https://github.com/fauna/faunadb-go.git
direct into the $GOPATH

Now i am working with the good old GOPATH :-)

Then i have some others problems:
https://github.com/mbraeutig/faunadb-tutorial
The tutorial is not working :-(
https://docs.fauna.com/fauna/current/tutorials/crud

@hasante
Copy link
Contributor Author

hasante commented Apr 10, 2020

@mbraeutig You should move to go dep to stop all this. I was informed by the FauanDB team that using Go mod as dependency management produces some errors.

Also after moving to Go dep for dependency management. I now understand how my folder is structure and how everything makes a lot more sense coming from a Node.js background.

image

@mbraeutig
Copy link

mbraeutig commented Apr 10, 2020

@Henry-Asante

Can you please try my repro.
https://github.com/mbraeutig/faunadb-tutorial
It is very simple olny one main.go.
Does it works with your set up ?

Thanks

@hasante
Copy link
Contributor Author

hasante commented Apr 10, 2020

@mbraeutig , It worked on my setup

@mbraeutig
Copy link

@Henry-Asante

Yeah, thanks a lot :-)

with my setup, i have no problems with compile,
but i have problem at the runtime.

For example, creatingCollection:
2020/04/10 12:37:54 Response error 400. Errors: [create_collection](invalid object in container): Object is not allowed
in a container

So, i must think off to switch to dep.

Thanks

@hasante
Copy link
Contributor Author

hasante commented Apr 10, 2020

Yes @mbraeutig , try that to stop all the problems which will probably come after fixing this.

All the best

@ldez
Copy link

ldez commented Oct 2, 2020

Fixed by #112

@n400 n400 closed this as completed Mar 10, 2021
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

4 participants