Closed randallmlough closed 4 years ago
It's because of this code if I'm not mistaken
func getGoImportFromFile(dir string) string {
longPath, err := filepath.Abs(dir)
if err != nil {
fmt.Println("error while trying to convert folder to gopath", err)
}
// src/Users/.../go/src/gitlab.com/.../app/backend/graphql_models
return strings.TrimPrefix(pathRegex.FindString(longPath), "src/")
}
https://github.com/web-ridge/gqlgen-sqlboiler/blob/master/convert.go#L151
I need import in golang
backend := gbgen.Config{
Directory: "models",
PackageName: "models",
}
From "models" -> to import path in file e.g "github.com/web-ridge/some-app/models"
We probably need this approach https://stackoverflow.com/questions/18537257/how-to-get-the-directory-of-the-currently-running-file
I think it's hard to detect import path if it's not in GOPATH we may need to let user explicitly set it via config.
Thanks you for this amazing PR!
Piggy backing off my issue on your examples: https://github.com/web-ridge/gqlgen-sqlboiler-examples/issues/2
and this issue: https://github.com/web-ridge/gqlgen-sqlboiler/issues/3
Is this library able to work outside of the GOPATH while using modules?
I created a simple example that attempts to use postgres. Unfortunately, I haven't been able to get it to work at all. It panics everytime I go
go run convert_plugin.go
Would love some insight here.
Example prpoject: https://github.com/randallmlough/gql-boil-psql