99designs / 99designs/gqlgen

Tutorial contains incorrect package import

Aperta
#2,520 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
10.8k
Fork
1.3k
Merge medio
2g 36m
PR unite (30g)
26

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.