From 7b16271dbec7db8fca4cbe816bf004add203a78a Mon Sep 17 00:00:00 2001 From: nicksherron Date: Mon, 10 Feb 2020 01:53:37 -0500 Subject: [PATCH] commenting exported vars/funcs and blank imports --- README.md | 9 +++++++-- cmd/root.go | 2 +- internal/db.go | 4 ++++ internal/server.go | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d7019c3..d5608ad 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Flags: Use " [command] --help" for more information about a command. ``` - +### Running Just run the server ```shell script @@ -65,4 +65,9 @@ docker run -d -p 8080:8080 --name bashhub-server nicksherron/bashhub-server ``` Then add ```export BH_HOST=localhost:8080``` (or whatever you set your bashhub-server address to) to your .zshrc or .bashrc -Thats it! \ No newline at end of file +Thats it! Restart your shell with `$SHELL` then re-configure bashhub-client to use your new +server by re-running ```bashhub setup``` . + +### Setting DB + +### Using Regex diff --git a/cmd/root.go b/cmd/root.go index d5b2ea1..fe8549b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -39,7 +39,7 @@ var rootCmd = &cobra.Command{ internal.Run() }, } - +// Execute runs root command func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Println(err) diff --git a/internal/db.go b/internal/db.go index 5727f0e..df79f2c 100644 --- a/internal/db.go +++ b/internal/db.go @@ -27,8 +27,11 @@ import ( "time" "github.com/jinzhu/gorm" + // db driver are called by gorm _ "github.com/jinzhu/gorm/dialects/postgres" + // db driver are called by gorm _ "github.com/jinzhu/gorm/dialects/sqlite" + // db driver are called by database/sql _ "github.com/lib/pq" "github.com/mattn/go-sqlite3" "golang.org/x/crypto/bcrypt" @@ -47,6 +50,7 @@ func dbInit() { var err error if strings.HasPrefix(DbPath, "postgres://") { // postgres + db, err = sql.Open("postgres", DbPath) if err != nil { log.Fatal(err) diff --git a/internal/server.go b/internal/server.go index da879fa..bfee302 100644 --- a/internal/server.go +++ b/internal/server.go @@ -81,7 +81,9 @@ type System struct { } var ( + // Addr is the listen and server address for our server (gin) Addr string + // LogFile is the log file location for http logging. Default is stderr. LogFile string ) @@ -107,7 +109,7 @@ func loggerWithFormatterWriter(f gin.LogFormatter) gin.HandlerFunc { Output: getLog(), }) } - +// Run starts server func Run() { // Initialize backend dbInit()