aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJan Mercl <0xjnml@gmail.com>2019-12-27 12:24:40 +0100
committerJan Mercl <0xjnml@gmail.com>2019-12-27 12:24:40 +0100
commitcab95cbf041c29cf5c041cbbc597baffaaf2c6a4 (patch)
treea1f22008acec855c0a619e1a491ff3363e098db0 /examples
parent6efd3c70006496181ffdf7397f8181c1b49895d8 (diff)
add aplha.2 compatible example for module mode
Diffstat (limited to 'examples')
-rw-r--r--examples/example1/README0
-rw-r--r--examples/example1/go.mod5
-rw-r--r--examples/example1/go.sum15
-rw-r--r--examples/example1/main.go50
4 files changed, 70 insertions, 0 deletions
diff --git a/examples/example1/README b/examples/example1/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/example1/README
diff --git a/examples/example1/go.mod b/examples/example1/go.mod
new file mode 100644
index 0000000..3c222ff
--- /dev/null
+++ b/examples/example1/go.mod
@@ -0,0 +1,5 @@
+module modernc.org/example
+
+require modernc.org/sqlite v1.1.0-alpha.2
+
+go 1.13
diff --git a/examples/example1/go.sum b/examples/example1/go.sum
new file mode 100644
index 0000000..13b3fcc
--- /dev/null
+++ b/examples/example1/go.sum
@@ -0,0 +1,15 @@
+github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
+github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
+github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446 h1:/NRJ5vAYoqz+7sG51ubIDHXeWO8DlTSrToPu6q11ziA=
+github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191218084908-4a24b4065292 h1:Y8q0zsdcgAd+JU8VUA8p8Qv2YhuY9zevDG2ORt5qBUI=
+golang.org/x/sys v0.0.0-20191218084908-4a24b4065292/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+modernc.org/crt/v2 v2.0.0-alpha.2 h1:/wq0trAb7RTvnqSs02z8avn3UMkRa3iFpfKV05KflGk=
+modernc.org/crt/v2 v2.0.0-alpha.2/go.mod h1:K7tDS2XDAsVcX1puL+MEnzy8/E2kUh1GgV57DLtCNgg=
+modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=
+modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
+modernc.org/memory v1.0.0 h1:Tm1p6vBp/U/SGR9/EeFhMvGzaVpUWeePopZhhIpW2YE=
+modernc.org/memory v1.0.0/go.mod h1:TXr4iJDvK3g0hW+sV+Kohu7BoeHfqw7QEFZWkBExdZc=
+modernc.org/sqlite v1.1.0-alpha.2 h1:RblbzNUI33g8HNZTBqq7HuVzxG6dKglMrlZB5W+Ol8c=
+modernc.org/sqlite v1.1.0-alpha.2/go.mod h1:Lk3NI8z9NDHeje1nJTFbmOgL+w9Hzay5vEuMbzOs/+0=
diff --git a/examples/example1/main.go b/examples/example1/main.go
new file mode 100644
index 0000000..70bfa9b
--- /dev/null
+++ b/examples/example1/main.go
@@ -0,0 +1,50 @@
+package main
+
+import (
+ "database/sql"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ _ "modernc.org/sqlite"
+)
+
+func main() {
+ if err := main1(); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+}
+
+func main1() error {
+ dir, err := ioutil.TempDir("", "test-")
+ if err != nil {
+ return err
+ }
+
+ defer os.RemoveAll(dir)
+
+ fn := filepath.Join(dir, "db")
+
+ db, err := sql.Open("sqlite", fn)
+ if err != nil {
+ return err
+ }
+
+ if _, err := db.Exec("create table if not exists t(i);"); err != nil {
+ return err
+ }
+
+ if err := db.Close(); err != nil {
+ return err
+ }
+
+ fi, err := os.Stat(fn)
+ if err != nil {
+ return err
+ }
+
+ fmt.Printf("%s size: %v\n", fn, fi.Size())
+ return nil
+}