Skip to content
Gx
GitHub

GX4002: more than one action is registered for a route type

Two gx.Action calls handle the same route type.

Cause

Two gx.Action calls handle the same route type. The message gives the two positions.

Example

cart/Button.gx
package cart

import "app/cart/route"

<button on:click={route.Add{}}>Add</button>
cart/cart.go
package cart

import (
	"github.com/alternayte/gx"
	"app/cart/route"
)

var Add = gx.Action(func(c *gx.Ctx, in route.Add) error { return nil })

var AddAgain = gx.Action(func(c *gx.Ctx, in route.Add) error { return nil })
cart/route/route.go
package route

import "github.com/alternayte/gx"

type Add struct {
	gx.Route `POST /cart/add`
}

gx check reports:

gx check
cart/Button.gx:5:9: GX4002: "Add" is registered 2 times: cart/cart.go:8:11, cart/cart.go:10:16

Fix

  1. Remove one of the two calls.
  2. Or give the second action its own route type.