update imports

This commit is contained in:
Jon Lundy 2018-02-15 08:01:35 -07:00
parent fbc56d7235
commit dbfa4df0df
7 changed files with 51 additions and 47 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
paste /paste
/vendor

View File

@ -9,9 +9,8 @@ all: $(BINARY)
clean: clean:
rm -f $(BINARY) $(ROUTE_ASSET) $(ROUTE_FILES) rm -f $(BINARY) $(ROUTE_ASSET) $(ROUTE_FILES)
fmt: $(SOURCE) $(SCHEMA_ASSET) $(ROUTE_ASSET) run: $(BINARY)
gofmt -w -l . ./$(BINARY) -vv serve
go tool vet -composites=false .
$(BINARY): $(SOURCE) $(ROUTE_ASSET) $(BINARY): $(SOURCE) $(ROUTE_ASSET)
go build go build
@ -42,5 +41,4 @@ public/style.css: assets/*.css
deploy: deploy:
cd debian && make && make deploy cd debian && make && make deploy
.PHONEY: clean deploy fmt .PHONEY: clean deploy run

View File

@ -3,18 +3,26 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/docopt/docopt.go" "github.com/docopt/docopt.go"
"github.com/spf13/viper" "github.com/spf13/viper"
"sour.is/x/httpsrv" "sour.is/go/httpsrv"
"sour.is/x/log" "sour.is/go/log"
) )
var ( var (
APP_VERSION string // AppVersion Application Version Number
APP_BUILD string AppVersion string
// AppBuild Application Build Number
AppBuild string
) )
var APP_NAME string = "Paste API"
var APP_USAGE string = `Paste API // AppName name of the application
var AppName = "Paste API"
// AppUsage displays runtime options
var AppUsage = `Paste API
Usage: Usage:
paste version paste version
@ -32,13 +40,21 @@ Config:
- /etc/opt/sour.is/paste/ - /etc/opt/sour.is/paste/
- Working Directory - Working Directory
` `
var defaultConfig = `
[http]
listen = ":9010"
[module.paste]
random = "4096"
store = "data/"
`
var args map[string]interface{} var args map[string]interface{}
func init() { func init() {
var err error var err error
if args, err = docopt.Parse(APP_USAGE, nil, true, APP_NAME, false); err != nil { if args, err = docopt.Parse(AppUsage, nil, true, AppVersion, false); err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -66,22 +82,22 @@ func init() {
log.Fatalf("Fatal error config file: %s \n", err) log.Fatalf("Fatal error config file: %s \n", err)
} }
viper.Set("app.name", APP_NAME) viper.Set("app.name", AppName)
viper.SetDefault("app.version", "VERSION") viper.SetDefault("app.version", "VERSION")
if APP_VERSION != "" { if AppVersion != "" {
viper.Set("app.version", APP_VERSION) viper.Set("app.version", AppVersion)
} }
viper.SetDefault("app.build", "SNAPSHOT") viper.SetDefault("app.build", "SNAPSHOT")
if APP_BUILD != "" { if AppBuild != "" {
viper.Set("app.build", APP_BUILD) viper.Set("app.build", AppBuild)
} }
if args["serve"] == true { if args["serve"] == true {
if args["--listen"] != nil { if args["--listen"] != nil {
viper.Set("listen", args["--listen"].(string)) viper.Set("http.listen", args["--listen"].(string))
} }
log.Noticef("Startup: %s (%s %s)", log.Noticef("Startup: %s (%s %s)",
@ -90,10 +106,8 @@ func init() {
viper.GetString("app.build")) viper.GetString("app.build"))
log.Notice("Read config from: ", viper.ConfigFileUsed()) log.Notice("Read config from: ", viper.ConfigFileUsed())
httpsrv.Config()
if viper.IsSet("http") {
httpsrv.Config()
}
} else if args["version"] == true { } else if args["version"] == true {
fmt.Printf("Version: %s (%s %s)\n", fmt.Printf("Version: %s (%s %s)\n",
viper.GetString("app.name"), viper.GetString("app.name"),
@ -101,12 +115,3 @@ func init() {
viper.GetString("app.build")) viper.GetString("app.build"))
} }
} }
var defaultConfig []byte = []byte(`
[http]
listen = ":9010"
[module.paste]
random = "4096"
store = "data/"
`)

2
debian/Makefile vendored
View File

@ -24,7 +24,7 @@ build:
export SED="s_Version:.*_Version: $${VERSION}-$${RELEASE}_"; \ export SED="s_Version:.*_Version: $${VERSION}-$${RELEASE}_"; \
sed -i "$$SED" "$${BUILD}/DEBIAN/control"; \ sed -i "$$SED" "$${BUILD}/DEBIAN/control"; \
go build -o $${BUILD}/opt/sour.is/bin/paste \ go build -o $${BUILD}/opt/sour.is/bin/paste \
-ldflags "-X main.APP_VERSION=$${VERSION}-$${RELEASE} -X main.APP_BUILD=$${DATE}"\ -ldflags "-X main.AppVersion=$${VERSION}-$${RELEASE} -X main.AppBuild=$${DATE}"\
sour.is/x/paste; \ sour.is/x/paste; \
dpkg -b $${BUILD}; \ dpkg -b $${BUILD}; \

View File

@ -27,8 +27,7 @@
package main // import "sour.is/x/paste" package main // import "sour.is/x/paste"
import ( import (
"sour.is/x/httpsrv" "sour.is/go/httpsrv"
//_ "sour.is/x/httpsrv/routes"
_ "sour.is/x/paste/routes" _ "sour.is/x/paste/routes"
) )

File diff suppressed because one or more lines are too long

View File

@ -6,17 +6,18 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"github.com/gorilla/mux"
"golang.org/x/sys/unix"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"sour.is/x/httpsrv"
"sour.is/x/log"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/gorilla/mux"
"golang.org/x/sys/unix"
"sour.is/go/httpsrv"
"sour.is/go/log"
) )
var store string var store string