Skip to content

Commit fdde2ab

Browse files
authored
Merge pull request go-jet#42 from go-jet/develop
Add support for go.mod (v2.4.0)
2 parents fdeef56 + 5881b5d commit fdde2ab

File tree

104 files changed

+275
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+275
-231
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
[![codecov](https://codecov.io/gh/go-jet/jet/branch/master/graph/badge.svg)](https://codecov.io/gh/go-jet/jet)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/go-jet/jet)](https://goreportcard.com/report/github.com/go-jet/jet)
66
[![Documentation](https://godoc.org/github.com/go-jet/jet?status.svg)](http://godoc.org/github.com/go-jet/jet)
7-
[![GitHub release](https://img.shields.io/github/release/go-jet/jet.svg)](https://github.com/go-jet/jet/releases)
7+
[![GitHub release](https://img.shields.io/github/release/go-jet/jet.svg)](https://github.com/go-jet/jet/v2/releases)
88
[![Gitter](https://badges.gitter.im/go-jet/community.svg)](https://gitter.im/go-jet/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
99

10-
Jet is a framework for writing type-safe SQL queries in Go, with ability to easily
11-
convert database query result into desired arbitrary object structure.
10+
Jet is a complete solution for efficient and high performance database access, consisting of type-safe SQL builder
11+
with code generation and automatic query result data mapping.
1212
Jet currently supports `PostgreSQL`, `MySQL` and `MariaDB`. Future releases will add support for additional databases.
1313

1414
![jet](https://github.com/go-jet/jet/wiki/image/jet.png)
15-
Jet is the easiest and the fastest way to write complex SQL queries and map database query result
15+
Jet is the easiest and the fastest way to write complex type-safe SQL queries as a Go code and map database query result
1616
into complex object composition. __It is not an ORM.__
1717

1818
## Motivation
@@ -58,22 +58,28 @@ https://medium.com/@go.jet/jet-5f3667efa0cc
5858

5959
To install Jet package, you need to install Go and set your Go workspace first.
6060

61-
[Go](https://golang.org/) **version 1.8+ is required**
61+
[Go](https://golang.org/) **version 1.9+ is required**
6262

6363
### Installation
6464

65-
Use the bellow command to install jet
65+
Use the bellow command to add jet as a dependency into `go.mod` project:
66+
```sh
67+
$ go get -u github.com/go-jet/jet/v2
68+
```
69+
70+
Use the bellow command to add jet as a dependency into `GOPATH` project:
71+
6672
```sh
6773
$ go get -u github.com/go-jet/jet
6874
```
6975

7076
Install jet generator to GOPATH bin folder. This will allow generating jet files from the command line.
7177

7278
```sh
73-
go install github.com/go-jet/jet/cmd/jet
79+
cd $GOPATH/src/ && GO111MODULE=off go get -u github.com/go-jet/jet/cmd/jet
7480
```
7581

76-
Make sure GOPATH bin folder is added to the PATH environment variable.
82+
*Make sure GOPATH bin folder is added to the PATH environment variable.*
7783

7884
### Quick Start
7985
For this quick start example we will use PostgreSQL sample _'dvd rental'_ database. Full database dump can be found in [./tests/testdata/init/postgres/dvds.sql](./tests/testdata/init/postgres/dvds.sql).
@@ -85,7 +91,7 @@ connection parameters and root destination folder path for generated files.\
8591
Assuming we are running local postgres database, with user `jetuser`, user password `jetpass`, database `jetdb` and
8692
schema `dvds` we will use this command:
8793
```sh
88-
jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=./gen
94+
jet -source=PostgreSQL -host=localhost -port=5432 -user=jetuser -password=jetpass -dbname=jetdb -schema=dvds -path=./.gen
8995
```
9096
```sh
9197
Connecting to postgres database: host=localhost port=5432 user=jetuser password=jetpass dbname=jetdb sslmode=disable
@@ -144,10 +150,10 @@ First we need to import jet and generated files from previous step:
144150
import (
145151
// dot import so go code would resemble as much as native SQL
146152
// dot import is not mandatory
147-
. "github.com/go-jet/jet/examples/quick-start/.gen/jetdb/dvds/table"
148-
. "github.com/go-jet/jet/postgres"
153+
. "github.com/go-jet/jet/v2/examples/quick-start/.gen/jetdb/dvds/table"
154+
. "github.com/go-jet/jet/v2/postgres"
149155

150-
"github.com/go-jet/jet/examples/quick-start/gen/jetdb/dvds/model"
156+
"github.com/go-jet/jet/v2/examples/quick-start/gen/jetdb/dvds/model"
151157
)
152158
```
153159
Lets say we want to retrieve the list of all _actors_ that acted in _films_ longer than 180 minutes, _film language_ is 'English'

cmd/jet/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
mysqlgen "github.com/go-jet/jet/generator/mysql"
7-
postgresgen "github.com/go-jet/jet/generator/postgres"
8-
"github.com/go-jet/jet/mysql"
9-
"github.com/go-jet/jet/postgres"
6+
mysqlgen "github.com/go-jet/jet/v2/generator/mysql"
7+
postgresgen "github.com/go-jet/jet/v2/generator/postgres"
8+
"github.com/go-jet/jet/v2/mysql"
9+
"github.com/go-jet/jet/v2/postgres"
1010
_ "github.com/go-sql-driver/mysql"
1111
_ "github.com/lib/pq"
1212
"os"

doc.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ result into desired arbitrary object structure.
66
Installation
77
88
9-
Use the bellow command to install jet
9+
Use the bellow command to add jet as a dependency into go.mod project:
10+
$ go get github.com/go-jet/jet/v2
11+
12+
Use the bellow command to add jet as a dependency into GOPATH project:
1013
$ go get -u github.com/go-jet/jet
1114
1215
Install jet generator to GOPATH bin folder. This will allow generating jet files from the command line.
13-
go install github.com/go-jet/jet/cmd/jet
16+
cd $GOPATH/src/ && GO111MODULE=off go get -u github.com/go-jet/jet/cmd/jet
1417
15-
*Make sure GOPATH bin folder is added to the PATH environment variable.
18+
Make sure GOPATH bin folder is added to the PATH environment variable.
1619
1720
Usage
1821
@@ -26,10 +29,10 @@ Then next step is to import generated SQL Builder and Model files and write SQL
2629
import "some_path/.gen/jetdb/dvds/model"
2730
2831
To write SQL queries for PostgreSQL import:
29-
. "github.com/go-jet/jet/postgres"
32+
. "github.com/go-jet/jet/v2/postgres"
3033
3134
To write SQL queries for MySQL and MariaDB import:
32-
. "github.com/go-jet/jet/mysql"
35+
. "github.com/go-jet/jet/v2/mysql"
3336
*Dot import is used so that Go code resemble as much as native SQL. Dot import is not mandatory.
3437
3538
Write SQL:

examples/quick-start/.gen/jetdb/dvds/enum/mpaa_rating.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/actor.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/category.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/film.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/film_actor.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/film_category.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/quick-start/.gen/jetdb/dvds/table/language.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)