• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattn / go-sqlite3 / 1
53%
master: 54%

Build:
Build:
LAST BUILD BRANCH: add-github-actions
DEFAULT BRANCH: master
Ran 05 Jun 2020 05:35AM UTC
Jobs 68
Files 12
Run time 974241min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
1

push

travis-ci-com

arp242
Add mock versions of SQLiteDriver and SQLiteConn for +build !cgo

My app can use PostgreSQL and – optionally – SQLite. I would like to be
able to compile the app without cgo when SQLite isn't used, as this
removes the need for a C compiler which makes builds easier and faster,
especially for end-users.

In the simple case, this is not a problem go-sqlite3 already provides a
simple non-cgo mock so it compiles and gives a runtime error if you try
to use it anyway.

However, now I'd like to register a function for my SQLite connection to
match a PostgreSQL function like so:

	sql.Register("sqlite3_custom", &sqlite3.SQLiteDriver{
		ConnectHook: func(conn *sqlite3.SQLiteConn) error {
			return conn.RegisterFunc("pow", pow, true); err != nil {
		},
	})

But this makes it quite hard to keep the same logic since it refers to
non-existing types. I will need to create a db.go with `+build !cgo` and
db_cgo.go with `+buid cgo` which duplicates all the logic but with the
sqlite hooks. In my case, this actually affects quite a lot; for example
I have a helper function which connects and runs migrations and whatnot
which looks like:

	type ConnectOptions struct {
		Connect    string // Connect string.
		Schema     []byte // Database schema to create on startup.
		Migrate    *Migrate
		SQLiteHook func(*sqlite3.SQLiteConn) error
	}

And I'd have to have two versions of that, too. You could perhaps do
some stuff with interfaces, but because the sql.Register() call
references the sqlite.SQLiteDriver.ConnectHook struct field that's not
so straightforward, either.

This simplifies all of that by just providing some common types that may
be used in this case. I renamed the `SQLiteDriverMock` to
`&SQLiteDriver` for this reason. As far as I can tell in my testing,
this has no real downsides (but perhaps I missed something?)

---

Note: it might also be worth doing the same for error.go, as I already
have two variants of the below function (one with cgo as below, and one
with... (continued)

1012 of 1895 relevant lines covered (53.4%)

785431.63 hits per line

Jobs
ID Job ID Ran Files Coverage
1 1.1 24 Mar 2015 06:23PM UTC 0
84.48
Travis Job 1.1
2 1.1 (GOTAGS=) 25 Jan 2018 06:40AM UTC 0
67.28
Travis Job 1.1
3 1.2 (GOTAGS=) 25 Jan 2018 06:40AM UTC 0
66.35
Travis Job 1.2
4 1.3 (GOTAGS=) 25 Jan 2018 06:40AM UTC 0
66.35
Travis Job 1.3
5 1.5 (GOTAGS=libsqlite3) 25 Jan 2018 06:40AM UTC 0
67.28
Travis Job 1.5
6 1.4 (GOTAGS=) 25 Jan 2018 06:43AM UTC 0
65.77
Travis Job 1.4
7 1.7 (GOTAGS=libsqlite3) 25 Jan 2018 06:43AM UTC 0
66.35
Travis Job 1.7
8 1.6 (GOTAGS=libsqlite3) 25 Jan 2018 06:44AM UTC 0
66.35
Travis Job 1.6
9 1.9 (GOTAGS=trace) 25 Jan 2018 06:44AM UTC 0
67.28
Travis Job 1.9
10 1.8 (GOTAGS=libsqlite3) 25 Jan 2018 06:46AM UTC 0
65.77
Travis Job 1.8
11 1.13 (GOTAGS=vtable) 25 Jan 2018 06:47AM UTC 0
67.28
Travis Job 1.13
12 1.11 (GOTAGS=trace) 25 Jan 2018 06:48AM UTC 0
66.35
Travis Job 1.11
13 1.10 (GOTAGS=trace) 25 Jan 2018 06:49AM UTC 0
66.35
Travis Job 1.10
14 1.14 (GOTAGS=vtable) 25 Jan 2018 06:50AM UTC 0
66.35
Travis Job 1.14
15 1.12 (GOTAGS=trace) 25 Jan 2018 06:50AM UTC 0
65.77
Travis Job 1.12
16 1.15 (GOTAGS=vtable) 25 Jan 2018 06:51AM UTC 0
66.35
Travis Job 1.15
17 1.16 (GOTAGS=vtable) 25 Jan 2018 06:54AM UTC 0
65.77
Travis Job 1.16
18 1.5 (GOTAGS=libsqlite3) 23 May 2018 11:00AM UTC 0
66.28
Travis Job 1.5
19 1.1 (GOTAGS=) 23 May 2018 11:00AM UTC 0
66.28
Travis Job 1.1
20 1.3 (GOTAGS=) 23 May 2018 11:00AM UTC 0
65.82
Travis Job 1.3
21 1.2 (GOTAGS=) 23 May 2018 11:00AM UTC 0
65.82
Travis Job 1.2
22 1.6 (GOTAGS=libsqlite3) 23 May 2018 11:03AM UTC 0
65.82
Travis Job 1.6
23 1.4 (GOTAGS=) 23 May 2018 11:03AM UTC 0
65.21
Travis Job 1.4
24 1.7 (GOTAGS=libsqlite3) 23 May 2018 11:03AM UTC 0
65.82
Travis Job 1.7
25 1.9 (GOTAGS=trace) 23 May 2018 11:03AM UTC 0
66.28
Travis Job 1.9
26 1.10 (GOTAGS=trace) 23 May 2018 11:06AM UTC 0
65.82
Travis Job 1.10
27 1.8 (GOTAGS=libsqlite3) 23 May 2018 11:06AM UTC 0
65.21
Travis Job 1.8
28 1.11 (GOTAGS=trace) 23 May 2018 11:06AM UTC 0
65.82
Travis Job 1.11
29 1.13 (GOTAGS=vtable) 23 May 2018 11:06AM UTC 0
66.28
Travis Job 1.13
30 1.12 (GOTAGS=trace) 23 May 2018 11:09AM UTC 0
65.21
Travis Job 1.12
31 1.14 (GOTAGS=vtable) 23 May 2018 11:09AM UTC 0
65.82
Travis Job 1.14
32 1.15 (GOTAGS=vtable) 23 May 2018 11:09AM UTC 0
65.82
Travis Job 1.15
33 1.16 (GOTAGS=vtable) 23 May 2018 11:12AM UTC 0
65.21
Travis Job 1.16
34 1.18 (UNIT_TESTS=true COMPILER=g++-6 BOOST_VERSION=default ENABLE_MEMCHECK=true) 23 May 2018 11:14AM UTC 0
66.28
Travis Job 1.18
35 1.17 (UNIT_TESTS=true COMPILER=g++-6 BOOST_VERSION=default ENABLE_MEMCHECK=true CFLAGS=-m32 CXXFLAGS=-m32) 23 May 2018 11:14AM UTC 0
66.28
Travis Job 1.17
36 1.19 (UNIT_TESTS=true COMPILER=g++-7 BOOST_VERSION=default ENABLE_MEMCHECK=true CFLAGS=-m32 CXXFLAGS=-m32) 23 May 2018 11:15AM UTC 0
66.28
Travis Job 1.19
37 1.20 (UNIT_TESTS=true COMPILER=g++-7 BOOST_VERSION=default ENABLE_MEMCHECK=true) 23 May 2018 11:16AM UTC 0
66.28
Travis Job 1.20
38 1.21 (UNIT_TESTS=true COMPILER=i686-w64-mingw32-gcc BOOST_VERSION=default ENABLE_MEMCHECK=true CFLAGS=-m32 CXXFLAGS=-m32) 23 May 2018 11:19AM UTC 0
66.28
Travis Job 1.21
39 1.22 (UNIT_TESTS=true COMPILER=x86_64-w64-mingw32-gcc BOOST_VERSION=default ENABLE_MEMCHECK=true) 23 May 2018 11:19AM UTC 0
66.28
Travis Job 1.22
40 1.1 (GOTAGS=) 09 Oct 2018 10:58AM UTC 0
58.45
Travis Job 1.1
41 1.2 (GOTAGS=) 09 Oct 2018 10:59AM UTC 0
58.04
Travis Job 1.2
42 1.3 (GOTAGS=) 09 Oct 2018 11:01AM UTC 0
58.04
Travis Job 1.3
43 1.5 (GOTAGS=libsqlite3) 09 Oct 2018 11:02AM UTC 0
58.04
Travis Job 1.5
44 1.7 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:03AM UTC 0
58.45
Travis Job 1.7
45 1.8 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:05AM UTC 0
58.04
Travis Job 1.8
46 1.9 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:07AM UTC 0
58.04
Travis Job 1.9
47 1.10 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:07AM UTC 0
58.45
Travis Job 1.10
48 1.4 (GOTAGS=libsqlite3) 09 Oct 2018 11:08AM UTC 0
58.45
Travis Job 1.4
49 1.11 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:09AM UTC 0
58.04
Travis Job 1.11
50 1.6 (GOTAGS=libsqlite3) 09 Oct 2018 11:10AM UTC 0
58.04
Travis Job 1.6
51 1.12 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:11AM UTC 0
58.04
Travis Job 1.12
52 1.14 (GOTAGS=) 09 Oct 2018 11:15AM UTC 0
58.04
Travis Job 1.14
53 1.13 (GOTAGS=) 09 Oct 2018 11:15AM UTC 0
58.45
Travis Job 1.13
54 1.15 (GOTAGS=) 09 Oct 2018 11:17AM UTC 0
58.04
Travis Job 1.15
55 1.16 (GOTAGS=libsqlite3) 09 Oct 2018 11:17AM UTC 0
58.45
Travis Job 1.16
56 1.17 (GOTAGS=libsqlite3) 09 Oct 2018 11:18AM UTC 0
58.04
Travis Job 1.17
57 1.18 (GOTAGS=libsqlite3) 09 Oct 2018 11:23AM UTC 0
58.04
Travis Job 1.18
58 1.19 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:24AM UTC 0
58.45
Travis Job 1.19
59 1.20 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:26AM UTC 0
58.04
Travis Job 1.20
60 1.21 (GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable") 09 Oct 2018 11:26AM UTC 0
58.04
Travis Job 1.21
61 1.22 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:27AM UTC 0
58.45
Travis Job 1.22
62 1.23 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:31AM UTC 0
58.04
Travis Job 1.23
63 1.24 (GOTAGS=sqlite_vacuum_full) 09 Oct 2018 11:33AM UTC 0
58.04
Travis Job 1.24
64 1.1 05 Jun 2020 05:35AM UTC 0
53.5
Travis Job 1.1
65 1.5 05 Jun 2020 05:35AM UTC 0
53.63
Travis Job 1.5
66 1.2 05 Jun 2020 05:36AM UTC 0
53.43
Travis Job 1.2
67 1.4 05 Jun 2020 05:36AM UTC 0
53.63
Travis Job 1.4
68 1.3 05 Jun 2020 05:36AM UTC 0
53.63
Travis Job 1.3
Source Files on build 1
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #1
  • 7181b99b on github
  • Next Build on cgo (#2)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc