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

View File

@ -3,18 +3,26 @@ package main
import (
"bytes"
"fmt"
"github.com/docopt/docopt.go"
"github.com/spf13/viper"
"sour.is/x/httpsrv"
"sour.is/x/log"
"sour.is/go/httpsrv"
"sour.is/go/log"
)
var (
APP_VERSION string
APP_BUILD string
// AppVersion Application Version Number
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:
paste version
@ -32,13 +40,21 @@ Config:
- /etc/opt/sour.is/paste/
- Working Directory
`
var defaultConfig = `
[http]
listen = ":9010"
[module.paste]
random = "4096"
store = "data/"
`
var args map[string]interface{}
func init() {
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)
}
@ -66,22 +82,22 @@ func init() {
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")
if APP_VERSION != "" {
viper.Set("app.version", APP_VERSION)
if AppVersion != "" {
viper.Set("app.version", AppVersion)
}
viper.SetDefault("app.build", "SNAPSHOT")
if APP_BUILD != "" {
viper.Set("app.build", APP_BUILD)
if AppBuild != "" {
viper.Set("app.build", AppBuild)
}
if args["serve"] == true {
if args["--listen"] != nil {
viper.Set("listen", args["--listen"].(string))
viper.Set("http.listen", args["--listen"].(string))
}
log.Noticef("Startup: %s (%s %s)",
@ -90,10 +106,8 @@ func init() {
viper.GetString("app.build"))
log.Notice("Read config from: ", viper.ConfigFileUsed())
if viper.IsSet("http") {
httpsrv.Config()
}
} else if args["version"] == true {
fmt.Printf("Version: %s (%s %s)\n",
viper.GetString("app.name"),
@ -101,12 +115,3 @@ func init() {
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}_"; \
sed -i "$$SED" "$${BUILD}/DEBIAN/control"; \
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; \
dpkg -b $${BUILD}; \

View File

@ -27,8 +27,7 @@
package main // import "sour.is/x/paste"
import (
"sour.is/x/httpsrv"
//_ "sour.is/x/httpsrv/routes"
"sour.is/go/httpsrv"
_ "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"
"encoding/base64"
"encoding/json"
"github.com/gorilla/mux"
"golang.org/x/sys/unix"
"io"
"io/ioutil"
"net/http"
"os"
"sour.is/x/httpsrv"
"sour.is/x/log"
"strconv"
"strings"
"time"
"github.com/gorilla/mux"
"golang.org/x/sys/unix"
"sour.is/go/httpsrv"
"sour.is/go/log"
)
var store string