From c5e3a7de4d41837e1196218b57a4b0f9a480446a Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 29 Aug 2019 22:40:22 -0400 Subject: [PATCH] manhattan i'm done --- cmd/pkger/main.go | 22 +++++---- .../examples => examples}/app/.gitignore | 0 .../examples => examples}/app/Dockerfile | 0 {internal/examples => examples}/app/Makefile | 0 examples/app/go.mod | 7 +++ {internal/examples => examples}/app/go.sum | 0 {internal/examples => examples}/app/main.go | 0 .../app/public/images/mark-small.png | Bin .../app/public/images/mark.png | Bin .../app/public/images/mark_250px.png | Bin .../app/public/images/mark_400px.png | Bin .../app/public/index.html | 0 .../examples => examples}/app/templates/a.txt | 0 .../app/templates/b/b.txt | 0 examples/extfile/go.mod | 7 +++ .../examples => examples}/extfile/go.sum | 4 ++ .../examples => examples}/extfile/main.go | 0 examples/httpserver/go.mod | 7 +++ .../examples => examples}/httpserver/go.sum | 0 .../examples => examples}/httpserver/main.go | 0 .../httpserver/public/radio.radio | 0 examples/walk/go.mod | 7 +++ {internal/examples => examples}/walk/go.sum | 0 {internal/examples => examples}/walk/main.go | 0 internal/examples/app/go.mod | 7 --- internal/examples/extfile/go.mod | 7 --- internal/examples/httpserver/go.mod | 7 --- internal/examples/walk/go.mod | 7 --- parser/parser_test.go | 42 +++++------------- 29 files changed, 57 insertions(+), 67 deletions(-) rename {internal/examples => examples}/app/.gitignore (100%) rename {internal/examples => examples}/app/Dockerfile (100%) rename {internal/examples => examples}/app/Makefile (100%) create mode 100644 examples/app/go.mod rename {internal/examples => examples}/app/go.sum (100%) rename {internal/examples => examples}/app/main.go (100%) rename {internal/examples => examples}/app/public/images/mark-small.png (100%) rename {internal/examples => examples}/app/public/images/mark.png (100%) rename {internal/examples => examples}/app/public/images/mark_250px.png (100%) rename {internal/examples => examples}/app/public/images/mark_400px.png (100%) rename {internal/examples => examples}/app/public/index.html (100%) rename {internal/examples => examples}/app/templates/a.txt (100%) rename {internal/examples => examples}/app/templates/b/b.txt (100%) create mode 100644 examples/extfile/go.mod rename {internal/examples => examples}/extfile/go.sum (79%) rename {internal/examples => examples}/extfile/main.go (100%) create mode 100644 examples/httpserver/go.mod rename {internal/examples => examples}/httpserver/go.sum (100%) rename {internal/examples => examples}/httpserver/main.go (100%) rename {internal/examples => examples}/httpserver/public/radio.radio (100%) create mode 100644 examples/walk/go.mod rename {internal/examples => examples}/walk/go.sum (100%) rename {internal/examples => examples}/walk/main.go (100%) delete mode 100644 internal/examples/app/go.mod delete mode 100644 internal/examples/extfile/go.mod delete mode 100644 internal/examples/httpserver/go.mod delete mode 100644 internal/examples/walk/go.mod diff --git a/cmd/pkger/main.go b/cmd/pkger/main.go index 81f0f15..ad9ba16 100644 --- a/cmd/pkger/main.go +++ b/cmd/pkger/main.go @@ -1,30 +1,34 @@ package main import ( - "fmt" "log" "os" "os/exec" ) func main() { - defer func() { + clean := func() { c := exec.Command("go", "mod", "tidy", "-v") - fmt.Println(c.Args) c.Stdout = os.Stdout c.Stderr = os.Stderr c.Stdin = os.Stdin c.Run() - }() - - root, err := New() - if err != nil { - log.Fatal(err) } + defer clean() - if err := root.Route(os.Args[1:]); err != nil { + if err := run(); err != nil { + clean() log.Fatal(err) } } +func run() error { + root, err := New() + if err != nil { + return err + } + + return root.Route(os.Args[1:]) +} + // does not computee diff --git a/internal/examples/app/.gitignore b/examples/app/.gitignore similarity index 100% rename from internal/examples/app/.gitignore rename to examples/app/.gitignore diff --git a/internal/examples/app/Dockerfile b/examples/app/Dockerfile similarity index 100% rename from internal/examples/app/Dockerfile rename to examples/app/Dockerfile diff --git a/internal/examples/app/Makefile b/examples/app/Makefile similarity index 100% rename from internal/examples/app/Makefile rename to examples/app/Makefile diff --git a/examples/app/go.mod b/examples/app/go.mod new file mode 100644 index 0000000..184f927 --- /dev/null +++ b/examples/app/go.mod @@ -0,0 +1,7 @@ +module github.com/markbates/pkger/examples/app + +go 1.12 + +require github.com/markbates/pkger v0.0.0 + +replace github.com/markbates/pkger => ../../ diff --git a/internal/examples/app/go.sum b/examples/app/go.sum similarity index 100% rename from internal/examples/app/go.sum rename to examples/app/go.sum diff --git a/internal/examples/app/main.go b/examples/app/main.go similarity index 100% rename from internal/examples/app/main.go rename to examples/app/main.go diff --git a/internal/examples/app/public/images/mark-small.png b/examples/app/public/images/mark-small.png similarity index 100% rename from internal/examples/app/public/images/mark-small.png rename to examples/app/public/images/mark-small.png diff --git a/internal/examples/app/public/images/mark.png b/examples/app/public/images/mark.png similarity index 100% rename from internal/examples/app/public/images/mark.png rename to examples/app/public/images/mark.png diff --git a/internal/examples/app/public/images/mark_250px.png b/examples/app/public/images/mark_250px.png similarity index 100% rename from internal/examples/app/public/images/mark_250px.png rename to examples/app/public/images/mark_250px.png diff --git a/internal/examples/app/public/images/mark_400px.png b/examples/app/public/images/mark_400px.png similarity index 100% rename from internal/examples/app/public/images/mark_400px.png rename to examples/app/public/images/mark_400px.png diff --git a/internal/examples/app/public/index.html b/examples/app/public/index.html similarity index 100% rename from internal/examples/app/public/index.html rename to examples/app/public/index.html diff --git a/internal/examples/app/templates/a.txt b/examples/app/templates/a.txt similarity index 100% rename from internal/examples/app/templates/a.txt rename to examples/app/templates/a.txt diff --git a/internal/examples/app/templates/b/b.txt b/examples/app/templates/b/b.txt similarity index 100% rename from internal/examples/app/templates/b/b.txt rename to examples/app/templates/b/b.txt diff --git a/examples/extfile/go.mod b/examples/extfile/go.mod new file mode 100644 index 0000000..e34a526 --- /dev/null +++ b/examples/extfile/go.mod @@ -0,0 +1,7 @@ +module github.com/markbates/pkger/examples/extfile + +go 1.12 + +require github.com/markbates/pkger v0.0.0 + +replace github.com/markbates/pkger => ../../ diff --git a/internal/examples/extfile/go.sum b/examples/extfile/go.sum similarity index 79% rename from internal/examples/extfile/go.sum rename to examples/extfile/go.sum index 48b8832..dad94cc 100644 --- a/internal/examples/extfile/go.sum +++ b/examples/extfile/go.sum @@ -3,6 +3,9 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gobuffalo/here v0.2.1 h1:YWZUvrHnxNCIY2nnHPnF5Ob99Z5Iq29wHioLgcY+2G0= github.com/gobuffalo/here v0.2.1/go.mod h1:2a6G14FaAKOGJMK/5UNa4Og/+iyFS5cq3MnlvFR7YDk= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/markbates/errx v1.1.0/go.mod h1:PLa46Oex9KNbVDZhKel8v1OT7hD5JZ2eI7AHhA0wswc= github.com/markbates/pkger/internal/examples/app v0.0.0-20190830010658-89a072f8d2d2/go.mod h1:f2mBLD6G47JQTp9vdB0Q8UJhoj96fX1cNyGTn13XG9g= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -12,4 +15,5 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/examples/extfile/main.go b/examples/extfile/main.go similarity index 100% rename from internal/examples/extfile/main.go rename to examples/extfile/main.go diff --git a/examples/httpserver/go.mod b/examples/httpserver/go.mod new file mode 100644 index 0000000..8a70cd3 --- /dev/null +++ b/examples/httpserver/go.mod @@ -0,0 +1,7 @@ +module github.com/markbates/pkger/examples/httpserver + +go 1.12 + +require github.com/markbates/pkger v0.0.0 + +replace github.com/markbates/pkger => ../../ diff --git a/internal/examples/httpserver/go.sum b/examples/httpserver/go.sum similarity index 100% rename from internal/examples/httpserver/go.sum rename to examples/httpserver/go.sum diff --git a/internal/examples/httpserver/main.go b/examples/httpserver/main.go similarity index 100% rename from internal/examples/httpserver/main.go rename to examples/httpserver/main.go diff --git a/internal/examples/httpserver/public/radio.radio b/examples/httpserver/public/radio.radio similarity index 100% rename from internal/examples/httpserver/public/radio.radio rename to examples/httpserver/public/radio.radio diff --git a/examples/walk/go.mod b/examples/walk/go.mod new file mode 100644 index 0000000..a20b3a8 --- /dev/null +++ b/examples/walk/go.mod @@ -0,0 +1,7 @@ +module github.com/markbates/pkger/examples/walk + +go 1.12 + +require github.com/markbates/pkger v0.0.0 + +replace github.com/markbates/pkger => ../../ diff --git a/internal/examples/walk/go.sum b/examples/walk/go.sum similarity index 100% rename from internal/examples/walk/go.sum rename to examples/walk/go.sum diff --git a/internal/examples/walk/main.go b/examples/walk/main.go similarity index 100% rename from internal/examples/walk/main.go rename to examples/walk/main.go diff --git a/internal/examples/app/go.mod b/internal/examples/app/go.mod deleted file mode 100644 index a27e97e..0000000 --- a/internal/examples/app/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module github.com/markbates/pkger/internal/examples/app - -go 1.12 - -require github.com/markbates/pkger v0.0.0 - -replace github.com/markbates/pkger => ../../../ diff --git a/internal/examples/extfile/go.mod b/internal/examples/extfile/go.mod deleted file mode 100644 index 24ebfe1..0000000 --- a/internal/examples/extfile/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module github.com/markbates/pkger/internal/examples/extfile - -go 1.12 - -require github.com/markbates/pkger v0.0.0 - -replace github.com/markbates/pkger => ../../../ diff --git a/internal/examples/httpserver/go.mod b/internal/examples/httpserver/go.mod deleted file mode 100644 index 9fae841..0000000 --- a/internal/examples/httpserver/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module github.com/markbates/pkger/internal/examples/httpserver - -go 1.12 - -require github.com/markbates/pkger v0.0.0 - -replace github.com/markbates/pkger => ../../../ diff --git a/internal/examples/walk/go.mod b/internal/examples/walk/go.mod deleted file mode 100644 index 028bd65..0000000 --- a/internal/examples/walk/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module github.com/markbates/pkger/internal/examples/walk - -go 1.12 - -require github.com/markbates/pkger v0.0.0 - -replace github.com/markbates/pkger => ../../../ diff --git a/parser/parser_test.go b/parser/parser_test.go index 6da4a96..116d19a 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -10,28 +10,10 @@ import ( ) func Test_Parser(t *testing.T) { - // unsure why, but it seems the gproxy - // has trouble handing this request. - // finding github.com/markbates/pkger v0.0.0 - // github.com/markbates/pkger@v0.0.0: unexpected status (https://proxy.golang.org/github.com/markbates/pkger/@v/v0.0.0.info): 410 Gone - // turning it off works just fine, so this - // might be a bug. - // module github.com/markbates/pkger/internal/examples/app - // - // go 1.12 - // - // require github.com/markbates/pkger v0.0.0-20190803203656-a4a55a52dc5d - // const env = "GOPROXY" - // prxy := os.Getenv(env) - // os.Setenv(env, "") - // defer func() { - // os.Setenv(env, prxy) - // }() - r := require.New(t) pwd, err := os.Getwd() r.NoError(err) - r.NoError(os.Chdir(filepath.Join("..", "internal", "examples", "app"))) + r.NoError(os.Chdir(filepath.Join("..", "examples", "app"))) defer os.Chdir(pwd) res, err := Parse("") @@ -39,17 +21,17 @@ func Test_Parser(t *testing.T) { r.NoError(err) exp := []string{ - "github.com/markbates/pkger/internal/examples/app:/", - "github.com/markbates/pkger/internal/examples/app:/public", - "github.com/markbates/pkger/internal/examples/app:/templates", - "github.com/markbates/pkger/internal/examples/app:/templates/a.txt", - "github.com/markbates/pkger/internal/examples/app:/templates/b", - "github.com/markbates/pkger/internal/examples/app:/public/images/mark-small.png", - "github.com/markbates/pkger/internal/examples/app:/public/images", - "github.com/markbates/pkger/internal/examples/app:/public/images/mark.png", - "github.com/markbates/pkger/internal/examples/app:/public/images/mark_250px.png", - "github.com/markbates/pkger/internal/examples/app:/public/images/mark_400px.png", - "github.com/markbates/pkger/internal/examples/app:/public/index.html", + "github.com/markbates/pkger/examples/app:/", + "github.com/markbates/pkger/examples/app:/public", + "github.com/markbates/pkger/examples/app:/templates", + "github.com/markbates/pkger/examples/app:/templates/a.txt", + "github.com/markbates/pkger/examples/app:/templates/b", + "github.com/markbates/pkger/examples/app:/public/images/mark-small.png", + "github.com/markbates/pkger/examples/app:/public/images", + "github.com/markbates/pkger/examples/app:/public/images/mark.png", + "github.com/markbates/pkger/examples/app:/public/images/mark_250px.png", + "github.com/markbates/pkger/examples/app:/public/images/mark_400px.png", + "github.com/markbates/pkger/examples/app:/public/index.html", } sort.Strings(exp)