Closed deepch closed 7 years ago
@deepch you can still run go run *.go
without the bundler normally. Can you paste your bootstrap.Run
function here?
I tried the same thing on this demo with: run main.go
Does not work
It's expecting 3 flags when main.go is run
Maybe you can add something to the readme about how the bootstrap function should be ?
package main
import (
"flag"
astilectron "github.com/asticode/go-astilectron"
bootstrap "github.com/asticode/go-astilectron-bootstrap"
astilog "github.com/asticode/go-astilog"
"github.com/pkg/errors"
)
var (
AppName string
BuiltAt string
debug = flag.Bool("d", false, "if yes, the app is in debug mode")
window *astilectron.Window
)
func main() {
flag.Parse()
astilog.FlagInit()
StartAPIServer()
if err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AstilectronOptions: astilectron.Options{
AppName: AppName,
AppIconDarwinPath: "resources/gopher.icns",
AppIconDefaultPath: "resources/gopher.png",
},
Debug: false,
Homepage: "index.html",
RestoreAssets: RestoreAssets,
WindowOptions: &astilectron.WindowOptions{
BackgroundColor: astilectron.PtrStr("#333"),
Center: astilectron.PtrBool(true),
Resizable: astilectron.PtrBool(false),
Height: astilectron.PtrInt(600),
Width: astilectron.PtrInt(1280),
},
}); err != nil {
astilog.Fatal(errors.Wrap(err, "running bootstrap failed"))
}
}
default
i create empty folder (onvif-scaner) and download demo zip
export GOPATH=/Users/deepweb/Desktop/work/ipeye/onvif-scaner
go get
go run *.go == worked
bin/astilectron-bundler -v == broken
DEBU[0000]
Resetting
DEBU[0000] Creating /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/astibundler
DEBU[0000] Creating /Users/deepweb/Desktop/work/ipeye/onvif-scaner/output
DEBU[0000] Bundling for environment darwin/amd64
DEBU[0000] Removing /Users/deepweb/Desktop/work/ipeye/onvif-scaner/output/darwin-amd64
DEBU[0000] Creating /Users/deepweb/Desktop/work/ipeye/onvif-scaner/output/darwin-amd64
DEBU[0000] Binding data
DEBU[0000] Removing /Users/deepweb/Desktop/work/ipeye/onvif-scaner/vendor
DEBU[0000] Creating /Users/deepweb/Desktop/work/ipeye/onvif-scaner/vendor
DEBU[0000] /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/astibundler/astilectron-0.8.0.zip already exists, skipping download of https://github.com/asticode/astilectron/archive/v0.8.0.zip
DEBU[0000] Copying /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/astibundler/astilectron-0.8.0.zip to /Users/deepweb/Desktop/work/ipeye/onvif-scaner/vendor/astilectron.zip
DEBU[0000] /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/astibundler/electron-darwin-amd64-1.6.5.zip already exists, skipping download of https://github.com/electron/electron/releases/download/v1.6.5/electron-v1.6.5-darwin-x64.zip
DEBU[0000] Copying /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/astibundler/electron-darwin-amd64-1.6.5.zip to /Users/deepweb/Desktop/work/ipeye/onvif-scaner/vendor/electron.zip
DEBU[0001] Building for os darwin and arch amd64
DEBU[0001] Executing go build -ldflags -X "main.AppName=onvif" -X "main.BuiltAt=2017-09-08 21:53:22.080750511 +0300 MSK m=+1.779725999" -o /Users/deepweb/Desktop/work/ipeye/onvif-scaner/output/darwin-amd64/binary Users/deepweb/Desktop/work/ipeye/onvif-scaner
FATA[0001] bundling failed: bundling for environment darwin/amd64 failed: building failed: can't load package: package Users/deepweb/Desktop/work/ipeye/onvif-scaner: cannot find package "Users/deepweb/Desktop/work/ipeye/onvif-scaner" in any of:
/usr/local/go/src/Users/deepweb/Desktop/work/ipeye/onvif-scaner (from $GOROOT)
/Users/deepweb/Desktop/work/ipeye/onvif-scaner/src/Users/deepweb/Desktop/work/ipeye/onvif-scaner (from $GOPATH)
: exit status 1
it no my $GOPATH
/Users/deepweb/Desktop/work/ipeye/onvif-scaner/src/Users/deepweb/Desktop/work/ipeye/onvif-scaner (from $GOPATH)
my go $GOPATH
export GOPATH=/Users/deepweb/Desktop/work/ipeye/onvif-scaner
I probably already tortured the author;) Well, in fact, his work is just wonderful! and the amazing project
@joeblew99 running go run main.go
will fail for sure, since when using go run
you need to list all go files you need. If you only run go run main.go
, you will at least see ./main.go:75: undefined: handleMessages
which is normal since this function is in message.go
.
@deepch the problem is that the way you have set up the demo, it's not properly located in your $GOPATH.
You shouldn't download the demo manually during your first step. Your first step should be exporting your GOPATH, and then running go get -u github.com/asticode/go-astilectron-demo/...
. Then you should cd $GOPATH/src/github.com/asticode/go-astilectron-demo
and then astilectron-bundler -v
.
Otherwise, the demo is not in $GOPATH/src/github.com/asticode/go-astilectron-demo but in $GOPATH which is wrong.
@deepch I will try to find a way to make the demo testable with a simple go run *.go
I do not understand how it happened, but today everything began to work. very strange, apparently you have magic;)
export GOPATH=/Users/deepweb/Desktop/work/ipeye/onvif
cd $GOPATH/src/github.com/deepch/onvif
go run *.go
cd $GOPATH
I'm sure that yesterday it did not work, I'll follow that would not break. ;)
Thank you very much for the help.
@deepch unfortunately I don't have magic powers :D
For this issue, what I can do is add a astilectron-bundler bindata -v
command just to generate the bind.go
file that contains the embedded resources
and vendor
folders.
That way you don't have to go through all the bundler process to run go run *.go
, just the mandatory part that is generating the bind.go
file.
It would be great.
Updated the title, will do
@deepch I've added the subcommand in the bundler. Here's how you should use it:
If this is first time you run your application or either the vendor
(electron or astilectron's version for instance) or the resources
(you have updated the JS or HTML for instance) folders have been updated, run the following command:
$ astilectron-bundler bd -v
This will only generate the bind.go
file. You will then be able to use go run *.go
to test your app.
PS: First time you will run the subcommand, it might take some time as the bundler will download some stuff to put into its cache. Next time you'll run it, it will be way quicker.
Does that fix your problem and can we close this issue?
i found problem go run *.go if you rename project folder and config have environments
1) go-astilectron-demo or you program make config
{
"app_name": "onvif",
"environments": [
{"arch": "amd64", "os": "darwin"},
{"arch": "amd64", "os": "linux"},
{"arch": "amd64", "os": "windows"},
{"arch": "386", "os": "windows"}
],
"icon_path_darwin": "resources/gopher.icns",
"icon_path_linux": "resources/gopher.png",
"icon_path_windows": "resources/gopher.ico",
"output_path": "/Users/deepweb/Desktop/work/release/ipeye-onvif"
}
2) astilectron-bundler -v all work ok
3) go run *.go worked
4) rename you folder go-astilectron-demo -> to any
5) go run *.go not working
FATA[0001] running bootstrap failed: starting astilectron failed: provisioning failed: provisioning electron failed: finishing failed: finishing provisioning electron for darwin systems failed: copying for darwin system finish failed: copying /var/folde
rs/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/resources/gopher.icns to /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/vendor/electron-darwin-amd64/Electron.ap
p/Contents/Resources/electron.icns failed: open /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/vendor/electron-darwin-amd64/Electron.app/Contents/Resources/electron.icns: no such file or directory
exit status 1
6) astilectron-bundler -v worked
7) go run *.go not working
FATA[0001] running bootstrap failed: starting astilectron failed: provisioning failed: provisioning electron failed: finishing failed: finishing provisioning electron for darwin systems failed: copying for darwin system finish failed: copying /var/folde
rs/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/resources/gopher.icns to /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/vendor/electron-darwin-amd64/Electron.ap
p/Contents/Resources/electron.icns failed: open /var/folders/vp/706x_4j922qghd8dsv0t1cj80000gn/T/go-build412450274/command-line-arguments/_obj/exe/vendor/electron-darwin-amd64/Electron.app/Contents/Resources/electron.icns: no such file or directory
exit status 1
8) change config to
{
"app_name": "onvif",
"icon_path_darwin": "resources/gopher.icns",
"icon_path_linux": "resources/gopher.png",
"icon_path_windows": "resources/gopher.ico",
"output_path": "/Users/deepweb/Desktop/work/release/ipeye-onvif"
}
9) astilectron-bundler -v worked
10) go run *.go worked
in other words, if you rename the project directory, you need to remove it environments and astilectron-bundler -v after go run *.go worked
Removing the environments
is working because there's a problem during the darwin
bundling and you must be on a different OS. But I still need to fix the problem during the darwin
bundling... I'll take a look this week
Many thanks.
OK I got it, it totally makes sense.
What is happening is the following:
bind.go
file is generated and overwritten for each environments you specified.go run *.go
, it uses the last bind.go
generated and therefore it uses the bind.go
generated for windows/386.vendor
folder but it contains the windows/386 version of electron, not the darwin/amd64 which seems to be the OS you're onHere's my conclusion:
go run *.go
, only use the following bundler command:$ astilectron-bundler bd -v
$ astilectron-bundler -v
Does this fix your issue?
is "astilectron-bundler bd -v" new ?
yeah, I've mentionned it in a comment above: https://github.com/asticode/go-astilectron-demo/issues/5#issuecomment-328329701
yes it work
cd $GOPATH/src/github.com/deepch/ipeye-onvif
$GOPATH/bin/astilectron-bundler bd -v
go run app.go bind.go main.go onvif.go onvif_darwin.go queue.go storage.go support.go
cd $GOPATH
great!
you can still use go run *.go
instead of listing all the files normally
Closing this issue.
previous versions supported the launch go run *.go
new version need use
astilectron-bundler -v
It was very convenient for me to debug a running application using log print
new version