From 7a91d0ca0bfc4706e700596262a5bf4b7002659d Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Sun, 7 Feb 2021 00:17:28 +0100 Subject: [PATCH 1/8] interrupt process on windows as well On Windows, the killing of running services relies on the 60 second kill timeout, making it faster to restart the harness to force rebuilding. Since os.Interrupt works for me, remove the runtime os check in harness/app.go completely. --- harness/app.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/harness/app.go b/harness/app.go index 3536dc9..ac6520c 100644 --- a/harness/app.go +++ b/harness/app.go @@ -11,7 +11,6 @@ import ( "io" "os" "os/exec" - "runtime" "sync" "time" @@ -133,11 +132,8 @@ func (cmd AppCmd) Kill() { // Send an interrupt signal to allow for a graceful shutdown utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid) - var err error - if runtime.GOOS != "windows" { - // os.Interrupt is not available on windows - err = cmd.Process.Signal(os.Interrupt) - } + + err := cmd.Process.Signal(os.Interrupt) if err != nil { utils.Logger.Info( From 25d6352bc52028a5eed09a002b36c12111dee7b7 Mon Sep 17 00:00:00 2001 From: Mark Christian Date: Sun, 15 Aug 2021 14:29:06 -0700 Subject: [PATCH 2/8] Get rid of redundant space in the output of `revel new -a` --- revel/new.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revel/new.go b/revel/new.go index 21fe5b2..c42ab78 100644 --- a/revel/new.go +++ b/revel/new.go @@ -118,7 +118,7 @@ func newApp(c *model.CommandConfig) (err error) { c.UpdateImportPath() runApp(c) } else { - fmt.Fprintln(os.Stdout, "\nYou can run it with:\n revel run -a ", c.ImportPath) + fmt.Fprintln(os.Stdout, "\nYou can run it with:\n revel run -a", c.ImportPath) } return } From ea5acb720fee7ee4bd6e37a898f6f6b608c82f04 Mon Sep 17 00:00:00 2001 From: "notzippy@gmail.com" Date: Sun, 20 Feb 2022 17:16:12 -0800 Subject: [PATCH 3/8] Updated shared build environments Updated check for errors. Updated go.mod Added .vscode launch --- .vscode/launch.json | 39 ++++++++++++++++++++++ .vscode/tasks.json | 12 +++++++ go.mod | 22 ++++--------- go.sum | 66 +++++++++++++++++++++++-------------- harness/build.go | 5 +++ model/command_config.go | 2 +- model/revel_container.go | 9 +++-- parser2/source_processor.go | 1 + utils/command.go | 18 +++++++--- utils/file.go | 3 +- 10 files changed, 125 insertions(+), 52 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9276550 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,39 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Help", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceRoot}/revel", + "args": [] + }, + { + "name": "Create new", + "type": "go", + "request": "launch", + "preLaunchTask": "Clean", + "mode": "auto", + "program": "${workspaceRoot}/revel", + "args": ["new", "-a", "/tmp/revel/aaa"], + "env": { + "GOPATH": "/tmp/revel/GOPATH" + }, + }, + { + "name": "Run program", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceRoot}/revel", + "args": ["run","-v", "-a", "/tmp/revel/aaa"], + "env": { + "GOPATH": "/tmp/revel/GOPATH" + }, + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..7dd4621 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Clean", + "type": "shell", + "command": "rm -rf /tmp/revel/aaa" + } + ] +} \ No newline at end of file diff --git a/go.mod b/go.mod index 268f752..d1a0de4 100644 --- a/go.mod +++ b/go.mod @@ -3,28 +3,18 @@ module github.com/revel/cmd go 1.12 require ( - github.com/BurntSushi/toml v0.3.1 // indirect github.com/agtorre/gocolorize v1.0.0 - github.com/fsnotify/fsnotify v1.4.7 - github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect + github.com/fsnotify/fsnotify v1.5.1 github.com/jessevdk/go-flags v1.4.0 - github.com/mattn/go-colorable v0.1.6 - github.com/myesui/uuid v1.0.0 // indirect + github.com/mattn/go-colorable v0.1.12 github.com/pkg/errors v0.9.1 - github.com/revel/config v0.21.0 + github.com/revel/config v1.0.0 github.com/revel/log15 v2.11.20+incompatible - github.com/revel/modules v0.21.0 // indirect - github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9 // indirect github.com/revel/revel v0.21.0 - github.com/stretchr/testify v1.4.0 - github.com/twinj/uuid v1.0.0 // indirect - github.com/xeonx/timeago v1.0.0-rc4 // indirect - golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect - golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect + github.com/stretchr/testify v1.7.0 golang.org/x/tools v0.0.0-20200219054238-753a1d49df85 - gopkg.in/fsnotify/fsnotify.v1 v1.4.7 - gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 - gopkg.in/stretchr/testify.v1 v1.2.2 // indirect ) + +replace github.com/revel/revel v0.21.0 => ../revel diff --git a/go.sum b/go.sum index 464c37b..e340928 100644 --- a/go.sum +++ b/go.sum @@ -1,60 +1,76 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/agtorre/gocolorize v1.0.0 h1:TvGQd+fAqWQlDjQxSKe//Y6RaxK+RHpEU9X/zPmHW50= github.com/agtorre/gocolorize v1.0.0/go.mod h1:cH6imfTkHVBRJhSOeSeEZhB4zqEYSq0sXuIyehgZMIY= +github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 h1:KUDFlmBg2buRWNzIcwLlKvfcnujcHQRQ1As1LoaCLAM= -github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/garyburd/redigo v1.6.3/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac h1:n1DqxAo4oWPMvH1+v+DLYlMCecgumhhgnxAPdqDIFHI= +github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/myesui/uuid v1.0.0 h1:xCBmH4l5KuvLYc5L7AS7SZg9/jKdIFubM7OVoLqaQUI= github.com/myesui/uuid v1.0.0/go.mod h1:2CDfNgU0LR8mIdO8vdWd8i9gWWxLlcoIGGpSNgafq84= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/revel/config v0.21.0 h1:Bw4iXLGAuD/Di2HEhPSOyDywrTlFIXUMbds91lXTtTU= -github.com/revel/config v0.21.0/go.mod h1:GT4a9px5kDGRqLizcw/md0QFErrhen76toz4qS3oIoI= +github.com/revel/config v1.0.0 h1:UAzLPQ+x9nJeP6a+H93G+AKEosg3OO2oVLBXK9oSN2U= +github.com/revel/config v1.0.0/go.mod h1:GT4a9px5kDGRqLizcw/md0QFErrhen76toz4qS3oIoI= github.com/revel/log15 v2.11.20+incompatible h1:JkA4tbwIo/UGEMumY50zndKq816RQW3LQ0wIpRc+32U= github.com/revel/log15 v2.11.20+incompatible/go.mod h1:l0WmLRs+IM1hBl4noJiBc2tZQiOgZyXzS1mdmFt+5Gc= -github.com/revel/modules v0.21.0/go.mod h1:UBlNmO9VGZo4j6Ptn2uC/26Iclefuic+V40jYRPBxQE= +github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9 h1:/d6kfjzjyx19ieWqMOXHSTLFuRxLOH15ZubtcAXExKw= github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9/go.mod h1:TmlwoRLDvgRjoTe6rbsxIaka/CulzYrgfef7iNJcEWY= -github.com/revel/revel v0.21.0/go.mod h1:VZWJnHjpDEtuGUuZJ2NO42XryitrtwsdVaJxfDeo5yc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/twinj/uuid v1.0.0 h1:fzz7COZnDrXGTAOHGuUGYd6sG+JMq+AoE7+Jlu0przk= github.com/twinj/uuid v1.0.0/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY= +github.com/xeonx/timeago v1.0.0-rc4 h1:9rRzv48GlJC0vm+iBpLcWAr8YbETyN9Vij+7h2ammz4= github.com/xeonx/timeago v1.0.0-rc4/go.mod h1:qDLrYEFynLO7y5Ho7w3GwgtYgpy5UfhcXIIQvMKVDkA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 h1:5B6i6EAiSYyejWfvc5Rc9BbI3rzIsrrXfAQBWnYfn+w= -golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20200219054238-753a1d49df85 h1:XNHaQ2CZDl/SjEZlUXGh7+OQvfLuFgmk3oNWkCFfERE= golang.org/x/tools v0.0.0-20200219054238-753a1d49df85/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify/fsnotify.v1 v1.4.7/go.mod h1:Fyux9zXlo4rWoMSIzpn9fDAYjalPqJ/K1qJ27s+7ltE= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0 h1:lMH45EKqD8Nf6LwoF+43YOKjOAEEHQRVgDyG8RCV4MU= gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0/go.mod h1:kl/bNzW/jgTgUOCGDj3XPn9/Hbfhw6pjfBRUnaTioFQ= +gopkg.in/stretchr/testify.v1 v1.2.2 h1:yhQC6Uy5CqibAIlk1wlusa/MJ3iAN49/BsR/dCCKz3M= gopkg.in/stretchr/testify.v1 v1.2.2/go.mod h1:QI5V/q6UbPmuhtm10CaFZxED9NreB8PnFYN9JcR6TxU= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/harness/build.go b/harness/build.go index ee23d56..ff8009e 100644 --- a/harness/build.go +++ b/harness/build.go @@ -25,6 +25,7 @@ import ( ) var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"") +var importErrorPattern2 = regexp.MustCompile("no required module provides package ([^;]+)+") type ByString []*model.TypeInfo @@ -210,6 +211,9 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err // See if it was an import error that we can go get. matches := importErrorPattern.FindAllStringSubmatch(stOutput, -1) + if matches == nil { + matches = importErrorPattern2.FindAllStringSubmatch(stOutput, -1) + } utils.Logger.Info("Build failed checking for missing imports", "message", stOutput, "missing_imports", len(matches)) if matches == nil { utils.Logger.Info("Build failed no missing imports", "message", stOutput) @@ -226,6 +230,7 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err } gotten[pkgName] = struct{}{} if err := c.PackageResolver(pkgName); err != nil { + panic("failed to resolve") utils.Logger.Error("Unable to resolve package", "package", pkgName, "error", err) return nil, newCompileError(paths, []byte(err.Error())) } diff --git a/model/command_config.go b/model/command_config.go index 87e4a89..aa0ad8f 100644 --- a/model/command_config.go +++ b/model/command_config.go @@ -237,7 +237,7 @@ func (c *CommandConfig) InitPackageResolver() { var getCmd *exec.Cmd print("Downloading related packages ...") if c.Vendored { - getCmd = exec.Command(c.GoCmd, "mod", "tidy") + getCmd = exec.Command(c.GoCmd, "mod", "tidy", "-v") } else { utils.Logger.Info("No vendor folder detected, not using dependency manager to import package", "package", pkgName) getCmd = exec.Command(c.GoCmd, "get", "-u", pkgName) diff --git a/model/revel_container.go b/model/revel_container.go index 659c256..9632910 100644 --- a/model/revel_container.go +++ b/model/revel_container.go @@ -273,12 +273,11 @@ func (rp *RevelContainer) ResolveImportPath(importPath string) (string, error) { return filepath.Join(rp.SourcePath, importPath), nil } config := &packages.Config{ - // TODO: packages.LoadSyntax deprecated, Need instead - //nolint:staticcheck - Mode: packages.LoadSyntax, - Dir: rp.AppPath, + Mode: packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedImports | + packages.NeedTypes | packages.NeedTypesSizes | packages.NeedSyntax | packages.NeedTypesInfo, + Dir: rp.AppPath, } - + config.Env = utils.ReducedEnv(false) pkgs, err := packages.Load(config, importPath) if len(pkgs) == 0 { return "", errors.New("No packages found for import " + importPath + " using app path " + rp.AppPath) diff --git a/parser2/source_processor.go b/parser2/source_processor.go index c42e12d..fd84fb9 100644 --- a/parser2/source_processor.go +++ b/parser2/source_processor.go @@ -107,6 +107,7 @@ func (s *SourceProcessor) addPackages() (err error) { // packages.LoadSyntax | packages.NeedDeps, Dir: s.revelContainer.AppPath, } + config.Env = utils.ReducedEnv(false) s.packageList, err = packages.Load(config, allPackages...) s.log.Info("Loaded modules ", "len results", len(s.packageList), "error", err) diff --git a/utils/command.go b/utils/command.go index d89b373..a233659 100644 --- a/utils/command.go +++ b/utils/command.go @@ -13,7 +13,13 @@ import ( func CmdInit(c *exec.Cmd, addGoPath bool, basePath string) { c.Dir = basePath // Dep does not like paths that are not real, convert all paths in go to real paths + // Fetch the rest of the env variables + c.Env = ReducedEnv(addGoPath) + +} +func ReducedEnv(addGoPath bool) []string { realPath := &bytes.Buffer{} + env := []string{} if addGoPath { for _, p := range filepath.SplitList(build.Default.GOPATH) { rp, _ := filepath.EvalSymlinks(p) @@ -23,14 +29,18 @@ func CmdInit(c *exec.Cmd, addGoPath bool, basePath string) { realPath.WriteString(rp) } // Go 1.8 fails if we do not include the GOROOT - c.Env = []string{"GOPATH=" + realPath.String(), "GOROOT=" + os.Getenv("GOROOT")} + env = []string{"GOPATH=" + realPath.String(), "GOROOT=" + os.Getenv("GOROOT")} } - // Fetch the rest of the env variables + for _, e := range os.Environ() { pair := strings.Split(e, "=") - if pair[0] == "GOPATH" || pair[0] == "GOROOT" { + // Always exclude gomodcache + if pair[0] == "GOMODCACHE" { continue + } else if !addGoPath && (pair[0] == "GOPATH" || pair[0] == "GOROOT") { + } - c.Env = append(c.Env, e) + env = append(env, e) } + return env } diff --git a/utils/file.go b/utils/file.go index f0637de..4fe0eef 100644 --- a/utils/file.go +++ b/utils/file.go @@ -358,9 +358,10 @@ func findSrcPaths(appPath string, packagesList []string) (sourcePathsmap map[str // Use packages to fetch // by not specifying env, we will use the default env config := &packages.Config{ - Mode: packages.NeedName | packages.NeedFiles, + Mode: packages.NeedName | packages.NeedFiles | packages.NeedDeps, Dir: appPath, } + config.Env = ReducedEnv(false) sourcePathsmap = map[string]string{} Logger.Infof("Environment path %s root %s config env %s", os.Getenv("GOPATH"), os.Getenv("GOROOT"), config.Env) From fcc1319245489834ee7836a00f12a75399413b78 Mon Sep 17 00:00:00 2001 From: Lukas Rist Date: Wed, 23 Feb 2022 14:55:14 +0100 Subject: [PATCH 4/8] Fixing type --- harness/harness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harness/harness.go b/harness/harness.go index 87ad05b..d264f98 100644 --- a/harness/harness.go +++ b/harness/harness.go @@ -206,7 +206,7 @@ func NewHarness(c *model.CommandConfig, paths *model.RevelContainer, runMode str // called by the watcher func (h *Harness) Refresh() (err *utils.SourceError) { t := time.Now(); - fmt.Println("Changed detected, recompiling") + fmt.Println("Change detected, recompiling") err = h.refresh() if err!=nil && !h.ranOnce && h.useProxy { addr := fmt.Sprintf("%s:%d", h.paths.HTTPAddr, h.paths.HTTPPort) From 25dc05b31eed259b80d275e760765e10c45ef07a Mon Sep 17 00:00:00 2001 From: "notzippy@gmail.com" Date: Mon, 28 Feb 2022 20:01:01 -0800 Subject: [PATCH 5/8] Updated Launch code Added output to error stack, so terminal errors are displayed Ficed c.Verbose, it was changed to an array which causes issues launching Removed . notation from doing anything special. This was already replaced with the -p CLI option Added documentaiton on adding the package name Started watcher with force refresh. --- .gitignore | 2 +- .vscode/launch.json | 21 ++++++++++++++++----- .vscode/tasks.json | 4 ++-- harness/app.go | 5 ++++- harness/harness.go | 5 ++++- model/command_config.go | 2 -- revel/new.go | 2 +- revel/run.go | 4 ++-- revel/test.go | 2 +- utils/command.go | 5 ++++- watcher/watcher.go | 2 +- 11 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 6ef72f8..ed465df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .idea/ *.iml - +.temp/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 9276550..fdaf289 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,12 +16,12 @@ "name": "Create new", "type": "go", "request": "launch", - "preLaunchTask": "Clean", + "preLaunchTask": "Clean-Test-Project", "mode": "auto", "program": "${workspaceRoot}/revel", - "args": ["new", "-a", "/tmp/revel/aaa"], + "args": ["new", "-v","-a", "${workspaceRoot}/.temp/revel/reveltest", "-p","revel.com/testproject"], "env": { - "GOPATH": "/tmp/revel/GOPATH" + "GOPATH": "${workspaceRoot}/.temp/revel/GOPATH" }, }, { @@ -30,9 +30,20 @@ "request": "launch", "mode": "auto", "program": "${workspaceRoot}/revel", - "args": ["run","-v", "-a", "/tmp/revel/aaa"], + "args": ["run","-v", "-v","-a", "${workspaceRoot}/.temp/revel/reveltest"], "env": { - "GOPATH": "/tmp/revel/GOPATH" + "GOPATH": "${workspaceRoot}/.temp/revel/GOPATH" + }, + }, + { + "name": "Run program Directly", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${workspaceRoot}/.temp/revel/reveltest/app/tmp/main.go", + "args": ["-port=34373","-importPath=revel.com/testproject/reveltest", "-runMode={\"mode\":\"dev\", \"specialUseFlag\":true,\"packagePathMap\":{\"github.com/revel/modules/static\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/static\",\"github.com/revel/modules/testrunner\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/testrunner\",\"github.com/revel/revel\":\"/home/notzippy/go/pkg/mod/github.com/revel/revel@v1.0.0\",\"revel.com/testproject/reveltest\":\"/mnt/DevSystem/Work/Workareas/revel/revel3/cmd/.temp/revel/reveltest\"}}"], + "env": { + "GOPATH": "${workspaceRoot}/.temp/revel/GOPATH" }, } ] diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7dd4621..c9112fb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,9 +4,9 @@ "version": "2.0.0", "tasks": [ { - "label": "Clean", + "label": "Clean-Test-Project", "type": "shell", - "command": "rm -rf /tmp/revel/aaa" + "command": "rm -rf ${workspaceRoot}/.temp/revel/testproject" } ] } \ No newline at end of file diff --git a/harness/app.go b/harness/app.go index 3536dc9..e879ee5 100644 --- a/harness/app.go +++ b/harness/app.go @@ -13,6 +13,7 @@ import ( "os/exec" "runtime" "sync" + "sync/atomic" "time" "github.com/revel/cmd/model" @@ -65,6 +66,7 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta func (cmd AppCmd) Start(c *model.CommandConfig) error { listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}} cmd.Stdout = listeningWriter + cmd.Stderr = listeningWriter utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath) utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env) if err := cmd.Cmd.Start(); err != nil { @@ -75,8 +77,9 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error { case exitState := <-cmd.waitChan(): fmt.Println("Startup failure view previous messages, \n Proxy is listening :", c.Run.Port) err := utils.NewError("", "Revel Run Error", "starting your application there was an exception. See terminal output, "+exitState, "") + atomic.SwapInt32(&startupError, 1) // TODO pretiffy command line output - // err.MetaError = listeningWriter.getLastOutput() + err.Stack = listeningWriter.buffer.String() return err case <-time.After(60 * time.Second): diff --git a/harness/harness.go b/harness/harness.go index 0bad2b0..10fbd7a 100644 --- a/harness/harness.go +++ b/harness/harness.go @@ -42,6 +42,8 @@ var ( doNotWatch = []string{"tmp", "views", "routes"} lastRequestHadError int32 + startupError int32 + startupErrorText error ) // Harness reverse proxies requests to the application server. @@ -255,7 +257,7 @@ func (h *Harness) refresh() (err *utils.SourceError) { if len(h.app.PackagePathMap) > 0 { paths, _ = json.Marshal(h.app.PackagePathMap) } - runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose, string(paths)) + runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose[0], string(paths)) } if err2 := h.app.Cmd(runMode).Start(h.config); err2 != nil { utils.Logger.Error("Could not start application", "error", err2) @@ -297,6 +299,7 @@ func (h *Harness) Run() { paths = append(paths, h.paths.CodePaths...) h.watcher = watcher.NewWatcher(h.paths, false) h.watcher.Listen(h, paths...) + go h.Refresh() // h.watcher.Notify() diff --git a/model/command_config.go b/model/command_config.go index aa0ad8f..744a03e 100644 --- a/model/command_config.go +++ b/model/command_config.go @@ -165,8 +165,6 @@ func (c *CommandConfig) initAppFolder() (err error) { } else { appFolder = filepath.Join(wd, appFolder) } - } else if strings.Contains(appFolder, ".") { - appFolder = filepath.Join(wd, filepath.Base(c.ImportPath)) } else if !filepath.IsAbs(appFolder) { appFolder = filepath.Join(wd, appFolder) } diff --git a/revel/new.go b/revel/new.go index a1461ab..5cc913e 100644 --- a/revel/new.go +++ b/revel/new.go @@ -19,7 +19,7 @@ import ( ) var cmdNew = &Command{ - UsageLine: "new -i [path] -s [skeleton]", + UsageLine: "new -i [path] -s [skeleton] -p [package name]", Short: "create a skeleton Revel application", Long: ` New creates a few files to get a new Revel application running quickly. diff --git a/revel/run.go b/revel/run.go index 1bbb619..7a7b0c1 100644 --- a/revel/run.go +++ b/revel/run.go @@ -133,7 +133,7 @@ func runApp(c *model.CommandConfig) (err error) { // If the app is run in "watched" mode, use the harness to run it. if revelPath.Config.BoolDefault("watch", true) && revelPath.Config.BoolDefault("watch.code", true) { utils.Logger.Info("Running in watched mode.") - runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, revelPath.RunMode, c.Verbose) + runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, revelPath.RunMode, c.Verbose[0]) if c.HistoricMode { runMode = revelPath.RunMode } @@ -152,7 +152,7 @@ func runApp(c *model.CommandConfig) (err error) { if len(app.PackagePathMap) > 0 { paths, _ = json.Marshal(app.PackagePathMap) } - runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose, string(paths)) + runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose[0], string(paths)) if c.HistoricMode { runMode = revelPath.RunMode } diff --git a/revel/test.go b/revel/test.go index dcba329..18f6cb2 100644 --- a/revel/test.go +++ b/revel/test.go @@ -112,7 +112,7 @@ func testApp(c *model.CommandConfig) (err error) { if len(app.PackagePathMap) > 0 { paths, _ = json.Marshal(app.PackagePathMap) } - runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose, string(paths)) + runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, app.Paths.RunMode, c.Verbose[0], string(paths)) if c.HistoricMode { runMode = app.Paths.RunMode } diff --git a/utils/command.go b/utils/command.go index a233659..12d1f38 100644 --- a/utils/command.go +++ b/utils/command.go @@ -17,6 +17,9 @@ func CmdInit(c *exec.Cmd, addGoPath bool, basePath string) { c.Env = ReducedEnv(addGoPath) } + +// ReducedEnv returns a list of environment vairables by using os.Env +// it will remove the GOPATH, GOROOT if addGoPath is true func ReducedEnv(addGoPath bool) []string { realPath := &bytes.Buffer{} env := []string{} @@ -38,7 +41,7 @@ func ReducedEnv(addGoPath bool) []string { if pair[0] == "GOMODCACHE" { continue } else if !addGoPath && (pair[0] == "GOPATH" || pair[0] == "GOROOT") { - + continue } env = append(env, e) } diff --git a/watcher/watcher.go b/watcher/watcher.go index 9a7c3f2..b3d7ad8 100644 --- a/watcher/watcher.go +++ b/watcher/watcher.go @@ -52,7 +52,7 @@ type Watcher struct { // Creates a new watched based on the container. func NewWatcher(paths *model.RevelContainer, eagerRefresh bool) *Watcher { return &Watcher{ - forceRefresh: false, + forceRefresh: true, lastError: -1, paths: paths, refreshTimerMS: time.Duration(paths.Config.IntDefault("watch.rebuild.delay", 1000)), From 3cd5ebbde205619abf5f58f93b4c57cd0a72f472 Mon Sep 17 00:00:00 2001 From: "notzippy@gmail.com" Date: Fri, 4 Mar 2022 17:21:29 -0800 Subject: [PATCH 6/8] Updated launch scripts --- .vscode/launch.json | 2 +- .vscode/tasks.json | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fdaf289..f69e0d5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,7 +41,7 @@ "request": "launch", "mode": "auto", "program": "${workspaceRoot}/.temp/revel/reveltest/app/tmp/main.go", - "args": ["-port=34373","-importPath=revel.com/testproject/reveltest", "-runMode={\"mode\":\"dev\", \"specialUseFlag\":true,\"packagePathMap\":{\"github.com/revel/modules/static\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/static\",\"github.com/revel/modules/testrunner\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/testrunner\",\"github.com/revel/revel\":\"/home/notzippy/go/pkg/mod/github.com/revel/revel@v1.0.0\",\"revel.com/testproject/reveltest\":\"/mnt/DevSystem/Work/Workareas/revel/revel3/cmd/.temp/revel/reveltest\"}}"], + "args": ["-port=9000","-importPath=revel.com/testproject/reveltest", "-runMode={\"mode\":\"dev\", \"specialUseFlag\":true,\"packagePathMap\":{\"github.com/revel/modules/static\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/static\",\"github.com/revel/modules/testrunner\":\"/home/notzippy/go/pkg/mod/github.com/revel/modules@v1.0.0/testrunner\",\"github.com/revel/revel\":\"/home/notzippy/go/pkg/mod/github.com/revel/revel@v1.0.0\",\"revel.com/testproject/reveltest\":\"/mnt/DevSystem/Work/Workareas/revel/revel3/cmd/.temp/revel/reveltest\"}}"], "env": { "GOPATH": "${workspaceRoot}/.temp/revel/GOPATH" }, diff --git a/.vscode/tasks.json b/.vscode/tasks.json index c9112fb..c1b7d3e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,6 +7,14 @@ "label": "Clean-Test-Project", "type": "shell", "command": "rm -rf ${workspaceRoot}/.temp/revel/testproject" - } + }, + { + "label": "Update Go Mod", + "type": "shell", + "options": { + "cwd": "${workspaceRoot}/.temp/revel/testproject" + }, + "command": "go mod tidy && go mod edit -replace github.com/revel/revel => ../../../revel" + }, ] } \ No newline at end of file From bb926f396a6e756bad2e0d7e35a31ab539477012 Mon Sep 17 00:00:00 2001 From: "notzippy@gmail.com" Date: Sat, 5 Mar 2022 09:10:51 -0800 Subject: [PATCH 7/8] Added additional pattern to test against Another different missing pacakge error thrown that can be detected and added This error occurs because a package may have been stripped down when originally loaded --- .vscode/load.sh | 1 + .vscode/load.web | 2 ++ harness/build.go | 5 +++++ 3 files changed, 8 insertions(+) create mode 100755 .vscode/load.sh create mode 100644 .vscode/load.web diff --git a/.vscode/load.sh b/.vscode/load.sh new file mode 100755 index 0000000..6a484dc --- /dev/null +++ b/.vscode/load.sh @@ -0,0 +1 @@ +http_load -rate 5 -seconds 10 load.web diff --git a/.vscode/load.web b/.vscode/load.web new file mode 100644 index 0000000..41d8a3d --- /dev/null +++ b/.vscode/load.web @@ -0,0 +1,2 @@ +http://localhost:9000/ +http://localhost:9000/miss diff --git a/harness/build.go b/harness/build.go index ff8009e..2d9f564 100644 --- a/harness/build.go +++ b/harness/build.go @@ -26,6 +26,7 @@ import ( var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"") var importErrorPattern2 = regexp.MustCompile("no required module provides package ([^;]+)+") +var addPackagePattern = regexp.MustCompile(`to add:\n\tgo get (.*)\n`) type ByString []*model.TypeInfo @@ -214,6 +215,10 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err if matches == nil { matches = importErrorPattern2.FindAllStringSubmatch(stOutput, -1) } + if matches == nil { + matches = addPackagePattern.FindAllStringSubmatch(stOutput, -1) + + } utils.Logger.Info("Build failed checking for missing imports", "message", stOutput, "missing_imports", len(matches)) if matches == nil { utils.Logger.Info("Build failed no missing imports", "message", stOutput) From 6dba0c3d2df3143c247e7f38e28f2fc5d2a0e629 Mon Sep 17 00:00:00 2001 From: "notzippy@gmail.com" Date: Sun, 6 Mar 2022 07:45:11 -0800 Subject: [PATCH 8/8] Fix bad error syntax An wrapped error message in the cmd module was referencing the wrong parameter value to be built closes revel/revel#1532 --- harness/harness.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harness/harness.go b/harness/harness.go index 10fbd7a..91947a1 100644 --- a/harness/harness.go +++ b/harness/harness.go @@ -243,7 +243,7 @@ func (h *Harness) refresh() (err *utils.SourceError) { } err = &utils.SourceError{ Title: "App failed to start up", - Description: err.Error(), + Description: newErr.Error(), } return }