Skip to content

Commit 6bfb60f

Browse files
authored
Update the Go driver documentation, Linux installer, and CI (#1527) (#1556)
Updated the Go driver documentation, Linux installer, and Github CI file. The documentation needed to clarify what was needed. The installer needed to be fixed. The CI file needed to have the updated Go versions. The driver installation for Linux will no longer install Java, Golang, or ANTLR for the user. This is left to the users system administrator. Instead, it will validate the current installation of those components, then build and install the driver. Also updated - modified: drivers/golang/go.mod modified: drivers/golang/go.sum
1 parent d14fe8c commit 6bfb60f

File tree

6 files changed

+149
-135
lines changed

6 files changed

+149
-135
lines changed

.github/workflows/go-driver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
go-version: [ '1.18', '1.19' ]
15+
go-version: [ '1.20', '1.21' ]
1616

1717
defaults:
1818
run:

drivers/golang/README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,66 @@
1-
# age AGType parser and driver support for Golang
1+
# age AGType parser and driver support for Golang
22

33
AGType parser and driver support for [Apache AGE](https://age.apache.org/), graph extension for PostgreSQL.
44

55
### Features
66
* Unmarshal AGE result data(AGType) to Vertex, Edge, Path
77
* Cypher query support for 3rd. Party sql driver (enables to use cypher queries directly)
88

9-
### Prerequisites
10-
* over Go 1.18 / 1.19
11-
* This module runs on golang standard api [database/sql](https://golang.org/pkg/database/sql/) and [antlr4-python3](https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr)
9+
### Prerequisites (Required)
10+
* Java 11, or greater, installed.
11+
* Go 1.18, or greater, installed.
12+
* This module runs on the golang standard api [database/sql](https://golang.org/pkg/database/sql/) and [antlr4-python3](https://github.com/antlr/antlr4/tree/master/runtime/Go/antlr)
13+
* ANTLR 4.11.1, or greater, installed.
1214

1315
### Installation (From source)
1416
Run (Windows): install.bat
1517
Run (Linux & OSX):
1618
```
17-
sh install.sh
19+
cd age/drivers/golang
20+
./install.sh
1821
```
1922

20-
### Go get
21-
```
23+
### Go get
24+
```
2225
go get github.com/apache/age/drivers/golang
2326
```
2427
### gomod
25-
```
28+
```
2629
require github.com/apache/age/drivers/golang {version}
2730
```
2831

29-
3032
Check [latest version](https://github.com/apache/age/releases)
3133

3234
### For more information about [Apache AGE](https://age.apache.org/)
3335
* Apache Age : https://age.apache.org/
3436
* GitHub : https://github.com/apache/age
3537
* Document : https://age.apache.org/docs/
3638

37-
### Check AGE loaded on your PostgreSQL
39+
### Check that Apache AGE is loaded on your PostgreSQL database
3840
Connect to your containerized Postgres instance and then run the following commands:
3941
```(sql)
40-
# psql
42+
# psql
4143
CREATE EXTENSION age;
4244
LOAD 'age';
4345
SET search_path = ag_catalog, "$user", public;
4446
```
4547

4648
### Test
47-
Check out and rewrite DSN in age/drivers/golang/age/age_test.go
49+
For the tests to work, please make sure the following has been done.
50+
* The driver has been successfully installed following the instructions above.
51+
* Make sure the database you will run tests against has Apache AGE installed.
52+
* Make sure to modify the DSN value in age/drivers/golang/age/age_test.go
53+
* Make sure the DSN has the correct database and connect string.
54+
* Make sure the database has a graph called testGraph created.
55+
4856
```
4957
cd age/drivers/golang/age
5058
go test . -v
5159
5260
```
5361

5462
### Samples
55-
* Usage 1: using database/sql API and Cypher execution function 'ExecCypher'
63+
* Usage 1: using database/sql API and Cypher execution function 'ExecCypher'
5664
Sample : [samples/sql_api_sample.go](samples/sql_api_sample.go)
5765

5866
* Usage 2: using Age Wrapper

drivers/golang/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ go 1.19
2323

2424
require (
2525
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1
26-
github.com/lib/pq v1.10.7
26+
github.com/lib/pq v1.10.9
2727
github.com/stretchr/testify v1.7.0
2828
)
2929

3030
require (
3131
github.com/davecgh/go-spew v1.1.0 // indirect
3232
github.com/pmezard/go-difflib v1.0.0 // indirect
33-
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
33+
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
3434
gopkg.in/yaml.v3 v3.0.0 // indirect
3535
)

drivers/golang/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
44
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
66
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
7+
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
8+
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
79
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
810
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
911
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1012
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
1113
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1214
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
1315
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
16+
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
17+
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
1418
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1519
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1620
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

drivers/golang/install.sh

Lines changed: 118 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,140 @@
11
#!/bin/sh
22

3+
# get OS
34
os=$(uname)
5+
6+
# get architecture
47
arch=$(uname -m)
58

6-
java=$(java -version 2>&1 | head -n 1 | cut -d ' ' -f 3 | cut -d '.' -f 1 | cut -d '"' -f 2)
7-
# Check JDK version
8-
echo "Checking for JDK..."
9-
if ! java -version >/dev/null 2>&1 || [ $java -lt 11 ]; then
10-
echo "JDK not found or less than version 11, would you like to install? ()"
11-
echo "Y/N ->"
12-
read answer
13-
if [ "$answer" = y ] || [ "$answer" = Y ]; then
14-
echo "Installing..."
15-
if [[ "$os" == "Darwin" ]]; then
16-
cd /tmp
17-
if [[ "$arch" == "x86_64" ]]; then
18-
curl "https://download.oracle.com/java/20/latest/jdk-20_macos-x64_bin.dmg" -o jdk-20_bin.dmg
19-
elif [[ "$arch" == "arm64" ]]; then
20-
curl "https://download.oracle.com/java/20/latest/jdk-20_macos-aarch64_bin.dmg" -o jdk-20_bin.dmg
21-
fi
22-
hdiutil mount jdk-20_bin.dmg
23-
# sudo installer -pkg "/Volumes/JDK 20/JDK 20.pkg" -target "/"
24-
sudo open -w "/Volumes/JDK 20/JDK 20.pkg"
25-
hdiutil unmount "/Volumes/JDK 20"
26-
rm jdk-20_bin.dmg
27-
28-
elif [[ "$os" == "Linux" ]]; then
29-
mkdir -p ~/tmp/jdk20
30-
cd ~/tmp/jdk20
31-
if [[ "$arch" == "x86_64" ]]; then
32-
curl "https://download.oracle.com/java/20/latest/jdk-20_linux-x64_bin.tar.gz" -o jdk-20_bin.tar.gz
33-
elif [[ "$arch" == "arm64" ]]; then
34-
curl "https://download.oracle.com/java/20/latest/jdk-20_linux-aarch64_bin.tar.gz" -o jdk-20_bin.tar.gz
35-
fi
36-
sudo tar zxvf jdk-20_bin.tar.gz -C /usr/local/
37-
cd ~/
38-
rm -rf ~/tmp/jdk20/
39-
fi
40-
echo "JDK installation complete."
41-
else
42-
echo "Please install JDK >= 11.0.16"
43-
exit 0
44-
fi
9+
# Check Java installation
10+
echo "Checking for minimum Java installation..."
11+
12+
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
13+
14+
if [ ! -z $java_version ]; then
15+
echo "Java version $java_version"
4516
else
46-
echo "JDK already installed."
17+
echo "Java not found. Please install Java."
4718
fi
4819

49-
antlr=$(/usr/local/jdk-20/bin/jar xf /usr/local/antlr/antlr-*-complete.jar META-INF/MANIFEST.MF >/dev/null 2>&1 && grep 'Implementation-Version' META-INF/MANIFEST.MF | cut -d ' ' -f 2 && rm -rf META-INF)
50-
# Check ANTLR installation and version
51-
echo "Checking for ANTLR..."
52-
check_antlr () {
53-
if [ ! -z $antlr ]; then
54-
if ([ "$(echo $antlr | cut -d '.' -f 1)" -lt 4 ] && [ "$(echo $antlr | cut -d '.' -f 2)" -lt 11 ] && [ "$(echo $antlr | cut -d '.' -f 3)" -lt 1 ]); then
55-
return 0
56-
else
57-
return 1
58-
fi
59-
else
60-
return 0
61-
fi
62-
}
63-
64-
if check_antlr; then
65-
echo "ANTLR not found in Default Location or less than version 4.11.1, would you like to Install?"
66-
echo "(If installed in other location, please edit the location inside the shell script before running)"
67-
echo "Y/N ->"
68-
read answer
69-
if [ "$answer" = y ] || [ "$answer" = Y ]; then
70-
mkdir -p ~/tmp/antlr4.11.1
71-
cd ~/tmp/antlr4.11.1
72-
curl -LO "https://www.antlr.org/download/antlr-4.11.1-complete.jar"
73-
sudo mkdir -p /usr/local/antlr
74-
sudo mv ~/tmp/antlr4.11.1/antlr-4.11.1-complete.jar /usr/local/antlr/antlr-4.11.1-complete.jar
75-
76-
echo 'export CLASSPATH=".:/usr/local/antlr/antlr-4.11.1-complete.jar"' >>~/.bashrc
77-
. ~/.bashrc
78-
echo "ANTLR installation complete."
79-
else
80-
echo "Please install ANTLR >= 4.11.1"
81-
exit 0
82-
fi
83-
#
20+
# Get Java version
21+
java_major=$(echo $java_version | cut -d '.' -f1)
22+
java_minor=$(echo $java_version | cut -d '.' -f2)
23+
java_patch=$(echo $java_version | cut -d '.' -f3)
24+
25+
# Check Java version
26+
java_version_flag=0
27+
if [ $java_major -lt 11 ]; then
28+
java_version_flag=0
29+
elif [ $java_minor -lt 0 ]; then
30+
java_version_flag=0
31+
elif [ $java_patch -lt 0 ]; then
32+
java_version_flag=0
8433
else
85-
echo "ANTLR already installed."
34+
java_version_flag=1
8635
fi
8736

88-
# Check Go installation and version
89-
echo "Checking for Go..."
90-
if ! command -v go >/dev/null 2>&1 || { [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 1) -lt 1 ] && [ $(go version | grep -o -E '[0-9]+\.[0-9]+' | head -n 1 | cut -d '.' -f 2) -lt 19 ]; }; then
91-
echo "Go not installed or version is less than 1.19, would you like to install?"
92-
echo "Y/N ->"
93-
read answer
94-
if [ "$answer" = y ] || [ "$answer" = Y ]; then
95-
if [[ "$os" == "Darwin" ]]; then
96-
cd /tmp
97-
if [[ "$arch" == "x86_64" ]]; then
98-
curl "https://go.dev/dl/go1.20.2.darwin-amd64.pkg" -o go1.20.2.pkg
99-
elif [[ "$arch" == "arm64" ]]; then
100-
curl "https://go.dev/dl/go1.20.2.darwin-arm64.pkg" -o go1.20.2.pkg
101-
fi
102-
103-
#sudo installer -pkg "go1.20.2.pkg" -target "/"
104-
sudo open -w golang.pkg
105-
106-
elif [[ "$os" == "Linux" ]]; then
107-
mkdir -p ~/tmp/go1.20.2
108-
cd ~/tmp/go1.20.2
109-
if [[ "$arch" == "x86_64" ]]; then
110-
curl "https://go.dev/dl/go1.20.2.linux-amd64.tar.gz" -o go1.20.2.tar.gz
111-
elif [[ "$arch" == "arm64" ]]; then
112-
curl "https://go.dev/dl/go1.20.2.linux-arm64.tar.gz" -o go1.20.2.tar.gz
113-
fi
114-
115-
if command -v go >/dev/null 2>&1; then
116-
rm -rf /usr/local/go
117-
fi
118-
sudo tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz
119-
120-
if ! [[ ":$PATH:" == *":/usr/local/go/bin:"* ]]; then
121-
export PATH=$PATH:/usr/local/go/bin
122-
fi
123-
fi
124-
echo "Go installation complete"
125-
else
126-
echo "Please install Go >= 1.19"
127-
exit 0
128-
fi
37+
if [ $java_version_flag -eq 0 ]; then
38+
echo "Java version less than 11.0.0"
39+
echo "NOTE: If a newer version of Java is installed, but not set as "
40+
echo " the current version, exit and select it before continuing."
41+
exit 0
12942
else
130-
echo "Go already installed."
43+
echo "Java is installed."
44+
echo ""
13145
fi
13246

47+
# Check ANTLR installation
48+
echo "Checking for minimum ANTLR installation..."
49+
jar xf /usr/local/antlr/antlr-*-complete.jar META-INF/MANIFEST.MF >/dev/null 2>&1
50+
antlr_version=$(grep 'Implementation-Version' META-INF/MANIFEST.MF | cut -d ' ' -f 2)
51+
rm -rf META-INF
13352

53+
if [ ! -z $antlr_version ]; then
54+
echo "ANTLR version $antlr_version"
55+
else
56+
echo "ANTLR not found. Please install ANTLR."
57+
exit 0
58+
fi
13459

60+
# Check ANTLR version
61+
antlr_version_flag=0
62+
antlr_major=$(echo $antlr_version | cut -d '.' -f 1)
63+
antlr_minor=$(echo $antlr_version | cut -d '.' -f 2)
64+
antlr_patch=$(echo $antlr_version | cut -d '.' -f 3 | sed 's/\r//')
65+
66+
if [ $antlr_major -lt 4 ]; then
67+
antlr_version_flag=0
68+
elif [ $antlr_minor -lt 11 ]; then
69+
antlr_version_flag=0
70+
elif [ $antlr_patch -lt 1 ]; then
71+
antlr_version_flag=0
72+
else
73+
antlr_version_flag=1
74+
fi
75+
76+
if [ $antlr_version_flag -eq 0 ]; then
77+
echo "ANTLR version less than 4.11.1"
78+
exit 0
79+
else
80+
echo "ANTLR is installed."
81+
echo ""
82+
fi
83+
84+
# Check Go installation
85+
echo "Checking for minimum Golang installation..."
86+
go_version=$(go version 2>&1 | cut -d' ' -f3)
87+
88+
if [ ! -z $go_version ]; then
89+
echo "Golang version $go_version"
90+
else
91+
echo "Golang not found. Please install Golang."
92+
exit 0
93+
fi
94+
95+
# Check Go version
96+
go_version_flag=0
97+
go_major=$(echo $go_version | cut -d '.' -f1 | cut -d 'o' -f 2)
98+
go_minor=$(echo $go_version | cut -d '.' -f2)
99+
go_patch=$(echo $go_version | cut -d '.' -f3)
100+
101+
if [ $go_major -lt 1 ]; then
102+
go_version_flag=0
103+
elif [ $go_minor -lt 18 ]; then
104+
go_version_flag=0
105+
elif [ $go_patch -lt 0 ]; then
106+
go_version_flag=0
107+
else
108+
go_version_flag=1
109+
fi
110+
111+
if [ $go_version_flag -eq 0 ]; then
112+
echo "Golang version less than 1.19.0"
113+
exit 0
114+
else
115+
echo "Golang is installed."
116+
echo ""
117+
fi
118+
119+
# Check CLASSPATH
120+
echo "Checking for ANTLR in CLASSPATH..."
121+
test_classpath=$(echo $CLASSPATH | grep antlr)
122+
123+
if [ ! -z $test_classpath ]; then
124+
echo "CLASSPATH = $CLASSPATH"
125+
echo ""
126+
else
127+
echo "ANTLR not set in CLASSPATH. Please set up CLASSPATH."
128+
exit 0
129+
fi
130+
131+
# Generate Parser and Lexer
135132
echo "Generating Parser & Lexer..."
136-
java -Xmx500M -cp "/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool -Dlanguage=Go -visitor Age.g4
133+
java -Xmx500M org.antlr.v4.Tool -Dlanguage=Go -visitor parser/Age.g4
137134

135+
# Install Golang driver
138136
echo "Installing Driver..."
139137
go get -u ./...
138+
140139
echo "Successfully Installed Driver!"
141140
exit 0

drivers/golang/parser/generate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/sh
2+
#
3+
# Please be aware that this is used by the CI scripts
4+
#
25
GRAMMAR_LOC="$(dirname $(pwd))/parser"
36

47
mkdir -p ~/tmp/antlr

0 commit comments

Comments
 (0)