example icon indicating copy to clipboard operation
example copied to clipboard

make generate works but then causes make server to fail with : "main.go:18:2: import "github.com/GoAdminGroup/example/tables" is a program, not an importable package"

Open joe-getcouragenow opened this issue 5 years ago • 2 comments

The tables folder is a main package.


make generate 
go install github.com/GoAdminGroup/go-admin/adm
go: finding module for package github.com/AlecAivazis/survey/v2
go: downloading github.com/lib/pq v1.3.0
go: finding module for package github.com/jawher/mow.cli
go: finding module for package github.com/tdewolff/minify
go: downloading github.com/go-sql-driver/mysql v1.5.0
go: finding module for package github.com/tdewolff/minify/js
go: finding module for package github.com/tdewolff/minify/css
go: finding module for package github.com/jteeuwen/go-bindata
go: finding module for package github.com/schollz/progressbar
go: finding module for package github.com/AlecAivazis/survey/v2/core
go: downloading github.com/tdewolff/minify v1.1.0
go: downloading github.com/jawher/mow.cli v1.2.0
go: downloading github.com/AlecAivazis/survey/v2 v2.1.1
go: downloading github.com/jteeuwen/go-bindata v3.0.7+incompatible
go: downloading github.com/schollz/progressbar v1.0.0
go: downloading github.com/AlecAivazis/survey v1.8.8
go: downloading github.com/tdewolff/minify v2.3.6+incompatible
go: found github.com/AlecAivazis/survey/v2 in github.com/AlecAivazis/survey/v2 v2.1.1
go: found github.com/AlecAivazis/survey/v2/core in github.com/AlecAivazis/survey/v2 v2.1.1
go: found github.com/jawher/mow.cli in github.com/jawher/mow.cli v1.2.0
GoAdmin CLI v1.2.16

? choose table to generate [select all]
? generate permission records for tables yes

✔ generating: 

 100% |████████████████████████████████████████| [0s:0s]            

Generate data table models success~~🍺🍺

see the docs: https://book.go-admin.com
visit forum: http://discuss.go-admin.com


make serve  
go run .
main.go:18:2: import "github.com/GoAdminGroup/example/tables" is a program, not an importable package
make[1]: *** [serve] Error 1
make: *** [run] Error 2

joe-getcouragenow avatar Sep 08 '20 07:09 joe-getcouragenow

So the fix is:

rename packages in tables to be "tables": https://github.com/GoAdminGroup/example/tree/master/tables

package tables

and in tables.go: https://github.com/GoAdminGroup/example/blob/master/tables/tables.go#L20

rename this

"users":   GetUsersTable,

These changes have to happen in the generator though at: https://github.com/GoAdminGroup/go-admin/blob/master/adm/generate.go

"packageName" is the variable: https://github.com/GoAdminGroup/go-admin/blob/master/adm/generate.go#L69

joe-getcouragenow avatar Sep 08 '20 07:09 joe-getcouragenow

i'm having the same problem here, what can we do locally?

brookyu avatar Sep 20 '20 03:09 brookyu