From 1163963381f255ce7237ecb6de7b69213037eb49 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Sun, 16 Aug 2020 10:43:25 +0530 Subject: [PATCH] Migrate to Go modules --- .gitignore | 1 + go.mod | 8 +++++++ go.sum | 24 +++++++++++++++++++ pkg/moq/moq_test.go | 10 ++++---- pkg/moq/testpackages/buildconstraints/go.mod | 5 ++++ pkg/moq/testpackages/buildconstraints/go.sum | 3 +++ .../buildconstraints/user/user.go | 3 +-- .../moq-test-pkgs/buildconstraints/go.mod | 3 +++ .../moq-test-pkgs}/buildconstraints/go17.go | 1 - .../buildconstraints/pre_go17.go | 1 - .../buildconstraints/vendor/modules.txt | 3 +++ pkg/moq/testpackages/go.mod | 5 ++++ pkg/moq/testpackages/go.sum | 2 ++ .../testpackages/gogenvendoring/user/user.go | 2 +- .../gogenvendoring/user/user_moq_test.go | 2 +- .../moq-test-pkgs}/somerepo/code.go | 0 .../sudo-suhas/moq-test-pkgs/somerepo/go.mod | 3 +++ pkg/moq/testpackages/vendor/modules.txt | 3 +++ pkg/moq/testpackages/vendoring/go.mod | 5 ++++ pkg/moq/testpackages/vendoring/go.sum | 2 ++ pkg/moq/testpackages/vendoring/user/user.go | 2 +- .../sudo-suhas/moq-test-pkgs/somerepo/code.go | 13 ++++++++++ .../sudo-suhas/moq-test-pkgs/somerepo/go.mod | 3 +++ .../testpackages/vendoring/vendor/modules.txt | 3 +++ pkg/vendor/github.com/matryer/somerepo/yep.go | 4 ---- 25 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 go.mod create mode 100644 go.sum create mode 100644 pkg/moq/testpackages/buildconstraints/go.mod create mode 100644 pkg/moq/testpackages/buildconstraints/go.sum create mode 100644 pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go.mod rename pkg/moq/testpackages/buildconstraints/vendor/github.com/{matryer => sudo-suhas/moq-test-pkgs}/buildconstraints/go17.go (99%) rename pkg/moq/testpackages/buildconstraints/vendor/github.com/{matryer => sudo-suhas/moq-test-pkgs}/buildconstraints/pre_go17.go (98%) create mode 100644 pkg/moq/testpackages/buildconstraints/vendor/modules.txt create mode 100644 pkg/moq/testpackages/go.mod create mode 100644 pkg/moq/testpackages/go.sum rename pkg/moq/testpackages/{vendoring/vendor/github.com/matryer => vendor/github.com/sudo-suhas/moq-test-pkgs}/somerepo/code.go (100%) create mode 100644 pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod create mode 100644 pkg/moq/testpackages/vendor/modules.txt create mode 100644 pkg/moq/testpackages/vendoring/go.mod create mode 100644 pkg/moq/testpackages/vendoring/go.sum create mode 100644 pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go create mode 100644 pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod create mode 100644 pkg/moq/testpackages/vendoring/vendor/modules.txt delete mode 100644 pkg/vendor/github.com/matryer/somerepo/yep.go diff --git a/.gitignore b/.gitignore index 016a02d..1cdf263 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ _testmain.go *.prof .vscode .idea +.playground diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..88448bd --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/matryer/moq + +go 1.14 + +require ( + github.com/pmezard/go-difflib v1.0.0 + golang.org/x/tools v0.0.0-20200815165600-90abf76919f3 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c5fc404 --- /dev/null +++ b/go.sum @@ -0,0 +1,24 @@ +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +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/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200815165600-90abf76919f3 h1:0aScV/0rLmANzEYIhjCOi2pTvDyhZNduBUMD2q3iqs4= +golang.org/x/tools v0.0.0-20200815165600-90abf76919f3/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/moq/moq_test.go b/pkg/moq/moq_test.go index cf1eed0..072cb7a 100644 --- a/pkg/moq/moq_test.go +++ b/pkg/moq/moq_test.go @@ -393,7 +393,7 @@ func TestVendoredPackages(t *testing.T) { s := buf.String() // assertions of things that should be mentioned var strs = []string{ - `"github.com/matryer/somerepo"`, + `"github.com/sudo-suhas/moq-test-pkgs/somerepo"`, } for _, str := range strs { if !strings.Contains(s, str) { @@ -404,7 +404,7 @@ func TestVendoredPackages(t *testing.T) { func TestVendoredInterface(t *testing.T) { m, err := New(Config{ - SrcDir: "testpackages/vendoring/vendor/github.com/matryer/somerepo", + SrcDir: "testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo", PkgName: "someother", }) if err != nil { @@ -418,14 +418,14 @@ func TestVendoredInterface(t *testing.T) { s := buf.String() // assertions of things that should be mentioned var strs = []string{ - `"github.com/matryer/somerepo"`, + `"github.com/sudo-suhas/moq-test-pkgs/somerepo"`, } for _, str := range strs { if !strings.Contains(s, str) { t.Errorf("expected but missing: \"%s\"", str) } } - incorrectImport := `"github.com/matryer/moq/pkg/moq/testpackages/vendoring/vendor/github.com/matryer/somerepo"` + incorrectImport := `"github.com/matryer/moq/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo"` if strings.Contains(s, incorrectImport) { t.Errorf("unexpected import: %s", incorrectImport) } @@ -444,7 +444,7 @@ func TestVendoredBuildConstraints(t *testing.T) { s := buf.String() // assertions of things that should be mentioned var strs = []string{ - `"github.com/matryer/buildconstraints"`, + `"github.com/sudo-suhas/moq-test-pkgs/buildconstraints"`, } for _, str := range strs { if !strings.Contains(s, str) { diff --git a/pkg/moq/testpackages/buildconstraints/go.mod b/pkg/moq/testpackages/buildconstraints/go.mod new file mode 100644 index 0000000..4c80660 --- /dev/null +++ b/pkg/moq/testpackages/buildconstraints/go.mod @@ -0,0 +1,5 @@ +module github.com/matryer/moq/pkg/moq/testpackages/buildconstraints + +go 1.14 + +require github.com/sudo-suhas/moq-test-pkgs/buildconstraints v0.0.0-20200816045313-d2f573eea6c7 diff --git a/pkg/moq/testpackages/buildconstraints/go.sum b/pkg/moq/testpackages/buildconstraints/go.sum new file mode 100644 index 0000000..423fbc9 --- /dev/null +++ b/pkg/moq/testpackages/buildconstraints/go.sum @@ -0,0 +1,3 @@ +github.com/sudo-suhas/moq-test-pkgs v0.0.0-20200816045313-d2f573eea6c7 h1:Nrz0lKzL7rEBWiclll8DLmBAuPZxMdJTe3UHzPOUkgg= +github.com/sudo-suhas/moq-test-pkgs/buildconstraints v0.0.0-20200816045313-d2f573eea6c7 h1:/GmPJhGa5xWMHHdGZ7K5MNM6prYeSnlSUeExdNg62bk= +github.com/sudo-suhas/moq-test-pkgs/buildconstraints v0.0.0-20200816045313-d2f573eea6c7/go.mod h1:3SKj4JbVOiJQrGo/HyVTyp+jKwC8eIIDtOaK4L5RZNE= diff --git a/pkg/moq/testpackages/buildconstraints/user/user.go b/pkg/moq/testpackages/buildconstraints/user/user.go index 10d3d9a..32050bf 100644 --- a/pkg/moq/testpackages/buildconstraints/user/user.go +++ b/pkg/moq/testpackages/buildconstraints/user/user.go @@ -1,9 +1,8 @@ package user -import "github.com/matryer/buildconstraints" +import "github.com/sudo-suhas/moq-test-pkgs/buildconstraints" // Service does something good with computers. type Service interface { DoSomething(buildconstraints.SomeType) error } - diff --git a/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go.mod b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go.mod new file mode 100644 index 0000000..4a0243b --- /dev/null +++ b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go.mod @@ -0,0 +1,3 @@ +module github.com/sudo-suhas/moq-test-pkgs/buildconstraints + +go 1.14 diff --git a/pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/go17.go b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go17.go similarity index 99% rename from pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/go17.go rename to pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go17.go index a03f6f5..45cce6f 100644 --- a/pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/go17.go +++ b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/go17.go @@ -9,4 +9,3 @@ type SomeType struct { // Truth indicates whether true is true or not. Computers. Truth bool } - diff --git a/pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/pre_go17.go b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/pre_go17.go similarity index 98% rename from pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/pre_go17.go rename to pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/pre_go17.go index 3fc99b6..4b714df 100644 --- a/pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/pre_go17.go +++ b/pkg/moq/testpackages/buildconstraints/vendor/github.com/sudo-suhas/moq-test-pkgs/buildconstraints/pre_go17.go @@ -3,4 +3,3 @@ package buildconstraints var someVariable = "Value 2" - diff --git a/pkg/moq/testpackages/buildconstraints/vendor/modules.txt b/pkg/moq/testpackages/buildconstraints/vendor/modules.txt new file mode 100644 index 0000000..983d8e2 --- /dev/null +++ b/pkg/moq/testpackages/buildconstraints/vendor/modules.txt @@ -0,0 +1,3 @@ +# github.com/sudo-suhas/moq-test-pkgs/buildconstraints v0.0.0-20200816045313-d2f573eea6c7 +## explicit +github.com/sudo-suhas/moq-test-pkgs/buildconstraints diff --git a/pkg/moq/testpackages/go.mod b/pkg/moq/testpackages/go.mod new file mode 100644 index 0000000..2755150 --- /dev/null +++ b/pkg/moq/testpackages/go.mod @@ -0,0 +1,5 @@ +module github.com/matryer/moq/pkg/moq/testpackages + +go 1.14 + +require github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 diff --git a/pkg/moq/testpackages/go.sum b/pkg/moq/testpackages/go.sum new file mode 100644 index 0000000..9f7813a --- /dev/null +++ b/pkg/moq/testpackages/go.sum @@ -0,0 +1,2 @@ +github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 h1:5TDSgxW5A9Homgu8Kh0iB1aeRCgM1y8pZaxAR0TjeQs= +github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7/go.mod h1:3CK3+2qBd+EkNJP+dgGjVYIbEwRQWVf6EgcmyIjTi2A= diff --git a/pkg/moq/testpackages/gogenvendoring/user/user.go b/pkg/moq/testpackages/gogenvendoring/user/user.go index 87f6e29..2496103 100644 --- a/pkg/moq/testpackages/gogenvendoring/user/user.go +++ b/pkg/moq/testpackages/gogenvendoring/user/user.go @@ -1,6 +1,6 @@ package user -import "github.com/matryer/somerepo" +import "github.com/sudo-suhas/moq-test-pkgs/somerepo" //go:generate moq -out user_moq_test.go . Service diff --git a/pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go b/pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go index 5f8be89..0ca586f 100644 --- a/pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go +++ b/pkg/moq/testpackages/gogenvendoring/user/user_moq_test.go @@ -4,7 +4,7 @@ package user import ( - "github.com/matryer/somerepo" + "github.com/sudo-suhas/moq-test-pkgs/somerepo" "sync" ) diff --git a/pkg/moq/testpackages/vendoring/vendor/github.com/matryer/somerepo/code.go b/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go similarity index 100% rename from pkg/moq/testpackages/vendoring/vendor/github.com/matryer/somerepo/code.go rename to pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go diff --git a/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod b/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod new file mode 100644 index 0000000..c30f001 --- /dev/null +++ b/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod @@ -0,0 +1,3 @@ +module github.com/sudo-suhas/moq-test-pkgs/somerepo + +go 1.14 diff --git a/pkg/moq/testpackages/vendor/modules.txt b/pkg/moq/testpackages/vendor/modules.txt new file mode 100644 index 0000000..5b3276c --- /dev/null +++ b/pkg/moq/testpackages/vendor/modules.txt @@ -0,0 +1,3 @@ +# github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 +## explicit +github.com/sudo-suhas/moq-test-pkgs/somerepo diff --git a/pkg/moq/testpackages/vendoring/go.mod b/pkg/moq/testpackages/vendoring/go.mod new file mode 100644 index 0000000..f959739 --- /dev/null +++ b/pkg/moq/testpackages/vendoring/go.mod @@ -0,0 +1,5 @@ +module github.com/matryer/moq/pkg/moq/testpackages/vendoring + +go 1.14 + +require github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 diff --git a/pkg/moq/testpackages/vendoring/go.sum b/pkg/moq/testpackages/vendoring/go.sum new file mode 100644 index 0000000..9f7813a --- /dev/null +++ b/pkg/moq/testpackages/vendoring/go.sum @@ -0,0 +1,2 @@ +github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 h1:5TDSgxW5A9Homgu8Kh0iB1aeRCgM1y8pZaxAR0TjeQs= +github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7/go.mod h1:3CK3+2qBd+EkNJP+dgGjVYIbEwRQWVf6EgcmyIjTi2A= diff --git a/pkg/moq/testpackages/vendoring/user/user.go b/pkg/moq/testpackages/vendoring/user/user.go index 798f104..4d20111 100644 --- a/pkg/moq/testpackages/vendoring/user/user.go +++ b/pkg/moq/testpackages/vendoring/user/user.go @@ -1,6 +1,6 @@ package user -import "github.com/matryer/somerepo" +import "github.com/sudo-suhas/moq-test-pkgs/somerepo" // Service does something good with computers. type Service interface { diff --git a/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go new file mode 100644 index 0000000..d5fbd14 --- /dev/null +++ b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go @@ -0,0 +1,13 @@ +// Package somerepo is a vendored package to test how moq deals with +// packages in the vendor package. +package somerepo + +// SomeType is just some old type. +type SomeType struct { + // Truth indicates whether true is true or not. Computers. + Truth bool +} + +type SomeService interface { + Get() SomeType +} diff --git a/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod new file mode 100644 index 0000000..c30f001 --- /dev/null +++ b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/go.mod @@ -0,0 +1,3 @@ +module github.com/sudo-suhas/moq-test-pkgs/somerepo + +go 1.14 diff --git a/pkg/moq/testpackages/vendoring/vendor/modules.txt b/pkg/moq/testpackages/vendoring/vendor/modules.txt new file mode 100644 index 0000000..5b3276c --- /dev/null +++ b/pkg/moq/testpackages/vendoring/vendor/modules.txt @@ -0,0 +1,3 @@ +# github.com/sudo-suhas/moq-test-pkgs/somerepo v0.0.0-20200816045313-d2f573eea6c7 +## explicit +github.com/sudo-suhas/moq-test-pkgs/somerepo diff --git a/pkg/vendor/github.com/matryer/somerepo/yep.go b/pkg/vendor/github.com/matryer/somerepo/yep.go deleted file mode 100644 index b580e91..0000000 --- a/pkg/vendor/github.com/matryer/somerepo/yep.go +++ /dev/null @@ -1,4 +0,0 @@ -package somerepo - -// SomeType is some type -type SomeType string