From 323cff4511cab59d92084463a21cb71f41bf4ed1 Mon Sep 17 00:00:00 2001 From: Safeer Jiwan Date: Thu, 13 Jun 2024 23:35:18 -0700 Subject: [PATCH] fix: provide a better error if go verb isn't upper camel case (#1783) Fixes #1742 --- go-runtime/compile/schema.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go-runtime/compile/schema.go b/go-runtime/compile/schema.go index 070fffd9e7..32ed8014fd 100644 --- a/go-runtime/compile/schema.go +++ b/go-runtime/compile/schema.go @@ -1224,6 +1224,11 @@ func visitFuncDecl(pctx *parseContext, node *ast.FuncDecl) (verb *schema.Verb) { return nil } + if expVerbName := strcase.ToUpperCamel(node.Name.Name); node.Name.Name != expVerbName { + pctx.errors.add(errorf(node, "unexpected verb name %q, did you mean to use %q instead?", node.Name.Name, expVerbName)) + return nil + } + for _, name := range pctx.nativeNames { if name == node.Name.Name { pctx.errors.add(noEndColumnErrorf(node.Pos(), "duplicate verb name %q", node.Name.Name))