From 0734ad5189022da6cf36cdb2e7e4184818385f14 Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Fri, 15 Jul 2016 15:11:35 +1000 Subject: [PATCH] Revert "update reademe and use flags" This reverts commit 07a5f9e32bb95026385fd209c2e2e19084a4ce56. --- README.md | 5 +---- pastebin.go | 23 +++++++---------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d14521d..13824e9 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,8 @@ sudo yum install -y go mariadb-server mariadb * go get https://github.com/ewhal/Pastebin * nano pastebin.go +* Configure port and database details * make -``` -./pastebin --db-name="pastes" --db-username="pastebin" --db-pass="" ---port=":9900" --length=6 -``` ## License diff --git a/pastebin.go b/pastebin.go index d6084ab..f0315a2 100644 --- a/pastebin.go +++ b/pastebin.go @@ -7,7 +7,6 @@ import ( "encoding/base64" "encoding/json" "encoding/xml" - "flag" "fmt" "html" "html/template" @@ -28,19 +27,19 @@ import ( "github.com/gorilla/mux" ) -var ( +const ( // ADDRESS that pastebin will return links for - ADDRESS string + ADDRESS = "http://localhost:9900" // LENGTH of paste id - LENGTH int + LENGTH = 6 // PORT that pastebin will listen on - PORT string + PORT = ":9900" // USERNAME for database - USERNAME string + USERNAME = "" // PASS database password - PASS string + PASS = "" // NAME database name - NAME string + NAME = "" // DATABASE connection String DATABASE = USERNAME + ":" + PASS + "@/" + NAME + "?charset=utf8" ) @@ -381,14 +380,6 @@ func RootHandler(w http.ResponseWriter, r *http.Request) { } func main() { - flag.StringVar(&ADDRESS, "address", "", "host to serve pastes on") - flag.StringVar(&PORT, "port", ":9990", "host to serve pastes on") - flag.StringVar(&USERNAME, "db-username", "", "db username") - flag.StringVar(&PASS, "db-pass", "", "db pass") - flag.StringVar(&NAME, "db-name", "", "db name") - flag.IntVar(&LENGTH, "id-length", 6, "length of uploaded file IDs") - flag.Parse() - router := mux.NewRouter() router.HandleFunc("/p/{pasteId}", PasteHandler).Methods("GET") router.HandleFunc("/raw/{pasteId}", RawHandler).Methods("GET")