99designs / 99designs/gqlgen

Tutorial contains incorrect package import

未关闭 适合新手
#2,520 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
10.8k
派生
1.3k
平均合并
2 天 36 分钟
30 天内合并 PR
26

描述

### What happened?
Learning gqlgen and going through the tutorial - the tutorial reads (from docs/content/getting-started.md):

>Returning to `graph/schema.resolvers.go`, let's implement the bodies of those automatically generated resolver functions. For `CreateTodo`, we'll use the [`math.rand` package](https://pkg.go.dev/math/rand#Rand.Int) to simply return a todo with a randomly generated ID and store that in the in-memory todos list --- in a real app, you're likely to use a database or some other backend service.

However, the implementation for `rand` is as follows a few lines later:

`rand, _ := rand.Int(rand.Reader, big.NewInt(100))`

That signature is not correct for the `rand` implementation from `math/rand`, but instead matches the expected args/returns from the package `crypto/rand`

### What did you expect?
Either we should document importing from `crypto/rand` instead of `math/rand`, or we should change the code to reflect the `rand` implementation from `math/rand`

### Minimal graphql.schema and models to reproduce
N/A

### versions
- `go run github.com/99designs/gqlgen version`?
v0.17.24
- `go version`?
1.19

贡献指南

打开贡献指南

调研方向

该 issue 指向 docs/content/getting-started.md。查看教程中提到 rand import 的部分,以及使用 rand.Int 的代码片段。检查 import 应该是 crypto/rand 还是 math/rand,并相应更新文档。通过阅读这两个 package 的 Go standard library 文档进行验证,以确保 import 和用法正确。

由索引模型根据 Issue 内容生成。

评估

技术栈
go
领域
documentation
Issue 类型
文档
难度
1/5
预计耗时
1 小时以内
活跃度
停滞
描述清晰度
描述清楚
新手友好度
80/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。