Slow go build with mattn/go-sqlite3

3,083 views
Skip to first unread message

SauliusGurklys

unread,
Jun 25, 2014, 3:19:11 PM6/25/14
to golan...@googlegroups.com
Hello,

I hope this is the right place to ask this question.

I'm using "github.com/mattn/go-sqlite3" in one of my go program.

Everything is great, except the that "go build" takes 15-20s every time, which is kind of annoying compared to builds of other go programs. :)

It's because every time "go build" recompiles some files (all files?) in "mattn/sqlite3" package.

Is there a way to speed up a build?

Thanks,
--
Saulius


Harmen B

unread,
Jun 25, 2014, 3:47:59 PM6/25/14
to SauliusGurklys, golan...@googlegroups.com
`go install` in .../mattn/sqlite3 ?


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

SauliusGurklys

unread,
Jun 25, 2014, 4:23:28 PM6/25/14
to golan...@googlegroups.com, s4u...@gmail.com
It worked!

Thank you!
--
Saulius

Peter Waller

unread,
Jun 25, 2014, 4:50:36 PM6/25/14
to SauliusGurklys, golang-nuts
To elaborate, what's happening here is that:

* the mattn/go-sqlite3 package has a 5 megabyte .c file in it
* when building the package, this .c file is compiled
* building a 5mb .c takes a while
* unless you `go install` it, the package is built every time you build a package when depends on it.

Does anyone know a way to change this behaviour? Is it just a matter of saying `go install` always instead of `go build`?

gta

unread,
Jun 25, 2014, 5:35:28 PM6/25/14
to golan...@googlegroups.com, s4u...@gmail.com
`go build -i` should also work

Carlos Castillo

unread,
Jun 25, 2014, 6:50:35 PM6/25/14
to golan...@googlegroups.com, s4u...@gmail.com
When you go build, every package that hasn't been installed (or isn't up to date) will be built, but only the final result (if it's an executable) is stored. To avoid this, go install, or go get the packages you aren't working on so the built package is in a location go can use it to skip having to recompile it.

Therefore for a large package, if it's not being modified, you should always go install / go get it. If you pass the -v flag to most go commands, it will print out a list of packages that are being built. If you want to speed up your next go build, you can either go install the dependencies, or you can use "go test -i -v" to install the dependencies (and see what was installed).

Dave Cheney

unread,
Jun 26, 2014, 1:40:57 AM6/26/14
to golan...@googlegroups.com
I wrote about this recently.


In short, use `go install`. I even have an alias setup, 

   alias gb='go install -v'

Cheers

Dave

dr...@stackengine.com

unread,
Feb 12, 2015, 1:50:51 PM2/12/15
to golan...@googlegroups.com
Is go build -i safe to use when depending on packages that will change? ie.


Will myproject get updated if I use go build -i?

Dave Cheney

unread,
Feb 12, 2015, 5:54:03 PM2/12/15
to dr...@stackengine.com, golang-nuts

I can't think of a justification for using go build (with any mode) over go install. My recommendation is to set up this alias

    alias GB='go install -v'

And use it exclusively.

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/KexEyiy6PvA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages