webui-dev / go-webui

Use any web browser as GUI, with Go in the backend and modern web technologies in the frontend.
https://webui.me/
MIT License
170 stars 14 forks source link

build constraints exclude all Go files #22

Closed OwOday closed 11 months ago

OwOday commented 11 months ago

I get the following while trying to import go-webui/v2 after installing it every way that the readme describes:

package command-line-arguments
        imports github.com/webui-dev/go-webui/v2: build constraints exclude all Go files in C:\Users\trisi\hack\goglitch\go-webui\v2
ttytm commented 11 months ago

Trying to give some first-aid I would forward a stack overflow answer.

Can you try again after running:

go clean -modcache

Ref.: https://stackoverflow.com/a/73531307/18392410

To further analyze the problem if it doesn't work, can you please try to run the example relative to the package, and report the result? For this you clone the repository and copy or move the examples directory into the v2/ directory. If you run them here, they will use the relative package.

Like the readme instructcs: https://github.com/webui-dev/go-webui#as-git-clone-in-a-local-directory

OwOday commented 11 months ago

I tried the modcache thing before this post hmm, I think I got something working by enabling cgo, is that a requirement of this project?: install https://jmeubank.github.io/tdm-gcc/download/

go env -w CGO_ENABLED=1
go build

and then changing the code to:

w := webui.NewWindow()
webui.Show(w, "<html>Hello World</html>")
webui.Wait()

produces no errors but nothing seems to happen, I'm probably doing something wrong

OwOday commented 11 months ago

Seems like NewWindow doesnt really do anything, is this because I have webui setup wrong?

OwOday commented 11 months ago

ah, I got it working haha

OwOday commented 11 months ago

The things I did above + go run .

ttytm commented 11 months ago

Glad to hear it works. Yep, you need to run the program :D!

Explicitly enabling cgo is usually not required. But I guess it can be required depending on the setup. If you run into more issues, don't hesitate to reach out! Best with such step by step reproductions like you did then the issues gets more clear, and it's easier to help!

OwOday commented 11 months ago

Is there a version of examples that uses the new api?

ttytm commented 11 months ago

Yes, the current examples in the repository use it. They are made to work with the latest webui version and are not compatible with versions earlier than 2.4.0.

E.g.: https://github.com/webui-dev/go-webui/blob/main/examples/call_go_from_js.go

OwOday commented 11 months ago

Oh, for some reason my api looks more like this: https://pkg.go.dev/github.com/webui-dev/go-webui/v2@v2.4.0 which doesnt work with the example you listed

ttytm commented 11 months ago

Oh yeah, the wrapper got a re-write that fixed all known bugs and improved the setup process and the API. The version that you are linking might have a lot of things that do not work right. The readme currently lists to install it via:

go get github.com/webui-dev/go-webui/v2/@v2.4.0-beta.1

This will give you the version you see in the example. Another tag with this new version will be released soon.

OwOday commented 11 months ago

First I did this:

go get github.com/webui-dev/go-webui/v2/@v2.4.0-beta.1
irm https://raw.githubusercontent.com/webui-dev/go-webui/main/setup.ps1 | iex

then I still had to do this

I tried the modcache thing before this post hmm, I think I got something working by enabling cgo, is that a requirement of this project?: install https://jmeubank.github.io/tdm-gcc/download/

go env -w CGO_ENABLED=1
go build

but now the example code works as expected :)

ttytm commented 11 months ago

Another thing that comes to my mind now that I know about the version. It might have been necessary to explicitly enable CGO with that version. You can check if it's still required after you have made the update.