Skip to content

Cleanup go.mod/go.sum #2321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Cleanup go.mod/go.sum #2321

wants to merge 2 commits into from

Conversation

inliquid
Copy link

Remove redundant dependencies.

Remove redundant dependencies.
Remove redundant dependencies.
@emirb
Copy link
Contributor

emirb commented Apr 11, 2019

go mod tidy in the current master generates this change only:

diff --git a/go.sum b/go.sum
index 894ee21..cb04ab3 100644
--- a/go.sum
+++ b/go.sum
@@ -130,6 +130,7 @@ google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+
 google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
 google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=

@emirb emirb closed this Apr 11, 2019
@inliquid
Copy link
Author

inliquid commented Apr 11, 2019

@emirb
Don't run go mod tidy if there is no special need, as it adds a lot of unnecessary indirect test dependencies.
One of few active issues about it: golang/go#27633

@inliquid
Copy link
Author

@emirb
If you want to see "clean" version of go.mod/go.sum - remove its contents and run go list ./...

@emirb
Copy link
Contributor

emirb commented Apr 11, 2019

Hi @inliquid, running go list ./... gives only a list of packages of the project. It does not contain external imports:

$ go list ./...
github.com/jinzhu/gorm
github.com/jinzhu/gorm/dialects/mssql
github.com/jinzhu/gorm/dialects/mysql
github.com/jinzhu/gorm/dialects/postgres
github.com/jinzhu/gorm/dialects/sqlite

Of course, gorm has other external packages imported so go list ./... doesn't give the whole picture.

To start from scratch, removing go.mod and go.sum fully and running go mod init and go get generates the following:

module github.com/jinzhu/gorm


require (
        github.com/denisenkom/go-mssqldb v0.0.0-20190401154936-ce35bd87d4b3
        github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5
        github.com/go-sql-driver/mysql v1.4.1
        github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a
        github.com/jinzhu/now v1.0.0
        github.com/lib/pq v1.0.0
        github.com/mattn/go-sqlite3 v1.10.0
)

Here's the comparison to current master:

diff --git a/go.mod b/go.mod
index 024f73c..31127ff 100644
--- a/go.mod
+++ b/go.mod
@@ -1,13 +1,11 @@
 module github.com/jinzhu/gorm

 require (
-       cloud.google.com/go v0.36.0 // indirect
-       github.com/denisenkom/go-mssqldb v0.0.0-20190204142019-df6d76eb9289
+       github.com/denisenkom/go-mssqldb v0.0.0-20190401154936-ce35bd87d4b3
        github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5
        github.com/go-sql-driver/mysql v1.4.1
        github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a
        github.com/jinzhu/now v1.0.0
        github.com/lib/pq v1.0.0
        github.com/mattn/go-sqlite3 v1.10.0
-       golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
 )

So I see a potential to remove cloud.google.com/go and golang.org/x/crypto imports in another PR; however, your PR removed more than that.

@inliquid
Copy link
Author

In fact you can run any go command so that it automatically fills-in all needed dependencies according to imports. No matter go get <...>, go list <...>, go build <...> or whatever, should be no difference. Probably go list ./... goes deeper than just go list. And I found this one more convenient.

I agree PR needs to be closed, because it's more than 1 month old and probably not up to date with latest changes. It was opened to clean up what was merged at that moment of time.

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