Description
What version of Go are you using (go version
)?
$ go version go version go1.12.1 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/mj/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/mj/go" GOPROXY="https://goproxy.io" GORACE="" GOROOT="/usr/local/Cellar/go/1.12.1/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xb/dsd0_2b92x7bsl92xlzj6fbm0000gn/T/go-build051189324=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
main.go
package main
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
func main() {
db, err := gorm.Open("sqlite3", "test.db")
if err != nil {
panic("failed to connect database")
}
defer db.Close()
}
go mod init gorm-demo
go mod tidy
go mod graph
when you run go mod graph
, you can see so many dependencies,
Output
github.com/jinzhu/[email protected] github.com/denisenkom/[email protected] github.com/jinzhu/[email protected] github.com/erikstmartin/[email protected] github.com/jinzhu/[email protected] github.com/go-sql-driver/[email protected] github.com/jinzhu/[email protected] github.com/jinzhu/[email protected] github.com/jinzhu/[email protected] github.com/jinzhu/[email protected] github.com/jinzhu/[email protected] github.com/lib/[email protected] github.com/jinzhu/[email protected] github.com/mattn/[email protected]just for mssql
github.com/denisenkom/[email protected] cloud.google.com/[email protected]
github.com/denisenkom/[email protected] golang.org/x/[email protected]
github.com/denisenkom/[email protected] gopkg.in/[email protected]
github.com/denisenkom/[email protected] gopkg.in/[email protected]just for cloud.google.com/go
cloud.google.com/[email protected] github.com/golang/[email protected]
cloud.google.com/[email protected] honnef.co/go/[email protected]
cloud.google.com/[email protected] google.golang.org/[email protected]
cloud.google.com/[email protected] google.golang.org/[email protected]
cloud.google.com/[email protected] google.golang.org/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] golang.org/x/[email protected]
cloud.google.com/[email protected] [email protected]
cloud.google.com/[email protected] github.com/jstemmer/[email protected]
cloud.google.com/[email protected] github.com/googleapis/gax-go/[email protected]
cloud.google.com/[email protected] github.com/google/[email protected]
cloud.google.com/[email protected] github.com/google/[email protected]+incompatible
cloud.google.com/[email protected] github.com/google/[email protected]
cloud.google.com/[email protected] github.com/google/[email protected]
cloud.google.com/[email protected] github.com/golang/[email protected]and many more ....
What did you expect to see?
what if i only use postgres db, please don't install mssql, sqlite dependencies for me.
i'm not sure this feature calls, maybe conditional dependencies ?
this pattern is common in some library that as a provider .....
What did you see instead?
a huge dependencies tree
Extra information (FYI)
i was a ruby on rails developer, as my experience, package management in node.js is sucking, big node_modules, installed failed, unmet dependencies ...
however in ruby world, package management (bundler) is nearly perfect, maybe go mod designer can learn something from that
https://bundler.io/man/gemfile.5.html#INSTALL_IF
https://bundler.io/v1.10/whats_new.html#install-if
https://bundler.io/guides/groups.html