bud icon indicating copy to clipboard operation
bud copied to clipboard

Can't create routes named `index`, `show`

Open 012e opened this issue 3 years ago • 7 comments

Reproduce

  1. Create a new project bud create project
  2. Create a root route (important) bud new controller anything:/ index show
  3. bud new controller index or bud new controller show (with or without views)
  4. bud run will give an error:
| conjure: generate "bud/.app/main.go". conjure: generate "bud/.app/program/program.go". program: unable to wire. di: unable to wire "bud-app/bud/program".loadApp function. di: unable to find definition for param "bud-app/bud/.app/controller".*Controller in "bud-app/bud/.app/web".*Server . parser: unable to find declaration for "bud-app/bud/.app/controller".Controller in "bud/.app/web/web.go". bud/.app/controller/controller.go:15:2: Index redeclared in this block
	previous declaration at bud/.app/controller/controller.go:13:2

012e avatar Jun 23 '22 10:06 012e

Thanks for the report @012e! That's strange, but I'm not too surprised since it's untested. Just want to double-check. The 1/ directory in "1/bud/.app/controller" isn't related to #144 right?

matthewmueller avatar Jun 24 '22 00:06 matthewmueller

Yes, 1 is just the module name.

012e avatar Jun 24 '22 04:06 012e

My previous report was wrong so I rewrote it

012e avatar Jun 26 '22 04:06 012e

Thanks! I can reproduce this one. Are you blocked by this one @012e? I may bundle this one together with reworking the controller generator to be middleware.

matthewmueller avatar Jun 27 '22 06:06 matthewmueller

Are you blocked by this one @012e?

Not really, I don't need this

012e avatar Jun 28 '22 05:06 012e

~~I was not able to reproduce this with the latest bud version 0.2.0~~

~~On a new bud project:~~

bud new controller foobar:/ index show bud new controller index

~~Worked as expected with no errors~~

Disregard. I was able to reproduce it.

dangerzone avatar Jul 07 '22 12:07 dangerzone

It is trying to create this during file generation (at the top of controller/controller.go).

// Controller struct
type Controller struct {
	Index *IndexAction
	Show *ShowAction
	Index *IndexController
}

I'm looking at the .gotext files and experimenting with how feasible it would be to do the following instead:

// Controller struct
type Controller struct {
	IndexAction *IndexAction
	ShowAction *ShowAction
	IndexController *IndexController
}

Edit:

I have it working this way now on a branch I'm toying with:

// Controller struct
type Controller struct {
	Indexaction *IndexAction
	Showaction *ShowAction
	Index *IndexController
}

This also works at deeper levels of nesting, where the problem was occurring as well.

jfmario avatar Jul 16 '22 14:07 jfmario