Safenetwork Git Portal Discussion

OMG this is exciting! I just made a major step towards a p2p git portal proof of concept.

After days fumbling with things I don’t understand I have a Go Wasm go-git app compiling (using a webpack golang wasm plugin) and can invoke git.Clone() in a web browser. Has anyone ever done this before?

Massive thanks to @lazyreader and @maxmcd on the Gophers slack who helped and I could not have done this without. Max spent ages with me on this.

I’m too excited to focus on the next things just now.


The ONE killer app is coming. :slight_smile:


Lots of killer apps could be built this way. It feels like I’ve invented fire! :fire:

By opening up the Safe platform to apps built using Golang and Rust to name just two, the whole landscape opens up. Existing code and skill sets all become options for building web, desktop and mobile apps. And if we have standard APIs like a POSIX filesystem, we make it even easier. Things are looking so good for Safe right now.


You have!

This is a killer app.


Gosh only a month since I kicked this off and so much progress! I’ll give a fuller update soon and a screencast demo before long, but I want to ask if anyone fancies doing a little side project.

It’s not a high priority, so I’ll not likely get around to it myself but this would still be a nice thing to have in the toolbag. It’s self contained so anyone could have a go at their own pace, and it won’t matter if you don’t finish it.

What I’d like is a web proxy, written in Golang to get around CORS issues when doing requests in the browser. This would ultimately live inside my Go/wasm app (or could be built with Rust/wasm etc), and although we won’t need this for Safe, it will ease adoption as well as help with testing and with inspiring folks with a cleaner easier to use demo. So a very nice but not vital to have. In the mean time I have workarounds, but they are a bit clunky. So it would be nice if it “just worked”.

I’m pretty sure this should be possible (Tauri does something like this for example), but it does need checking out - that a proxy can run like this within the browser. I’ve think I’ve seen a reference to doing this in JavaScript but not certain, but we can ask or you could build a test example to check a proxy can work like this before adding the features needed by such a proxy.

Let me know if you fancy having a go at Go, and if you need it I can help and give some pointers.

And watch this space for the next update!

UPDATE: I’m now less sure this would work, so if anyone who understands the idea thinks it would or would not work, please let me know. My concern is that if the proxy is in the wasm/web app, it may be forced to use http via the browser and unable to circumvent the CORS issue like an external proxy.


Update: First stage is complete - testing welcome!

I’ve finished proof of:

  • clone from git repositories
  • choose active repo from list of cloned repos
  • list commits from active repo

This should be much easier to try out than previously, so please have a go! Instructions here: GitHub - happybeing/p2p-git-portal-poc: p2p git portal proof-of-concept using Svelte Golang/WASM (experimental)

Next: git-bug

  • get compiling to web assembly
  • make into a package
  • modify to use go-billy filesystem for git and git-bug operations
  • integrate into the git portal

I also have a new offer of help to spruce up the UI! :partying_face:


This is awesome!! Way to go, @happybeing!!! :smile:


Nice - look forward to having another try at the weekend. What’s the URL? GitHub - happybeing/safenetwork-gitportal: p2p git portal - a decentralised alternative to github?

I think may be the one we need.


I found helpful

Interesting, I installed from scratch on Ubuntu 20.10 recently and had no problems installing yarn. Note: I prefer yarn but npm run is fine instead.

@Southside did you have success billing or running? I ask because of this issue, also on Ubuntu:

Fails to build for me on Mint 20

user@user:~/src/go_wasm/p2p-git-portal-poc$ yarn build
    ERROR in ./src/main.go
    Module build failed (from ./node_modules/golang-wasm-async-loader2/dist/index.js):
    Error: spawn /usr/lib/go-1.13/bin/go ENOENT
        at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
        at onErrorNT (internal/child_process.js:468:16)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)
     @ ./src/App.svelte 28:0-29 469:81-85
     @ ./src/main.js
     @ multi ./src/main.js

npm run gives:

user@user:~/src/go_wasm/p2p-git-portal-poc$ npm run
Scripts available in svelte-go-poc via `npm run-script`:

In case it helps, npm install works but then npm start gives

user@user:~/src/go_wasm/p2p-git-portal-poc$ npm start
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2020-11-21T10_52_41_001Z-debug.log

npm run is the way to run a script, so where you would use yarn <script> you can say npm run <script>

So in this case we have yarn build or npm run build. Sorry for not being clearer.

Thanks for the report. It confirms the issue is not isolated so I need to figure out why it is working for me and not for others. Can you try the following and report back:

In the repo ./src directory:

export GOROOT=`go env GOROOT`
export GOPATH=`go env GOPATH`
/usr/local/go/bin/go build -o /home/tychi/SourceCode/p2p-git-portal-poc/src/main.go.wasm /home/tychi/SourceCode/p2p-git-portal-poc/src/main.go

(I’m pretty sure it needs to be fine in the ./src directory, will check in a bit).

Thanks as always for diving in where others fear to tread. It’s very helpful.

I tried this - in my case there is no /usr/local/bin/go so I used
/usr/bin/go build -o /home/user/SourceCode/p2p-git-portal-poc/src/main.go.wasm /home/user/SourceCode/p2p-git-portal-poc/src/main.go

user@user:~/src/go_wasm/p2p-git-portal-poc$ /usr/bin/go build -o /home/user/SourceCode/p2p-git-portal-poc/src/main.go.wasm /home/user/SourceCode/p2p-git-portal-poc/src/main.go
can't load package: package /home/user/SourceCode/p2p-git-portal-poc/src/main.go: import "/home/user/SourceCode/p2p-git-portal-poc/src/main.go": cannot import absolute path
1 Like

Actually SourceCode is probably not correct is it?

1 Like

Oh b****s! Sorry, the evils of copy and paste. Those file paths apply to someone else’s system. Can you modify them to where your p2p-git-portal-poc directory is!

I’m my defence I haven’t got up properly yet. Saturday is our Sunday on the boat, so I’m still lazing on the sofa after my bacon sarny.

Which is, I’ll admit, not that unusual most days.


OK - same ‘absolute path’ error
user@user:~/src/go_wasm/p2p-git-portal-poc$ /usr/bin/go build -o /home/user/src/p2p-git-portal-poc/src/main.go.wasm /home/user/src/p2p-git-portal-poc/src/main.go
can’t load package: package /home/user/src/p2p-git-portal-poc/src/main.go: import “/home/user/src/p2p-git-portal-poc/src/main.go”: cannot import absolute path

And /home/user/src/p2p-git-portal-poc/src/main.go definitely exists?

If so, great, I’ll take a look shortly.

Are you sure it shouldn’t be:


Yes you’re right! It’s /home/user/src/go_wasm/p2p-git-portal-poc/src/main.go So what should the target directory be? /home/usr/src/ has two subdirectories, go_wasm and wasm_test.

I think it’s go_wasm, I changed the suggested location in the README so one is from the previous tests and the other you will have created for these tests. You can check the dates with ls -l.

Oh, and I think you need to run the command from the same directory as main.go