Skip to content

Commit

Permalink
Fix: goodbye easyjson (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho authored Aug 15, 2021
1 parent 6247fdf commit 98146ff
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 664 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.PHONY:easyjson
easyjson:
easyjson -all ./internal/model/config.go

.PHONY:build
build:
go build .
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/sanposhiho/gomockhandler
go 1.16

require (
github.com/mailru/easyjson v0.7.7
golang.org/x/mod v0.4.1
golang.org/x/sync v0.0.0-20190423024810-112230192c58
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
Expand Down
2 changes: 1 addition & 1 deletion internal/command/generate_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r Runner) GenerateConfig() {
destinationPathInPro := util.PathInProject(configDir, originalPath+"/"+r.Args.Destination)
r.MockgenRunner.SetDestination(destinationPathInPro)

var sourceChecksum [16]byte
var sourceChecksum string
if r.Args.Source != "" {
// change source as seen from the config directory.
sourcePathInPro := util.PathInProject(configDir, originalPath+"/"+r.Args.Source)
Expand Down
2 changes: 1 addition & 1 deletion internal/command/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (r Runner) Mockgen() {
m := m
g.Go(func() error {
var runner mockgen.Runner
var sourceChecksum [16]byte
var sourceChecksum string
switch m.Mode {
case model.ReflectMode:
runner = m.ReflectModeRunner
Expand Down
10 changes: 5 additions & 5 deletions internal/mockgen/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Runner interface {
GetDestination() string
}

func Checksum(r Runner) ([16]byte, error) {
func Checksum(r Runner) (string, error) {
d := r.GetDestination()
tmpFile := util.TmpFilePath(d)
defer os.Remove(tmpFile)
Expand All @@ -26,21 +26,21 @@ func Checksum(r Runner) ([16]byte, error) {
defer r.SetDestination(d)

if err := r.Run(); err != nil {
return [16]byte{}, fmt.Errorf("failed to run mockgen: %v \nPlease run `%s` and check if mockgen works correctly with your options", err, r)
return "", fmt.Errorf("failed to run mockgen: %v \nPlease run `%s` and check if mockgen works correctly with your options", err, r)
}

checksum, err := util.CalculateCheckSum(tmpFile)
if err != nil {
return [16]byte{}, fmt.Errorf("calculate checksum of the mock: %v", err)
return "", fmt.Errorf("calculate checksum of the mock: %v", err)
}

return checksum, nil
}

func SourceChecksum(r Runner) ([16]byte, error) {
func SourceChecksum(r Runner) (string, error) {
checksum, err := util.CalculateCheckSum(r.GetSource())
if err != nil {
return [16]byte{}, fmt.Errorf("calculate checksum of the mock source: %v", err)
return "", fmt.Errorf("calculate checksum of the mock source: %v", err)
}

return checksum, nil
Expand Down
1 change: 0 additions & 1 deletion internal/model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package model

import "errors"

//easyjson:json
type Config struct {
// key: destination
Mocks map[string]*Mock `json:"mocks"`
Expand Down
Loading

0 comments on commit 98146ff

Please sign in to comment.