Skip to content

Commit

Permalink
Update to hashstructure/v2 (#54)
Browse files Browse the repository at this point in the history
From the docs:

> It is highly recommended you use the "v2" release since this fixes some
> significant hash collisions issues from v1.
  • Loading branch information
rohansingh authored Jun 24, 2021
1 parent b3cc19c commit fa6749e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/harukasan/go-libwebp v0.0.0-20190703060927-68562c9c99af
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mitchellh/hashstructure v1.1.0
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/pkg/errors v0.9.1
github.com/qri-io/starlib v0.5.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eI
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0=
github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA=
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand Down
4 changes: 2 additions & 2 deletions runtime/animatedpositioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package runtime
import (
"fmt"

"github.com/mitchellh/hashstructure"
"github.com/mitchellh/hashstructure/v2"
"go.starlark.net/starlark"

"tidbyt.dev/pixlet/render"
Expand Down Expand Up @@ -93,6 +93,6 @@ func (ap AnimatedPositioned) Freeze() {}
func (ap AnimatedPositioned) Truth() starlark.Bool { return true }

func (ap AnimatedPositioned) Hash() (uint32, error) {
sum, err := hashstructure.Hash(ap, nil)
sum, err := hashstructure.Hash(ap, hashstructure.FormatV2, nil)
return uint32(sum), err
}
4 changes: 2 additions & 2 deletions runtime/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package runtime
import (
"fmt"

"github.com/mitchellh/hashstructure"
"github.com/mitchellh/hashstructure/v2"
"go.starlark.net/starlark"

"tidbyt.dev/pixlet/render"
Expand Down Expand Up @@ -73,6 +73,6 @@ func (r Root) Freeze() {}
func (r Root) Truth() starlark.Bool { return true }

func (r Root) Hash() (uint32, error) {
sum, err := hashstructure.Hash(r, nil)
sum, err := hashstructure.Hash(r, hashstructure.FormatV2, nil)
return uint32(sum), err
}
2 changes: 1 addition & 1 deletion runtime/gen/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"

"github.com/lucasb-eyer/go-colorful"
"github.com/mitchellh/hashstructure"
"github.com/mitchellh/hashstructure/v2"
"go.starlark.net/starlark"
"go.starlark.net/starlarkstruct"
"tidbyt.dev/pixlet/render"
Expand Down
2 changes: 1 addition & 1 deletion runtime/gen/widget.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (w *{{.Name}}) Freeze() {}
func (w *{{.Name}}) Truth() starlark.Bool { return true }

func (w *{{.Name}}) Hash() (uint32, error) {
sum, err := hashstructure.Hash(w, nil)
sum, err := hashstructure.Hash(w, hashstructure.FormatV2, nil)
return uint32(sum), err
}

Expand Down
24 changes: 12 additions & 12 deletions runtime/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions runtime/plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
gocolor "image/color"

"github.com/lucasb-eyer/go-colorful"
"github.com/mitchellh/hashstructure"
"github.com/mitchellh/hashstructure/v2"
"go.starlark.net/starlark"

"tidbyt.dev/pixlet/render"
Expand Down Expand Up @@ -196,6 +196,6 @@ func (p Plot) Freeze() {}
func (p Plot) Truth() starlark.Bool { return true }

func (p Plot) Hash() (uint32, error) {
sum, err := hashstructure.Hash(p, nil)
sum, err := hashstructure.Hash(p, hashstructure.FormatV2, nil)
return uint32(sum), err
}
4 changes: 2 additions & 2 deletions runtime/xpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"

"github.com/antchfx/xmlquery"
"github.com/mitchellh/hashstructure"
"github.com/mitchellh/hashstructure/v2"
"go.starlark.net/starlark"
"go.starlark.net/starlarkstruct"
)
Expand Down Expand Up @@ -141,6 +141,6 @@ func (x *XPath) Freeze() {}
func (x *XPath) Truth() starlark.Bool { return true }

func (x *XPath) Hash() (uint32, error) {
sum, err := hashstructure.Hash(x, nil)
sum, err := hashstructure.Hash(x, hashstructure.FormatV2, nil)
return uint32(sum), err
}

0 comments on commit fa6749e

Please sign in to comment.