Skip to content

Commit 4a90a03

Browse files
committed
Update documentation
Compile Section Closes mattn#175 Compile Section Closes mattn#201 Compile Section Closes mattn#206 Compile Section Closes mattn#404 Compile Section Closes mattn#217 Compile Section Closes mattn#224 Compile Section Closes mattn#234 Compile Section Closes mattn#242 Feature table Closes mattn#255 Description Section Closes mattn#232 Golang:1.6 not supported Closes mattn#272 Golang:1.5 not supported + compilation section Closes mattn#283 usleep Implemented Closes mattn#285 FAQ Section Closes mattn#289 Compile Section closes mattn#295 FAQ Section Closes mattn#305 PR339 Closes mattn#318 mattn#321 Compilation Section Closes mattn#341 PR407 Closes mattn#364 Feature `sqlite_vtable` Closes mattn#393 Compile Section Closes mattn#416 sqlite_trace feature Closes mattn#433 Compilation Section Closes mattn#435 Compilation Section Closes mattn#443 Golang:1.6 Not Supported Closes mattn#445 Compilation Section Closes mattn#451 Compilation Section Closes mattn#467 Compilation Section Closes mattn#491 Compilation Section Closes mattn#495 Compilation Section Closes mattn#505 Compilation Section Closes mattn#557 Compilation Section Closes mattn#560
1 parent 3526997 commit 4a90a03

File tree

1 file changed

+181
-15
lines changed

1 file changed

+181
-15
lines changed

README.md

+181-15
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,29 @@ go-sqlite3
1010

1111
sqlite3 driver conforming to the built-in database/sql interface
1212

13+
Supported Golang version:
14+
- 1.8.x
15+
- 1.9.x
16+
- 1.10.x
17+
1318
### Overview
1419

1520
- [Installation](#installation)
1621
- [API Reference](#api-reference)
1722
- [Features](#features)
23+
- [Compilation](#compilation)
24+
- [Android](#android)
25+
- [ARM](#arm)
26+
- [Cross Compile](#cross-compile)
27+
- [Docker](#docker)
28+
- [Alpine](#alpine)
29+
- [Google Cloud Platform](#google-cloud-platform)
30+
- [Linux](#linux)
31+
- [Fedora](#fedora)
32+
- [Ubuntu](#ubuntu)
33+
- [Mac OSX](#mac-osx)
34+
- [Windows](#windows)
35+
- [Errors](#errors)
1836
- [FAQ](#faq)
1937
- [License](#license)
2038

@@ -28,6 +46,8 @@ _go-sqlite3_ is *cgo* package.
2846
If you want to build your app using go-sqlite3, you need gcc.
2947
However, after you have built and installed _go-sqlite3_ with `go install github.com/mattn/go-sqlite3` (which requires gcc), you can build your app without relying on gcc in future.
3048

49+
***Important: because this is a `CGO` enabled package you are required to set the environment variable `CGO_ENABLED=1` and have a `gcc` compile present within your path.***
50+
3151
# API Reference
3252

3353
API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite3
@@ -76,23 +96,168 @@ go build --tags "icu json1 fts5 secure_delete"
7696
| Secure Delete | sqlite_secure_delete | This compile-time option changes the default setting of the secure_delete pragma.<br><br>When this option is not used, secure_delete defaults to off. When this option is present, secure_delete defaults to on.<br><br>The secure_delete setting causes deleted content to be overwritten with zeros. There is a small performance penalty since additional I/O must occur.<br><br>On the other hand, secure_delete can prevent fragments of sensitive information from lingering in unused parts of the database file after it has been deleted. See the documentation on the secure_delete pragma for additional information |
7797
| Tracing / Debug | sqlite_trace | Activate trace functions |
7898

79-
# FAQ
99+
# Compilation
100+
101+
This package requires `CGO_ENABLED=1` ennvironment variable if not set by default, and the presence of the `gcc` compiler.
102+
103+
If you need to add additional CFLAGS or LDFLAGS to the build command, and do not want to modify this package. Then this can be achieved by using the `CGO_CFLAGS` and `CGO_LDFLAGS` environment variables.
104+
105+
## Android
106+
107+
This package can be compiled for android.
108+
Compile with:
109+
110+
```bash
111+
go build --tags "android"
112+
```
113+
114+
For more information see [#201](https://github.com/mattn/go-sqlite3/issues/201)
115+
116+
# ARM
117+
118+
To compile for `ARM` use the following environment.
119+
120+
```bash
121+
env CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
122+
CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 \
123+
go build -v
124+
```
125+
126+
Additional information:
127+
- [#242](https://github.com/mattn/go-sqlite3/issues/242)
128+
- [#504](https://github.com/mattn/go-sqlite3/issues/504)
129+
130+
# Cross Compile
131+
132+
This library can be cross-compiled.
133+
134+
In some cases you are required to the `CC` environment variable with the cross compiler.
135+
136+
Additional information:
137+
- [#491](https://github.com/mattn/go-sqlite3/issues/491)
138+
- [#560](https://github.com/mattn/go-sqlite3/issues/560)
139+
140+
## Docker
141+
142+
### Alpine
143+
144+
When building in an `alpine` container run the following command before building.
145+
146+
```
147+
apk add --update gcc musl-dev
148+
```
149+
150+
# Google Cloud Platform
151+
152+
Building on GCP is not possible because `Google Cloud Platform does not allow `gcc` to be executed.
153+
154+
Please work only with compiled final binaries.
155+
156+
## Linux
157+
158+
To compile this package on Linux you must install the development tools for your linux distribution.
80159

81-
- Want to build go-sqlite3 with libsqlite3 on my linux.
160+
To compile under linux use the build tag `linux`.
82161

83-
Use `go build --tags "libsqlite3 linux"`
162+
```bash
163+
go build --tags "linux"
164+
```
165+
166+
If you wish to link directly to libsqlite3 then you can use the `libsqlite3` build tag.
167+
168+
```
169+
go build --tags "libsqlite3 linux"
170+
```
84171

85-
- Want to build go-sqlite3 with libsqlite3 on OS X.
172+
### Fedora
86173

87-
Install sqlite3 from homebrew: `brew install sqlite3`
174+
```bash
175+
sudo yum groupinstall "Development Tools" "Development Libraries"
176+
```
177+
178+
### Ubuntu
179+
180+
```bash
181+
sudo apt-get install build-essential
182+
```
183+
184+
## Mac OSX
185+
186+
OSX should have all the tools present to compile this package, if not install XCode this will add all the developers tools.
187+
188+
Required dependency
189+
190+
```bash
191+
brew install sqlite3
192+
```
88193

89-
Use `go build --tags "libsqlite3 darwin"`
194+
For OSX there is an additional package install which is required if you whish to build the `icu` extension.
195+
196+
This additional package can be installed with `homebrew`.
197+
198+
```bash
199+
brew upgrade icu4c
200+
```
201+
202+
To compile for Mac OSX.
203+
204+
```bash
205+
go build --tags "darwin"
206+
```
207+
208+
If you wish to link directly to libsqlite3 then you can use the `libsqlite3` build tag.
209+
210+
```
211+
go build --tags "libsqlite3 darwin"
212+
```
213+
214+
Additional information:
215+
- [#206](https://github.com/mattn/go-sqlite3/issues/206)
216+
- [#404](https://github.com/mattn/go-sqlite3/issues/404)
217+
218+
## Windows
219+
220+
To compile this package on Windows OS you must have the `gcc` compiler installed.
221+
222+
1) Install a Windows `gcc` toolchain.
223+
2) Add the `bin` folders to the Windows path if the installer did not do this by default.
224+
3) Open a terminal for the TDM-GCC toolchain, can be found in the Windows Start menu.
225+
4) Navigate to your project folder and run the `go build ...` command for this package.
226+
227+
For example the TDM-GCC Toolchain can be found [here](ttps://sourceforge.net/projects/tdm-gcc/).
228+
229+
## Errors
230+
231+
- Compile error: `can not be used when making a shared object; recompile with -fPIC`
232+
233+
When receiving a compile time error referencing recompile with `-FPIC` then you
234+
are probably using a hardend system.
235+
236+
You can copile the library on a hardend system with the following command.
237+
238+
```bash
239+
go build -ldflags '-extldflags=-fno-PIC'
240+
```
241+
242+
More details see [#120](https://github.com/mattn/go-sqlite3/issues/120)
90243

91244
- Can't build go-sqlite3 on windows 64bit.
92245
93246
> Probably, you are using go 1.0, go1.0 has a problem when it comes to compiling/linking on windows 64bit.
94247
> See: [#27](https://github.com/mattn/go-sqlite3/issues/27)
95248
249+
- `go get github.com/mattn/go-sqlite3` throws compilation error.
250+
251+
`gcc` throws: `internal compiler error`
252+
253+
Remove the download repository from your disk and try re-install with:
254+
255+
```bash
256+
go install github.com/mattn/go-sqlite3
257+
```
258+
259+
# FAQ
260+
96261
- Getting insert error while query is opened.
97262
98263
> You can pass some arguments into the connection string, for example, a URI.
@@ -120,19 +285,20 @@ go build --tags "icu json1 fts5 secure_delete"
120285
connection to this string will point to the same in-memory database. See
121286
[#204](https://github.com/mattn/go-sqlite3/issues/204) for more info.
122287
123-
- Compile error: `can not be used when making a shared object; recompile with -fPIC`
288+
- Reading from database with large amount of goroutines fails on OSX.
124289
125-
When receiving a compile time error referencing recompile with `-FPIC` then you
126-
are probably using a hardend system.
290+
OS X limits OS-wide to not have more than 1000 files open simultaneously by default.
127291
128-
You can copile the library on a hardend system with the following command.
292+
For more information see [#289](https://github.com/mattn/go-sqlite3/issues/289)
129293
130-
```bash
131-
go build -ldflags '-extldflags=-fno-PIC'
132-
```
294+
- Trying to execure a `.` (dot) command throws an error.
133295
134-
More details see [#120](https://github.com/mattn/go-sqlite3/issues/120)
135-
296+
Error: `Error: near ".": syntax error`
297+
Dot command are part of SQLite3 CLI not of this library.
298+
299+
You need to implement the feature or call the sqlite3 cli.
300+
301+
More infomation see [#305](https://github.com/mattn/go-sqlite3/issues/305)
136302
137303
# License
138304

0 commit comments

Comments
 (0)