-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing the editor (tutorial platform) #24
Comments
Hey @amlwwalker, thanks for opening and the positive feedback! I love those ideas. A learning platform written in Go for Go is a fantastic goal I can get behind 😄
That's a great question. I actually do not have a tutorial for that one. Mostly, I pulled from my previous experience writing static sites to build up the look I wanted, and then later I used the APIs to build DOM elements for the entire UI instead of only part of it. I typically insert some shared HTML and stylesheets using Go's hackpad/cmd/editor/ide/settings.go Lines 18 to 23 in be2b4e1
Then connect some DOM elements with event listeners to parts of the application like the text input and button controls. You can find the whole editor is a Go program all stored in ./cmd/editor if you're curious.
Yes, certainly! The only unique Hackpad piece is I start the Line 25 in be2b4e1
and here: Line 77 in be2b4e1
The editor uses React under the hood today. In the future, I plan to remove as much of React as I can to simplify our dependencies a bit.
I think it may actually be easier to do in JS today, simply because really good development tools exist for those already. Doing it in Wasm is pretty fun though, so I wouldn't want to discourage you either way. 🙂 Turns out, you could write a UI using whichever tools you like! React certainly works (since we're using that now) and Go is an okay experience thus far. As mentioned above, it isn't quite as nice as a mature set of tools like React offers. I have seen some interesting Go UI libraries out there though. You might want to give these a try:
Yep, that works today! Give it a try and let me know if you hit any roadblocks. I've just noticed new editor tabs aren't working at all like they should... oof. We should fix that. I worked around it by writing and running a test in the terminal though (yes, it looks very silly without the editor working!): This is running the real Go CLI on a fake Node.js environment, so Go is totally convinced it's on a real system. There are some caveats, like binding to a port doesn't work, but generally most things work the way you'd expect.
Mocking out dependencies is 100% possible. Binding to a port for real isn't possible right now, but if you use a mock for that too, then you should be good to go. You might be able to "hack" in your own
Happy to provide! 😄 |
Hey @JohnStarich nothing too much yet but its working nicely using Go-App UI builder for web aseembly apps. I'm now trying to understand what I need from your repository to run the code from my editor. Could you give me some support as to what I need to do to:
It may just be a case of you telling me which of your main.go's I should run or might even be able to turn into functions and call from within my application - or is it a case (for the terminal) of creating a new instance of terminalBuilder from here ? if so I can probably work out how to get the output to display within my GUI if thats all I need. Do I have to manually run the OS or does that happen as a result of running the terminal? I attempted to run the main.go at the root of the repo but I get build constraint errors so wondering if thats not supposed to be directly run perhaps. Could you potentially give me a simple main.go that I can run from my terminal that builds a .wasm file that I can then fire up in my browser? Apologies if this all seems a bit basic - trying to get my head around your setup is slightly slow on my part 😂 but once I understand how to save text to file and compile it from the terminal/run it I should be off - just the hackpad demo is a kitchen sink and hopefully can get a barebones equivalent runnning! |
hey @JohnStarich just pinging this because I actually see an awesome usecase for this in writing (and teaching to write) blockchain contracts (that can be written in Go). Would love to have a little help getting the terminal/compiler in a simple standalone format that i can then learn from. Thanks again! |
Hey, sorry for the delay! I think all the necessary bits you need to run your own app are outlined in here: Lines 9 to 45 in 1f6b4af
and here: Lines 19 to 27 in 1f6b4af
where run isLines 54 to 57 in 1f6b4af
The setup should be significantly easier after the big refactor lands, but that's taking quite a while so probably best not to wait for it. If you run the JS I've linked above, you should be able to get everything up and running. Might be worth poking around in To get the As a note: hackpad.org is using CodeMirror for the text editing portion and xterm.js for the terminals. Let me know if you need any pointers to hook those together. |
You can run this repo as a local copy using
This might be the best spot to start with Go and Wasm: https://github.com/golang/go/wiki/WebAssembly |
Hey @JohnStarich - thanks for getting back to me. Since last speaking I've been doing a lot with Go-App and am itching to include your OS/terminal in there. I think I will wait and keep an eye on how the refactor goes because as you say I think it will be easier to follow the code through, but if you are working on it 😉 and during the refactor you are able to put simple examples of using the elements individually so we/I can build off of your components that would be epic.
both from Go and JS/webasm would be interesting. Its a very cool set of components you have here. I realise thats quite cheeky, as it is now its a lot to take in how its all put together and I think being able to build on top of your individual components will really make this an incredible bit of work Going through your code snippets now |
Hey,
This is super cool.
I have wanted for quite some time to build tutorials for the Go language using wasm (in browser) - you have probably jump started my work here by a mile.
The first step is to make a super interactive platform and a 'framework' for the tutorials so its fast and easy to add new ones.
Thoughts:
Questions
I looked through the code and see you are designing/rendering the UI in Go which was amazing/surprising. Two questions really - one is do you have a link to tutorial in how you are doing this, and secondly, could this be swapped out for HTML/CSS/JS or React or something easily? My guess is WASM means better to do all in Go, so question one is more the focus - i.e can you point me to anything to learn how to adjust the UI?
This sounds possible based on your "OS" - Would be cool if tests can run against code?
I suspect these last two are closely related and its either "thats easy" or "thats hard" as the OS isn't really "real".....
Anyway would love just to hear your thoughts on this usecase for this platform.
Thanks
The text was updated successfully, but these errors were encountered: