From 8c3f576a223dbb718d68deaad7306820c5da58b7 Mon Sep 17 00:00:00 2001 From: Nelson-He Date: Sun, 29 May 2022 20:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E4=BF=AE=E6=94=B9README?= =?UTF-8?q?=E9=83=A8=E5=88=86=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=BA=90=E7=A0=81?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=BB=8B=E7=BB=8D=EF=BC=9B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?Makefile=E5=92=8C=E5=8C=85=E5=90=8D=EF=BC=8C=E4=BD=BF=E5=BE=97?= =?UTF-8?q?=E6=89=93=E5=8C=85=E7=9A=84=E7=BB=93=E6=9E=9C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=BAopenGauss-webclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 20 ++++++------- README.md | 36 ++++++++++++++++++++---- go.mod | 2 +- main.go | 2 +- pkg/api/api.go | 12 ++++---- pkg/api/helpers.go | 2 +- pkg/api/middleware.go | 2 +- pkg/api/routes.go | 2 +- pkg/api/session_cleanup.go | 2 +- pkg/bookmarks/bookmarks.go | 4 +-- pkg/cli/cli.go | 14 ++++----- pkg/client/client.go | 10 +++---- pkg/client/client_test.go | 2 +- pkg/client/result.go | 2 +- pkg/client/tunnel.go | 4 +-- pkg/connection/connection_string.go | 2 +- pkg/connection/connection_string_test.go | 2 +- 17 files changed, 72 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index a5323a7..3c39f0b 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ TARGETS = darwin/amd64 darwin/arm64 linux/amd64 linux/386 windows/amd64 windows/ GIT_COMMIT = $(shell git rev-parse HEAD) BUILD_TIME = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n') GO_VERSION = $(shell go version | awk {'print $$3'}) -DOCKER_RELEASE_TAG = "sosedoff/pgweb:$(shell git describe --abbrev=0 --tags | sed 's/v//')" -DOCKER_LATEST_TAG = "sosedoff/pgweb:latest" +DOCKER_RELEASE_TAG = "sosedoff/openGauss-webclient:$(shell git describe --abbrev=0 --tags | sed 's/v//')" +DOCKER_LATEST_TAG = "sosedoff/openGauss-webclient:latest" LDFLAGS = -s -w -PKG = github.com/sosedoff/pgweb +PKG = github.com/sosedoff/openGauss-webclient usage: @echo "" @@ -33,11 +33,11 @@ test-all: dev: go build - @echo "You can now execute ./pgweb" + @echo "You can now execute ./openGauss-webclient" build: go build - @echo "You can now execute ./pgweb" + @echo "You can now execute ./openGauss-webclient" release: LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT) release: LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME) @@ -47,13 +47,13 @@ release: @gox \ -osarch "$(TARGETS)" \ -ldflags "$(LDFLAGS)" \ - -output "./bin/pgweb_{{.OS}}_{{.Arch}}" + -output "./bin/openGauss-webclient_{{.OS}}_{{.Arch}}" @echo "Building ARM binaries..." - GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "$(LDFLAGS)" -o "./bin/pgweb_linux_arm_v5" + GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "$(LDFLAGS)" -o "./bin/openGauss-webclient_linux_arm_v5" @echo "Building ARM64 binaries..." - GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags "$(LDFLAGS)" -o "./bin/pgweb_linux_arm64_v7" + GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags "$(LDFLAGS)" -o "./bin/openGauss-webclient_linux_arm64_v7" @echo "\nPackaging binaries...\n" @./script/package.sh @@ -65,11 +65,11 @@ setup: go install github.com/mitchellh/gox@v1.0.1 clean: - @rm -f ./pgweb + @rm -f ./openGauss-webclient* @rm -rf ./bin/* docker: - docker build --no-cache -t pgweb . + docker build --no-cache -t openGauss-webclient . docker-release: docker build --no-cache -t $(DOCKER_RELEASE_TAG) . diff --git a/README.md b/README.md index cad9b37..4088604 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Web-based openGauss database browser written in Go. ## Overview -Pgweb is a web-based database browser for PostgreSQL, written in Go and works +openGauss-webclient is a web-based database browser for openGauss, written in Go and works on OSX, Linux and Windows machines. Main idea behind using Go for backend development is to utilize ability of the compiler to produce zero-dependency binaries for -multiple platforms. Pgweb was created as an attempt to build very simple and portable -application to work with local or remote PostgreSQL databases. +multiple platforms. openGauss-webclient was created as an attempt to build very simple and portable +application to work with local or remote openGauss databases. ## Features @@ -62,11 +62,35 @@ SESSIONS=1 openGauss-webclient ``` +## Build from source + +Go 1.7 is required. You can install Go with honebrew: + +``` +brew install go +``` + +To compile source code run the following command: +``` +make setup +make dev +``` + +This will produce openGauss-webclient binary in the current directory. + +There's also a task to compile banaries for other operating system: +``` +make release +``` + +Under the hood it uses gox. Compiled binaries will be stored into ./bin directory. + + ## Testing -Before running tests, make sure you have PostgreSQL server running on `localhost:5432` +Before running tests, make sure you have openGauss server running on `localhost:5432` interface. Also, you must have `postgres` user that could create new databases -in your local environment. Pgweb server should not be running at the same time. +in your local environment. openGauss-webclient server should not be running at the same time. Execute test suite: @@ -75,7 +99,7 @@ make test ``` If you're using Docker locally, you might also run pgweb test suite against -all supported PostgreSQL version with a single command: +all supported openGauss version with a single command: ``` make test-all diff --git a/go.mod b/go.mod index 7902c73..e0a8af1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/sosedoff/pgweb +module github.com/sosedoff/openGauss-webclient go 1.17 diff --git a/main.go b/main.go index 272bec1..955c719 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/sosedoff/pgweb/pkg/cli" + "github.com/sosedoff/openGauss-webclient/pkg/cli" ) func main() { diff --git a/pkg/api/api.go b/pkg/api/api.go index c951727..ee0e455 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -13,12 +13,12 @@ import ( "github.com/gin-gonic/gin" "github.com/tuvistavie/securerandom" - "github.com/sosedoff/pgweb/pkg/bookmarks" - "github.com/sosedoff/pgweb/pkg/client" - "github.com/sosedoff/pgweb/pkg/command" - "github.com/sosedoff/pgweb/pkg/connection" - "github.com/sosedoff/pgweb/pkg/shared" - "github.com/sosedoff/pgweb/static" + "github.com/sosedoff/openGauss-webclient/pkg/bookmarks" + "github.com/sosedoff/openGauss-webclient/pkg/client" + "github.com/sosedoff/openGauss-webclient/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/connection" + "github.com/sosedoff/openGauss-webclient/pkg/shared" + "github.com/sosedoff/openGauss-webclient/static" ) var ( diff --git a/pkg/api/helpers.go b/pkg/api/helpers.go index f56093a..46516e6 100644 --- a/pkg/api/helpers.go +++ b/pkg/api/helpers.go @@ -10,7 +10,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/sosedoff/pgweb/pkg/shared" + "github.com/sosedoff/openGauss-webclient/pkg/shared" ) var ( diff --git a/pkg/api/middleware.go b/pkg/api/middleware.go index f20dffb..43772dd 100644 --- a/pkg/api/middleware.go +++ b/pkg/api/middleware.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" ) // Middleware to check database connection status before running queries diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 3f94f5f..7cfb1da 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -3,7 +3,7 @@ package api import ( "github.com/gin-gonic/gin" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" ) func SetupMiddlewares(group *gin.RouterGroup) { diff --git a/pkg/api/session_cleanup.go b/pkg/api/session_cleanup.go index 862d121..68469a2 100644 --- a/pkg/api/session_cleanup.go +++ b/pkg/api/session_cleanup.go @@ -4,7 +4,7 @@ import ( "log" "time" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" ) // StartSessionCleanup starts a goroutine to cleanup idle database sessions diff --git a/pkg/bookmarks/bookmarks.go b/pkg/bookmarks/bookmarks.go index 2648b04..8e8a3e4 100644 --- a/pkg/bookmarks/bookmarks.go +++ b/pkg/bookmarks/bookmarks.go @@ -9,8 +9,8 @@ import ( "github.com/BurntSushi/toml" "github.com/mitchellh/go-homedir" - "github.com/sosedoff/pgweb/pkg/command" - "github.com/sosedoff/pgweb/pkg/shared" + "github.com/sosedoff/openGauss-webclient/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/shared" ) // Bookmark contains information about bookmarked database connection diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 64d527f..21cc849 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -11,13 +11,13 @@ import ( "github.com/gin-gonic/gin" "github.com/jessevdk/go-flags" - "github.com/sosedoff/pgweb/pkg/api" - "github.com/sosedoff/pgweb/pkg/bookmarks" - "github.com/sosedoff/pgweb/pkg/client" - "github.com/sosedoff/pgweb/pkg/command" - "github.com/sosedoff/pgweb/pkg/connection" - "github.com/sosedoff/pgweb/pkg/shared" - "github.com/sosedoff/pgweb/pkg/util" + "github.com/sosedoff/openGauss-webclient/pkg/api" + "github.com/sosedoff/openGauss-webclient/pkg/bookmarks" + "github.com/sosedoff/openGauss-webclient/pkg/client" + "github.com/sosedoff/openGauss-webclient/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/connection" + "github.com/sosedoff/openGauss-webclient/pkg/shared" + "github.com/sosedoff/openGauss-webclient/pkg/util" ) var ( diff --git a/pkg/client/client.go b/pkg/client/client.go index 865a2e3..da6664e 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -13,11 +13,11 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/lib/pq" - "github.com/sosedoff/pgweb/pkg/command" - "github.com/sosedoff/pgweb/pkg/connection" - "github.com/sosedoff/pgweb/pkg/history" - "github.com/sosedoff/pgweb/pkg/shared" - "github.com/sosedoff/pgweb/pkg/statements" + "github.com/sosedoff/openGauss-webclient/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/connection" + "github.com/sosedoff/openGauss-webclient/pkg/history" + "github.com/sosedoff/openGauss-webclient/pkg/shared" + "github.com/sosedoff/openGauss-webclient/pkg/statements" ) var ( diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 4d3f59d..dddc676 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" "github.com/stretchr/testify/assert" ) diff --git a/pkg/client/result.go b/pkg/client/result.go index 4cef669..df977d6 100644 --- a/pkg/client/result.go +++ b/pkg/client/result.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" ) type Row []interface{} diff --git a/pkg/client/tunnel.go b/pkg/client/tunnel.go index 784c01e..7f236a6 100644 --- a/pkg/client/tunnel.go +++ b/pkg/client/tunnel.go @@ -16,8 +16,8 @@ import ( "github.com/ScaleFT/sshkeys" "golang.org/x/crypto/ssh" - "github.com/sosedoff/pgweb/pkg/connection" - "github.com/sosedoff/pgweb/pkg/shared" + "github.com/sosedoff/openGauss-webclient/pkg/connection" + "github.com/sosedoff/openGauss-webclient/pkg/shared" ) const ( diff --git a/pkg/connection/connection_string.go b/pkg/connection/connection_string.go index 3ca831c..901a0da 100644 --- a/pkg/connection/connection_string.go +++ b/pkg/connection/connection_string.go @@ -8,7 +8,7 @@ import ( "os/user" "strings" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" ) // Common errors diff --git a/pkg/connection/connection_string_test.go b/pkg/connection/connection_string_test.go index ce82bfe..7cfca6b 100644 --- a/pkg/connection/connection_string_test.go +++ b/pkg/connection/connection_string_test.go @@ -6,7 +6,7 @@ import ( "os/user" "testing" - "github.com/sosedoff/pgweb/pkg/command" + "github.com/sosedoff/openGauss-webclient/pkg/command" "github.com/stretchr/testify/assert" ) -- Gitee