Skip to content

Commit

Permalink
Move to Go 1.21.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman committed Jul 15, 2024
1 parent cc06d6d commit b666fd3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22.x"
go-version: "1.21.x"
- name: Install dependencies
run: go get .
- name: Vet
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/restatedev/sdk-go

go 1.22.0
go 1.21.0

require (
github.com/golang-jwt/jwt/v5 v5.2.1
Expand Down
16 changes: 15 additions & 1 deletion internal/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package rand
import (
"crypto/sha256"
"encoding/binary"
"math/rand/v2"
"math/rand"

"github.com/google/uuid"
)
Expand All @@ -25,10 +25,18 @@ func (r *Rand) UUID() uuid.UUID {
return uuid
}

func (r *Rand) Float64() float64 {
// use the math/rand/v2 implementation of Float64() which is more correct
// and also matches our TS implementation
return float64(r.Uint64()<<11>>11) / (1 << 53)
}

type Source struct {
state [4]uint64
}

var _ rand.Source64 = (*Source)(nil)

func newSource(invocationID []byte) *Source {
hash := sha256.New()
hash.Write(invocationID)
Expand All @@ -43,6 +51,12 @@ func newSource(invocationID []byte) *Source {
}}
}

func (s *Source) Int63() int64 {
return int64(s.Uint64() & ((1 << 63) - 1))
}

func (s *Source) Seed(int64) {}

func (s *Source) Uint64() uint64 {
result := rotl((s.state[0]+s.state[3]), 23) + s.state[0]

Expand Down
2 changes: 1 addition & 1 deletion internal/rand/rand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package rand

import (
"encoding/hex"
"math/rand/v2"
"math/rand"
"testing"
)

Expand Down
8 changes: 4 additions & 4 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type serviceNamer interface {
}

var (
typeOfContext = reflect.TypeFor[Context]()
typeOfObjectContext = reflect.TypeFor[ObjectContext]()
typeOfVoid = reflect.TypeFor[Void]()
typeOfError = reflect.TypeFor[error]()
typeOfContext = reflect.TypeOf((*Context)(nil)).Elem()
typeOfObjectContext = reflect.TypeOf((*ObjectContext)(nil)).Elem()
typeOfVoid = reflect.TypeOf((*Void)(nil))
typeOfError = reflect.TypeOf((*error)(nil))
)

// Object converts a struct with methods into a Virtual Object where each correctly-typed
Expand Down

0 comments on commit b666fd3

Please sign in to comment.