99designs / 99designs/gqlgen

goTag limitation

未關閉 適合新手
#3,955 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Go
星號
10.8k
分支
1.3k
平均合併
2 天 36 分鐘
30 天內合併 PR
26

描述

Hello !

I am new using gqlgen, thanks for this project.

While playing with I am hitting some limitation regarding `goTag` usage.

Having this simple schema :

```
type License {
description: String!
@goTag(key: "json", value: "description")
@goTag(
key: "doc"
value: "Detailed description of the license capabilities and restrictions"
)
@goTag(key: "example", value: "This license provides access to all enterprise features including advanced analytics, priority support, and unlimited users")
@goTag(key: "maxLength", value: "500")

version: String!
@goTag(key: "json", value: "version")
@goTag(key: "doc", value: "Version of the license (e.g., 1)")
@goTag(key: "example", value: "1")
}
```

I got the two error when use generate command :

```
panic: tag value should not contain any leading or trailing spaces: "This license provides access to all enterprise features including advanced analytics, priority support, and unlimited users"

goroutine 1 [running]:
github.com/99designs/gqlgen/plugin/modelgen.removeDuplicateTags({0x140001d0240, 0x103})
/Users/tomflenner/golang/pkg/mod/github.com/99designs/gqlgen@v0.17.84/plugin/modelgen/models.go:698 +0x47c
github.com/99designs/gqlgen/plugin/modelgen.GoTagFieldHook(0x14000c514a0?, 0x14000441680, 0x140009162a0)

```

```
panic: tag value should not contain any leading or trailing spaces: "Version of the license (e.g., 1)"

goroutine 1 [running]:
github.com/99designs/gqlgen/plugin/modelgen.removeDuplicateTags({0x14000d869b0, 0x50})
/Users/tomflenner/golang/pkg/mod/github.com/99designs/gqlgen@v0.17.84/plugin/modelgen/models.go:698 +0x47c
github.com/99designs/gqlgen/plugin/modelgen.GoTagFieldHook(0x14000d177e0?, 0x14000412f00, 0x140008d97a0)
/Users/tomflenner/golang/pkg/mod/github.com/99designs/gqlgen@v0.17.84/plugin/modelgen/models.go:605 +0x41c

```

I am wondering is there is such limitation regarding the length of value OR special character ?

Thanks in advance !

貢獻指南

開啟貢獻指南

研究方向

錯誤源自 plugin/modelgen/models.go 第 698 行的 removeDuplicateTags。查看第 605 行附近的 GoTagFieldHook 函式。問題在於,帶有前導或尾隨空格的 tag 值會導致 panic。檢查 tag 的剖析與驗證方式。修正可能涉及移除空格或調整驗證。使用測試 schema 執行 gqlgen generate 命令,以重現 panic。

由索引模型根據 Issue 內容生成。

評估

領域
backend-api-design
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。