Skip to content

Commit 4e819bf

Browse files
committed
build(deps): bump github.com/ccoveille/go-safecast to 1.8.1
1 parent 022f31a commit 4e819bf

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/authzed/grpcutil v0.0.0-20240123194739-2ea1e3d2d98b
1818
github.com/authzed/spicedb v1.45.4
1919
github.com/brianvoe/gofakeit/v6 v6.28.0
20-
github.com/ccoveille/go-safecast v1.6.1
20+
github.com/ccoveille/go-safecast v1.8.1
2121
github.com/cenkalti/backoff/v4 v4.3.0
2222
github.com/charmbracelet/lipgloss v1.1.0
2323
github.com/charmbracelet/x/term v0.2.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,8 @@ github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNr
810810
github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das=
811811
github.com/ccoveille/go-safecast v1.6.1 h1:Nb9WMDR8PqhnKCVs2sCB+OqhohwO5qaXtCviZkIff5Q=
812812
github.com/ccoveille/go-safecast v1.6.1/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8=
813+
github.com/ccoveille/go-safecast v1.8.1 h1:RoucjfYKKcx2lFmIjRjuo8AeX9k/GaZn5SUMHlA3kMw=
814+
github.com/ccoveille/go-safecast v1.8.1/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8=
813815
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
814816
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
815817
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

internal/cmd/restorer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (r *restorer) commitStream(ctx context.Context, bulkImportClient v1.Permiss
279279

280280
// it was a successful transaction commit without duplicates
281281
if resp != nil {
282-
numLoaded, err := safecast.ToUint(resp.NumLoaded)
282+
numLoaded, err := safecast.Convert[uint](resp.NumLoaded)
283283
if err != nil {
284284
return spiceerrors.MustBugf("could not cast numLoaded to uint")
285285
}
@@ -289,7 +289,7 @@ func (r *restorer) commitStream(ctx context.Context, bulkImportClient v1.Permiss
289289
}
290290
}
291291

292-
writtenAndSkipped, err := safecast.ToInt64(r.writtenRels + r.skippedRels)
292+
writtenAndSkipped, err := safecast.Convert[int64](r.writtenRels + r.skippedRels)
293293
if err != nil {
294294
return fmt.Errorf("too many written and skipped rels for an int64")
295295
}

internal/cmd/restorer_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ func (m *mockClientForRestore) Send(req *v1.ImportBulkRelationshipsRequest) erro
220220

221221
for i, rel := range req.Relationships {
222222
// This is a gosec115 false positive which should be fixed in a future version.
223-
uinti, _ := safecast.ToUint(i)
223+
uinti, err := safecast.Convert[uint](i)
224+
if err != nil {
225+
// just in case to avoid accessing out of bounds in the []string
226+
uinti = 0
227+
}
224228
require.True(m.t, proto.Equal(rel, tuple.MustParseV1Rel(m.expectedRels[((m.receivedBatches-1)*m.requestedBatchSize)+uinti])))
225229
}
226230

internal/cmd/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func schemaCopyCmdFunc(cmd *cobra.Command, args []string) error {
223223
}
224224

225225
func schemaWriteCmdImpl(cmd *cobra.Command, args []string, client v1.SchemaServiceClient, terminalChecker termChecker) error {
226-
stdInFd, err := safecast.ToInt(uint(os.Stdin.Fd()))
226+
stdInFd, err := safecast.Convert[int](uint(os.Stdin.Fd()))
227227
if err != nil {
228228
return err
229229
}
@@ -363,7 +363,7 @@ func determinePrefixForSchema(ctx context.Context, specifiedPrefix string, clien
363363
// Compiles an input schema written in the new composable schema syntax
364364
// and produces it as a fully-realized schema
365365
func schemaCompileCmdFunc(cmd *cobra.Command, args []string, termChecker termChecker) error {
366-
stdOutFd, err := safecast.ToInt(uint(os.Stdout.Fd()))
366+
stdOutFd, err := safecast.Convert[int](uint(os.Stdout.Fd()))
367367
if err != nil {
368368
return err
369369
}

internal/cmd/validate.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,16 @@ func outputErrorWithSource(sb *strings.Builder, validateContents []byte, errWith
283283

284284
func outputForLine(sb *strings.Builder, validateContents []byte, oneIndexedLineNumber uint64, sourceCodeString string, oneIndexedColumnPosition uint64) {
285285
lines := strings.Split(string(validateContents), "\n")
286-
// These should be fine to be zero if the cast fails.
287-
intLineNumber, _ := safecast.ToInt(oneIndexedLineNumber)
288-
intColumnPosition, _ := safecast.ToInt(oneIndexedColumnPosition)
286+
intLineNumber, err := safecast.Convert[int](oneIndexedLineNumber)
287+
if err != nil {
288+
// It's fine to be zero if the cast fails.
289+
intLineNumber = 0
290+
}
291+
intColumnPosition, _ := safecast.Convert[int](oneIndexedColumnPosition)
292+
if err != nil {
293+
// It's fine to be zero if the cast fails.
294+
intColumnPosition = 0
295+
}
289296
errorLineNumber := intLineNumber - 1
290297
for i := errorLineNumber - 3; i < errorLineNumber+3; i++ {
291298
if i == errorLineNumber {

0 commit comments

Comments
 (0)