Skip to content

Standard go Module resolution#111

Closed
mariotoffia wants to merge 2 commits intoqntfy:masterfrom
mariotoffia:module-resolution
Closed

Standard go Module resolution#111
mariotoffia wants to merge 2 commits intoqntfy:masterfrom
mariotoffia:module-resolution

Conversation

@mariotoffia
Copy link
Copy Markdown

Is it possible to have a go.mod so I can include it using require in go.mod in my project?

Cheers,
Mario

@JoshuaC215
Copy link
Copy Markdown
Collaborator

Hey @mariotoffia, I'm not sure if this will cause issues since it doesn't include an update to use the semver major version on imports. Also looks like this needs to update the travis script, I suspect removing these two lines will fix or at least see if there are any other issues.

It will be at least a few days before I can take a closer look at this. Appreciate the pull request!

@mariotoffia
Copy link
Copy Markdown
Author

@JoshKCarroll Thanks! I'm new to go so I've got it to work on my master branch.

It required that prepended /v3 on module name and all the imports is prepending /v3 as well, then the module resolver in my other project acknowledged it as a v3 module.

I understand if this is a issue and you don't wish to update it accordingly.

Have a look at my master branch (if you'd like) - I've created a specific branch for this PR so I would not interfere - since I need to update the module to my URL instead of yours (temporarily) while trying out.

Cheers,
Mario :)

diff --git a/go.mod b/go.mod
index 37b8316..4ca7e8e 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/mariotoffia/kazaam
+module github.com/mariotoffia/kazaam/v3

 require (
        github.com/gofrs/uuid v4.0.0+incompatible`
diff --git a/kazaam.go b/kazaam.go
index 3240598..8e14b95 100644
--- a/kazaam.go
+++ b/kazaam.go
@@ -8,7 +8,7 @@ import (
        "fmt"
        "strings"

-       "github.com/mariotoffia/kazaam/transform"
+       "github.com/mariotoffia/kazaam/v3/transform"
        "github.com/qntfy/jsonparser"
 )

@@ -152,7 +152,7 @@ func New(specString string, config Config) (*Kazaam, error) {
 func (k *Kazaam) getTransform(s *spec) TransformFunc {
        // getting a non-existent transform is checked against before this function is
        // called, hence the _
-       tform, _ := k.config.transforms[*s.Operation]
+       tform := k.config.transforms[*s.Operation]
        return tform
 }
diff --git a/kazaam_benchmarks_test.go b/kazaam_benchmarks_test.go
index 14c67e9..6589546 100644
--- a/kazaam_benchmarks_test.go
+++ b/kazaam_benchmarks_test.go
@@ -3,7 +3,7 @@ package kazaam_test
 import (
        "testing"

-       "github.com/mariotoffia/kazaam"
+       "github.com/mariotoffia/kazaam/v3"
 )

 const (
diff --git a/kazaam_int_test.go b/kazaam_int_test.go
index 1e782d2..1788a8c 100644
--- a/kazaam_int_test.go
+++ b/kazaam_int_test.go
@@ -5,8 +5,8 @@ import (
        "reflect"
        "testing"

-       "github.com/mariotoffia/kazaam"
-       "github.com/mariotoffia/kazaam/transform"
+       "github.com/mariotoffia/kazaam/v3"
+       "github.com/mariotoffia/kazaam/v3/transform"
        "github.com/qntfy/jsonparser"
 )

@@ -370,13 +370,13 @@ func TestKazaamNoModify(t *testing.T) {
        }
 }

-func TestConfigdKazaamGet3rdPartyTransform(t *testing.T) {
+func TestConfigsKazaamGet3rdPartyTransform(t *testing.T) {
        kc := kazaam.NewDefaultConfig()
        kc.RegisterTransform("3rd-party", func(spec *transform.Config, data []byte) ([]byte, error) {
-               data, _ = jsonparser.Set(data, []byte(`"does-exist"`), "doesnt-exist")
+               data, _ = jsonparser.Set(data, []byte(`"does-exist"`), "doesn't-exist")
                return data, nil
        })
-       msgOut := `{"test":"data","doesnt-exist":"does-exist"}`
+       msgOut := `{"test":"data","doesn't-exist":"does-exist"}`

        k, _ := kazaam.New(`[{"operation": "3rd-party"}]`, kc)
        kazaamOut, _ := k.TransformJSONStringToString(`{"test":"data"}`)
diff --git a/kazaam_test.go b/kazaam_test.go
index 92f5993..4f9d47f 100644
--- a/kazaam_test.go
+++ b/kazaam_test.go
@@ -4,7 +4,7 @@ import (
        "fmt"
        "testing"

-       "github.com/mariotoffia/kazaam/transform"
+       "github.com/mariotoffia/kazaam/v3/transform"
        "github.com/qntfy/jsonparser"
 )
diff --git a/spec.go b/spec.go
index d4aa4f9..4e988b6 100644
--- a/spec.go
+++ b/spec.go
@@ -3,7 +3,7 @@ package kazaam
 import (
        "encoding/json"

-       "github.com/mariotoffia/kazaam/transform"
+       "github.com/mariotoffia/kazaam/v3/transform"
 )

 // Spec represents an individual spec element. It describes the name of the operation,
@@ -18,7 +18,7 @@ type spec struct {
 type specInt spec
 type specs []spec

-// UnmarshalJSON implements a custon unmarshaller for the Spec type
+// UnmarshalJSON implements a custom unmarshaler for the Spec type
 func (s *spec) UnmarshalJSON(b []byte) (err error) {
        j := specInt{}
        if err = json.Unmarshal(b, &j); err == nil {

@JoshuaC215
Copy link
Copy Markdown
Collaborator

Hey @mariotoffia I merged #112 and bumped kazaam to v4.0.0 to support go mod with the semver import path. Let me know if you have any issues with use. I'm going to close this pull request. Thanks!

@JoshuaC215 JoshuaC215 closed this Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants